From gitlab at gitlab.haskell.org Sun Jan 1 11:35:30 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Sun, 01 Jan 2023 06:35:30 -0500 Subject: [Git][ghc/ghc][wip/andreask/spec-pragma] 91 commits: rts/Messages: Refactor Message-ID: <63b17002f2e93_2a26f5a43d37c820196f7@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/spec-pragma at Glasgow Haskell Compiler / GHC Commits: ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/ThreadPaused: Ordering fixes - - - - - 914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00 eventlog: Silence spurious data race - - - - - fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts: Use fences instead of explicit barriers - - - - - 2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - 70999283 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 98689f77 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - 86f20258 by Ben Gamari at 2022-12-16T16:12:45-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. - - - - - f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate access to capabilities array - - - - - 7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate sched_state - - - - - 1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Style fix - - - - - 82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00 compiler: Use release store in eager blackholing - - - - - eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Fix ordering of makeStableName - - - - - ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Note race with wakeBlockingQueue - - - - - 5acf33dd by Bodigrim at 2022-12-16T16:13:22-05:00 Bump submodule directory to 1.3.8.0 and hpc to HEAD - - - - - 0dd95421 by Bodigrim at 2022-12-16T16:13:22-05:00 Accept allocations increase on Windows This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips between lists and ByteArray. See #22625 for discussion. Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T10547 T12150 T12227 T12234 T12425 T13035 T13253 T13253-spj T13701 T13719 T15703 T16875 T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T21839r T5837 T6048 T9198 T9961 TcPlugin_RewritePerf hard_hole_fits - - - - - ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00 testsuite: Mark T9405 as fragile instead of broken on Windows It's starting to pass again, and the unexpected pass blocks CI. - - - - - 1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: remove obsolete commented code in wasm NCG It was just a temporary hack to workaround a bug in the relooper, that bug has been fixed long before the wasm backend is merged. - - - - - e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm Also removes some unreachable code here. - - - - - 1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: change fallback function signature to Cmm function signature in wasm NCG In the wasm NCG, when handling a `CLabel` of undefined function without knowing its function signature, we used to fallback to `() -> ()` which is accepted by `wasm-ld`. This patch changes it to the signature of Cmm functions, which equally works, but would be required when we emit tail call instructions. - - - - - 8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add optional tail-call support in wasm NCG When the `-mtail-call` clang flag is passed at configure time, wasm tail-call extension is enabled, and the wasm NCG will emit `return_call`/`return_call_indirect` instructions to take advantage of it and avoid the `StgRun` trampoline overhead. Closes #22461. - - - - - d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00 base: add missing autoconf checks for waitpid/umask These are not present in wasi-libc. Required for fixing #22589 - - - - - da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00 compiler: make .wasm the default executable extension on wasm32 Following convention as in other wasm toolchains. Fixes #22594. - - - - - ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00 ci: support hello.wasm in ci.sh cross testing logic - - - - - 6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00 Correct `exitWith` Haddocks The `IOError`-specific `catch` in the Prelude is long gone. - - - - - b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-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. - - - - - 761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00 rts/libdw: Silence uninitialized usage warnings As noted in #22538, previously some GCC versions warned that various locals in Libdw.c may be used uninitialized. Although this wasn't strictly true (since they were initialized in an inline assembler block) we fix this by providing explicit empty initializers. Fixes #22538 - - - - - 5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00 testsuite: Mark T16392 as fragile on windows See #22649 - - - - - 703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00 Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`. - - - - - 9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05: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 - - - - - 7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Drop uses of AC_PROG_CC_C99 As noted in #22566, this macro is deprecated as of autoconf-2.70 `AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself. Closes #22566. - - - - - 36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Use AS_HELP_STRING instead of AC_HELP_STRING The latter has been deprecated. See #22566. - - - - - befe6ff8 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: fix various usages of head and tail - - - - - 666d0ba7 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: avoid head and tail in parseCallEscape and around - - - - - 5d96fd50 by Bodigrim at 2022-12-20T21:16:37-05:00 Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty - - - - - 3ce2ab94 by Bodigrim at 2022-12-21T06:17:56-05:00 Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian - - - - - 954de93a by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule haskeline to HEAD (to allow transformers-0.6) - - - - - cefbeec3 by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule transformers to 0.6.0.4 - - - - - b4730b62 by Bodigrim at 2022-12-21T06:17:56-05:00 Fix tests T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations Metric Increase: T13253 - - - - - 0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05: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. - - - - - df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00 rts: explicitly store return value of ccall checkClosure to prevent type error (#22617) - - - - - e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix shadowing lacuna in OccurAnal Issue #22623 demonstrated another lacuna in the implementation of wrinkle (BS3) in Note [The binder-swap substitution] in the occurrence analyser. I was failing to add TyVar lambda binders using addInScope/addOneInScope and that led to a totally bogus binder-swap transformation. Very easy to fix. - - - - - 3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix an assertion check in addToEqualCtList The old assertion saw that a constraint ct could rewrite itself (of course it can) and complained (stupid). Fixes #22645 - - - - - ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00 configure: Bump version to 9.6 - - - - - fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00 base: Bump version to 4.18 Requires various submodule bumps. - - - - - 93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00 ghc-boot: Fix bootstrapping - - - - - fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00 Bump GHC version to 9.7 - - - - - 914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05: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. - - - - - 32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00 hadrian bindist: Install manpages to share/man/man1/ghc.1 When the installation makefile was copied over the manpages were no longer installed in the correct place. Now we install it into share/man/man1/ghc.1 as the make build system did. Fixes #22371 - - - - - b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00 rts: Drop paths from configure from cabal file A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them. - - - - - b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00 Bump libffi-tarballs submodule We will now use libffi-3.4.4. - - - - - 3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00 EPA: Make EOF position part of AnnsModule Closes #20951 Closes #19697 - - - - - 99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00 JS: fix support for -outputdir (#22641) The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug. - - - - - 02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00 Refactor mkRuntimeError This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions. - - - - - 35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00 base: Fix event manager shutdown race on non-Linux platforms During shutdown it's possible that we will attempt to use a closed fd to wakeup another capability's event manager. On the Linux eventfd path we were careful to handle this. However on the non-Linux path we failed to do so. Fix this. - - - - - 317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00 Fix unifier bug: failing to decompose over-saturated type family This simple patch fixes #22647 - - - - - 14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00 rts/m32: Fix sanity checking Previously we would attempt to clear pages which were marked as read-only. Fix this. - - - - - 16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00 ci: Move wasm pipelines into nightly rather than master See #22664 for the changes which need to be made to bring one of these back to the validate pipeline. - - - - - 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-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). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Bodigrim at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 18f2c302 by Andreas Klebinger at 2023-01-01T12:34:04+01:00 Allow combination of NOINLINE/INLINEABLE. We do this by also tracking INLINEABLE outside of the Unfolding data type as it's own flag. In the proccess of this I made a few other smaller changes. * Allow NOINLINE bindings to specialise with -fspecialise-aggressively. Fixes #21036 * Made rule source a proper type instead of Bool. ------------------------- Metric Decrease: T14766 T18304 Metric Increase: T10359 T13386 T15263 ------------------------- - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Wasm.hs - compiler/GHC/CmmToAsm/Wasm/Asm.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/Wasm/Types.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Rules.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7bbf5784303adbb752317f8a4062cd048e9b8651...18f2c302045fa26af9bb9d6be94dd56904a0f8f1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7bbf5784303adbb752317f8a4062cd048e9b8651...18f2c302045fa26af9bb9d6be94dd56904a0f8f1 You're receiving 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 Jan 1 17:16:21 2023 From: gitlab at gitlab.haskell.org (Tamar Christina (@Phyx)) Date: Sun, 01 Jan 2023 12:16:21 -0500 Subject: [Git][ghc/ghc][wip/T22166] 160 commits: Handle type data declarations in Template Haskell quotations and splices (fixes #22500) Message-ID: <63b1bfe58bf6e_2a26f5a43d37c82044832@gitlab.mail> Tamar Christina pushed to branch wip/T22166 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. - - - - - 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 - - - - - 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]. - - - - - 2eb0fb87 by Matthew Pickering at 2022-12-15T03:54:39-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 - - - - - 552b7908 by Ben Gamari at 2022-12-15T03:55:15-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. - - - - - 933d61a4 by Simon Peyton Jones at 2022-12-15T03:55:51-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. - - - - - 03ed0b95 by Ryan Scott at 2022-12-15T03:56:26-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. - - - - - ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/ThreadPaused: Ordering fixes - - - - - 914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00 eventlog: Silence spurious data race - - - - - fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts: Use fences instead of explicit barriers - - - - - 2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - 70999283 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 98689f77 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - 86f20258 by Ben Gamari at 2022-12-16T16:12:45-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. - - - - - f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate access to capabilities array - - - - - 7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate sched_state - - - - - 1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Style fix - - - - - 82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00 compiler: Use release store in eager blackholing - - - - - eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Fix ordering of makeStableName - - - - - ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Note race with wakeBlockingQueue - - - - - 5acf33dd by Bodigrim at 2022-12-16T16:13:22-05:00 Bump submodule directory to 1.3.8.0 and hpc to HEAD - - - - - 0dd95421 by Bodigrim at 2022-12-16T16:13:22-05:00 Accept allocations increase on Windows This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips between lists and ByteArray. See #22625 for discussion. Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T10547 T12150 T12227 T12234 T12425 T13035 T13253 T13253-spj T13701 T13719 T15703 T16875 T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T21839r T5837 T6048 T9198 T9961 TcPlugin_RewritePerf hard_hole_fits - - - - - ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00 testsuite: Mark T9405 as fragile instead of broken on Windows It's starting to pass again, and the unexpected pass blocks CI. - - - - - 1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: remove obsolete commented code in wasm NCG It was just a temporary hack to workaround a bug in the relooper, that bug has been fixed long before the wasm backend is merged. - - - - - e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm Also removes some unreachable code here. - - - - - 1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: change fallback function signature to Cmm function signature in wasm NCG In the wasm NCG, when handling a `CLabel` of undefined function without knowing its function signature, we used to fallback to `() -> ()` which is accepted by `wasm-ld`. This patch changes it to the signature of Cmm functions, which equally works, but would be required when we emit tail call instructions. - - - - - 8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add optional tail-call support in wasm NCG When the `-mtail-call` clang flag is passed at configure time, wasm tail-call extension is enabled, and the wasm NCG will emit `return_call`/`return_call_indirect` instructions to take advantage of it and avoid the `StgRun` trampoline overhead. Closes #22461. - - - - - d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00 base: add missing autoconf checks for waitpid/umask These are not present in wasi-libc. Required for fixing #22589 - - - - - da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00 compiler: make .wasm the default executable extension on wasm32 Following convention as in other wasm toolchains. Fixes #22594. - - - - - ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00 ci: support hello.wasm in ci.sh cross testing logic - - - - - 6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00 Correct `exitWith` Haddocks The `IOError`-specific `catch` in the Prelude is long gone. - - - - - b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-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. - - - - - 761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00 rts/libdw: Silence uninitialized usage warnings As noted in #22538, previously some GCC versions warned that various locals in Libdw.c may be used uninitialized. Although this wasn't strictly true (since they were initialized in an inline assembler block) we fix this by providing explicit empty initializers. Fixes #22538 - - - - - 5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00 testsuite: Mark T16392 as fragile on windows See #22649 - - - - - 703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00 Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`. - - - - - 9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05: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 - - - - - 7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Drop uses of AC_PROG_CC_C99 As noted in #22566, this macro is deprecated as of autoconf-2.70 `AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself. Closes #22566. - - - - - 36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Use AS_HELP_STRING instead of AC_HELP_STRING The latter has been deprecated. See #22566. - - - - - befe6ff8 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: fix various usages of head and tail - - - - - 666d0ba7 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: avoid head and tail in parseCallEscape and around - - - - - 5d96fd50 by Bodigrim at 2022-12-20T21:16:37-05:00 Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty - - - - - 3ce2ab94 by Bodigrim at 2022-12-21T06:17:56-05:00 Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian - - - - - 954de93a by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule haskeline to HEAD (to allow transformers-0.6) - - - - - cefbeec3 by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule transformers to 0.6.0.4 - - - - - b4730b62 by Bodigrim at 2022-12-21T06:17:56-05:00 Fix tests T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations Metric Increase: T13253 - - - - - 0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05: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. - - - - - df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00 rts: explicitly store return value of ccall checkClosure to prevent type error (#22617) - - - - - e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix shadowing lacuna in OccurAnal Issue #22623 demonstrated another lacuna in the implementation of wrinkle (BS3) in Note [The binder-swap substitution] in the occurrence analyser. I was failing to add TyVar lambda binders using addInScope/addOneInScope and that led to a totally bogus binder-swap transformation. Very easy to fix. - - - - - 3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix an assertion check in addToEqualCtList The old assertion saw that a constraint ct could rewrite itself (of course it can) and complained (stupid). Fixes #22645 - - - - - ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00 configure: Bump version to 9.6 - - - - - fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00 base: Bump version to 4.18 Requires various submodule bumps. - - - - - 93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00 ghc-boot: Fix bootstrapping - - - - - fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00 Bump GHC version to 9.7 - - - - - 914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05: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. - - - - - 32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00 hadrian bindist: Install manpages to share/man/man1/ghc.1 When the installation makefile was copied over the manpages were no longer installed in the correct place. Now we install it into share/man/man1/ghc.1 as the make build system did. Fixes #22371 - - - - - b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00 rts: Drop paths from configure from cabal file A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them. - - - - - b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00 Bump libffi-tarballs submodule We will now use libffi-3.4.4. - - - - - 3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00 EPA: Make EOF position part of AnnsModule Closes #20951 Closes #19697 - - - - - 99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00 JS: fix support for -outputdir (#22641) The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug. - - - - - 02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00 Refactor mkRuntimeError This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions. - - - - - 35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00 base: Fix event manager shutdown race on non-Linux platforms During shutdown it's possible that we will attempt to use a closed fd to wakeup another capability's event manager. On the Linux eventfd path we were careful to handle this. However on the non-Linux path we failed to do so. Fix this. - - - - - 317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00 Fix unifier bug: failing to decompose over-saturated type family This simple patch fixes #22647 - - - - - 14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00 rts/m32: Fix sanity checking Previously we would attempt to clear pages which were marked as read-only. Fix this. - - - - - 16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00 ci: Move wasm pipelines into nightly rather than master See #22664 for the changes which need to be made to bring one of these back to the validate pipeline. - - - - - 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-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). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Bodigrim at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 14ee7a04 by Ryan Scott at 2023-01-01T16:48:48+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 ``` - - - - - e3eee3be by Tamar Christina at 2023-01-01T17:15:12+00:00 linker: Fix BFD import libraries - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - compiler/CodeGen.Platform.h - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info/Build.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.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.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/CmmToAsm/Wasm.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 The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/457427c7b95fe6daf18f351a891515cd21b091a9...e3eee3bee5efa012cc2ecc44b51e3c3262093018 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/457427c7b95fe6daf18f351a891515cd21b091a9...e3eee3bee5efa012cc2ecc44b51e3c3262093018 You're receiving 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 Jan 1 17:54:29 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Sun, 01 Jan 2023 12:54:29 -0500 Subject: [Git][ghc/ghc][wip/rts-configure-0] Give the RTS it's own configure script Message-ID: <63b1c8d56485c_2a26f5a43d37c820471c5@gitlab.mail> John Ericson pushed to branch wip/rts-configure-0 at Glasgow Haskell Compiler / GHC Commits: d0a146a5 by John Ericson at 2023-01-01T12:48:47-05:00 Give the RTS it's own configure script Currently it doesn't do much anything, we are just trying to introduce it without breaking the build. Later, we will move functionality from the top-level configure script over to it. We need to bump Cabal for https://github.com/haskell/cabal/pull/8649; to facilitate and existing hack of skipping some configure checks for the RTS we now need to skip just *part* not *all* of the "post configure" hook, as running the configure script (which we definitely want to do) is also implemented as part of the "post configure" hook. But doing this requires exposing functionality that wasn't exposed before. - - - - - 14 changed files: - boot - hadrian/cabal.project - hadrian/hadrian.cabal - hadrian/src/Base.hs - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Lint.hs - hadrian/src/Rules/Register.hs - libraries/Cabal - libraries/base/.gitignore - m4/fp_find_libdw.m4 - rts/.gitignore - + rts/configure.ac - rts/rts.cabal.in Changes: ===================================== boot ===================================== @@ -63,7 +63,7 @@ def autoreconf(): else: reconf_cmd = 'autoreconf' - for dir_ in ['.'] + glob.glob('libraries/*/'): + for dir_ in ['.', 'rts'] + glob.glob('libraries/*/'): if os.path.isfile(os.path.join(dir_, 'configure.ac')): print("Booting %s" % dir_) # Update config.sub in submodules ===================================== hadrian/cabal.project ===================================== @@ -1,4 +1,6 @@ packages: ./ +-- N.B. This could be removed once Cabal 3.9 is released. +packages: ../libraries/Cabal/Cabal, ../libraries/Cabal/Cabal-syntax -- This essentially freezes the build plan for hadrian index-state: 2022-11-19T22:13:06Z ===================================== hadrian/hadrian.cabal ===================================== @@ -147,7 +147,7 @@ executable hadrian , BangPatterns other-extensions: MultiParamTypeClasses , TypeFamilies - build-depends: Cabal >= 3.2 && < 3.9 + build-depends: Cabal >= 3.9 && < 3.10 , base >= 4.8 && < 5 , bytestring >= 0.10 && < 0.12 , containers >= 0.5 && < 0.7 ===================================== hadrian/src/Base.hs ===================================== @@ -20,9 +20,6 @@ module Base ( module Stage, module Way, - -- * Files - configH, - -- * Paths hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, @@ -72,11 +69,6 @@ configFile = configPath -/- "system.config" sourcePath :: FilePath sourcePath = hadrianPath -/- "src" --- TODO: Change @mk/config.h@ to @shake-build/cfg/config.h at . --- | Path to the generated @mk/config.h@ file. -configH :: FilePath -configH = "mk/config.h" - -- | The directory in 'buildRoot' containing the Shake database and other -- auxiliary files generated by Hadrian. shakeFilesDir :: FilePath ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -146,22 +146,31 @@ configurePackage context at Context {..} = do need deps -- Figure out what hooks we need. - hooks <- case C.buildType (C.flattenPackageDescription gpd) of + hooks <- if + -- Not quite right, but good enough for us: + | package == rts -> + -- Don't try to do post configuration validation for 'rts'. This + -- will simply not work, due to the @ld-options@ and @Stg.h at . + -- + -- We used to just mkae the whole 'postConf' a no-op, but now + -- that th RTS has a configure script we do need to at least run + -- it, which is the first part of the stock 'postConf'. + pure $ C.autoconfUserHooks { + C.postConf = \_ flags pd lbi -> do + _ <- C.runConfigureScriptAndReadAndValidateBuildInfo flags pd lbi + pure () + } + | otherwise -> case C.buildType (C.flattenPackageDescription gpd) of C.Configure -> pure C.autoconfUserHooks + C.Simple -> pure C.simpleUserHooks + C.Make -> fail "build-type: Make is not supported" -- The 'time' package has a 'C.Custom' Setup.hs, but it's actually -- 'C.Configure' plus a @./Setup test@ hook. However, Cabal is also -- 'C.Custom', but doesn't have a configure script. C.Custom -> do - configureExists <- doesFileExist $ - replaceFileName (pkgCabalFile package) "configure" - pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks - -- Not quite right, but good enough for us: - _ | package == rts -> - -- Don't try to do post configuration validation for 'rts'. This - -- will simply not work, due to the @ld-options@ and @Stg.h at . - pure $ C.simpleUserHooks { C.postConf = \_ _ _ _ -> return () } - | otherwise -> pure C.simpleUserHooks - + configureExists <- doesFileExist $ + replaceFileName (pkgCabalFile package) "configure" + pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks -- Compute the list of flags, and the Cabal configuration arguments flavourArgs <- args <$> flavour flagList <- interpret (target context (Cabal Flags stage) [] []) flavourArgs ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -147,7 +147,8 @@ generatePackageCode context@(Context stage pkg _ _) = do root -/- "**" -/- dir -/- "cmm/AutoApply.cmm" %> \file -> build $ target context GenApply [] [file] let go gen file = generate file (semiEmptyTarget stage) gen - root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> go generateGhcAutoconfH + root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> \_ -> + need . pure =<< pkgSetupConfigFile context root -/- "**" -/- dir -/- "include/ghcplatform.h" %> go generateGhcPlatformH root -/- "**" -/- dir -/- "include/DerivedConstants.h" %> genPlatformConstantsHeader context root -/- "**" -/- dir -/- "include/rts/EventLogConstants.h" %> genEventTypes "--event-types-defines" @@ -486,26 +487,6 @@ generateConfigHs = do stageString (Stage0 GlobalLibs) = error "stageString: StageBoot" --- | Generate @ghcautoconf.h@ header. -generateGhcAutoconfH :: Expr String -generateGhcAutoconfH = do - trackGenerateHs - configHContents <- expr $ mapMaybe undefinePackage <$> readFileLines configH - return . unlines $ - [ "#if !defined(__GHCAUTOCONF_H__)" - , "#define __GHCAUTOCONF_H__" ] - ++ configHContents ++ - [ "#endif /* __GHCAUTOCONF_H__ */" ] - where - undefinePackage s - | "#define PACKAGE_" `isPrefixOf` s - = Just $ "/* #undef " ++ takeWhile (/=' ') (drop 8 s) ++ " */" - | "#define __GLASGOW_HASKELL" `isPrefixOf` s - = Nothing - | "/* REMOVE ME */" == s - = Nothing - | otherwise = Just s - -- | Generate @Version.hs@ files. generateVersionHs :: Expr String generateVersionHs = do ===================================== hadrian/src/Rules/Lint.hs ===================================== @@ -11,13 +11,15 @@ lintRules :: Rules () lintRules = do "lint:base" ~> lint base "lint:compiler" ~> lint compiler + + -- Ensure that autoconf scripts, which are usually run by Cabal, are run to + -- avoid depending upon Cabal from the stage0 compiler.. "libraries" -/- "base" -/- "include" -/- "HsBaseConfig.h" %> \_ -> -- ./configure is called here manually because we need to generate -- HsBaseConfig.h, which is created from HsBaseConfig.h.in. ./configure - -- is usually run by Cabal which generates this file but if we do that - -- then hadrian thinks it needs to build the stage0 compiler before - -- attempting to configure. Therefore we just run it directly here. cmd_ (Cwd "libraries/base") "./configure" + "rts" -/- "include" -/- "ghcautoconf.h" %> \_ -> + cmd_ (Cwd "rts") "./configure" lint :: Action () -> Action () lint lintAction = do ===================================== hadrian/src/Rules/Register.hs ===================================== @@ -45,6 +45,12 @@ configurePackageRules = do isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend when isGmp $ need [buildP -/- "include/ghc-gmp.h"] + when (pkg == rts) $ do + -- Rts.h is a header listed in the cabal file, and configuring + -- therefore wants to ensure that the header "works" post-configure. + -- But it (transitively) includes this, so we must ensure it exists + -- for that check to work. + need [buildP -/- "include/ghcplatform.h"] Cabal.configurePackage ctx root -/- "**/autogen/cabal_macros.h" %> \out -> do ===================================== libraries/Cabal ===================================== @@ -1 +1 @@ -Subproject commit 6cd29789ca866464dc3af89f62c98c41264ce3cd +Subproject commit 5abfa5032cb6f011c9a7e02d14c9f10dcb2d660d ===================================== libraries/base/.gitignore ===================================== @@ -19,4 +19,3 @@ /include/EventConfig.h /include/HsBaseConfig.h /include/HsBaseConfig.h.in - ===================================== m4/fp_find_libdw.m4 ===================================== @@ -48,9 +48,6 @@ AC_DEFUN([FP_FIND_LIBDW], AC_SUBST(UseLibdw) if test $UseLibdw = "YES" ; then USE_LIBDW=1 - AC_SUBST([CabalHaveLibdw],[True]) - else - AC_SUBST([CabalHaveLibdw],[False]) fi AC_DEFINE_UNQUOTED([USE_LIBDW], [$USE_LIBDW], [Set to 1 to use libdw]) ]) ===================================== rts/.gitignore ===================================== @@ -12,7 +12,12 @@ /package.conf.install.raw /fs.* +/aclocal.m4 /autom4te.cache/ /config.log /config.status /configure + +/ghcautoconf.h.autoconf.in +/ghcautoconf.h.autoconf +/include/ghcautoconf.h ===================================== rts/configure.ac ===================================== @@ -0,0 +1,57 @@ +# Configure script template for the Run-time System of GHC +# +# Process with 'autoreconf' to get a working configure script. +# +# For the generated configure script, do "./configure --help" to +# see what flags are available. (Better yet, read the documentation!) +# + +AC_INIT([GHC run-time system], [1.0.2], [libraries at haskell.org], [rts]) + +AC_CONFIG_MACRO_DIRS([../m4]) + +# Safety check: Ensure that we are in the correct source directory. +AC_CONFIG_SRCDIR([include/rts/Constants.h]) + +dnl * We require autoconf version 2.69 due to +dnl https://bugs.ruby-lang.org/issues/8179. Also see #14910. +dnl * We need 2.50 due to the use of AC_SYS_LARGEFILE and AC_MSG_NOTICE. +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.69]) + +AC_CONFIG_HEADERS([ghcautoconf.h.autoconf]) + +# We have to run these unconditionally, but we may discard their +# results in the following code +AC_CANONICAL_BUILD +AC_CANONICAL_HOST + +GHC_CONVERT_PLATFORM_PARTS([host], [Host]) +FPTOOLS_SET_PLATFORM_VARS([host], [Host]) +FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host]) + +AC_OUTPUT + +dnl ###################################################################### +dnl Generate ghcautoconf.h +dnl ###################################################################### + +[ +mkdir -p include +touch include/ghcautoconf.h +> include/ghcautoconf.h + +echo "#if !defined(__GHCAUTOCONF_H__)" >> include/ghcautoconf.h +echo "#define __GHCAUTOCONF_H__" >> include/ghcautoconf.h +# Copy the contents of $srcdir/../mk/config.h, turning '#define PACKAGE_FOO +# "blah"' into '/* #undef PACKAGE_FOO */' to avoid clashes. +cat $srcdir/../mk/config.h ghcautoconf.h.autoconf | sed \ + -e 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$,\1/* #undef \2 */,' \ + -e '/__GLASGOW_HASKELL/d' \ + -e '/REMOVE ME/d' \ + >> include/ghcautoconf.h +echo "#endif /* __GHCAUTOCONF_H__ */" >> include/ghcautoconf.h +] ===================================== rts/rts.cabal.in ===================================== @@ -1,9 +1,24 @@ cabal-version: 3.0 name: rts version: 1.0.2 +synopsis: The GHC runtime system +description: + The GHC runtime system. + + Code produced by GHC links this library to provide missing functionality + that cannot be written in Haskell itself. license: BSD-3-Clause maintainer: glasgow-haskell-users at haskell.org -build-type: Simple +build-type: Configure + +extra-source-files: + configure + configure.ac + +extra-tmp-files: + autom4te.cache + config.log + config.status source-repository head type: git @@ -206,6 +221,7 @@ library include-dirs: include includes: Rts.h + autogen-includes: ghcautoconf.h install-includes: Cmm.h HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h -- ^ from include View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d0a146a5914f62414b1b09d88741bf0da7f277d9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d0a146a5914f62414b1b09d88741bf0da7f277d9 You're receiving 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 Jan 2 06:18:11 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Mon, 02 Jan 2023 01:18:11 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/rts-configure-libdw-libnuma Message-ID: <63b277236940f_2a26f5c980f16420537da@gitlab.mail> John Ericson pushed new branch wip/rts-configure-libdw-libnuma at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/rts-configure-libdw-libnuma You're receiving 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 Jan 2 06:18:13 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Mon, 02 Jan 2023 01:18:13 -0500 Subject: [Git][ghc/ghc][wip/rts-configure-symbols] 2 commits: Give the RTS it's own configure script Message-ID: <63b27725f03b1_2a26f5a2ef946020538f5@gitlab.mail> John Ericson pushed to branch wip/rts-configure-symbols at Glasgow Haskell Compiler / GHC Commits: d0a146a5 by John Ericson at 2023-01-01T12:48:47-05:00 Give the RTS it's own configure script Currently it doesn't do much anything, we are just trying to introduce it without breaking the build. Later, we will move functionality from the top-level configure script over to it. We need to bump Cabal for https://github.com/haskell/cabal/pull/8649; to facilitate and existing hack of skipping some configure checks for the RTS we now need to skip just *part* not *all* of the "post configure" hook, as running the configure script (which we definitely want to do) is also implemented as part of the "post configure" hook. But doing this requires exposing functionality that wasn't exposed before. - - - - - dde92d14 by John Ericson at 2023-01-01T12:49:18-05:00 rts: Move external symbols logic to the configure script This is much more terse because we are programatically handling the leading underscore. - - - - - 16 changed files: - boot - hadrian/cabal.project - hadrian/hadrian.cabal - hadrian/src/Base.hs - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Lint.hs - hadrian/src/Rules/Register.hs - libraries/Cabal - libraries/base/.gitignore - m4/fp_find_libdw.m4 - rts/.gitignore - + rts/configure.ac - + rts/external-symbols.list.in - + rts/rts.buildinfo.in - rts/rts.cabal.in Changes: ===================================== boot ===================================== @@ -63,7 +63,7 @@ def autoreconf(): else: reconf_cmd = 'autoreconf' - for dir_ in ['.'] + glob.glob('libraries/*/'): + for dir_ in ['.', 'rts'] + glob.glob('libraries/*/'): if os.path.isfile(os.path.join(dir_, 'configure.ac')): print("Booting %s" % dir_) # Update config.sub in submodules ===================================== hadrian/cabal.project ===================================== @@ -1,4 +1,6 @@ packages: ./ +-- N.B. This could be removed once Cabal 3.9 is released. +packages: ../libraries/Cabal/Cabal, ../libraries/Cabal/Cabal-syntax -- This essentially freezes the build plan for hadrian index-state: 2022-11-19T22:13:06Z ===================================== hadrian/hadrian.cabal ===================================== @@ -147,7 +147,7 @@ executable hadrian , BangPatterns other-extensions: MultiParamTypeClasses , TypeFamilies - build-depends: Cabal >= 3.2 && < 3.9 + build-depends: Cabal >= 3.9 && < 3.10 , base >= 4.8 && < 5 , bytestring >= 0.10 && < 0.12 , containers >= 0.5 && < 0.7 ===================================== hadrian/src/Base.hs ===================================== @@ -20,9 +20,6 @@ module Base ( module Stage, module Way, - -- * Files - configH, - -- * Paths hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, @@ -72,11 +69,6 @@ configFile = configPath -/- "system.config" sourcePath :: FilePath sourcePath = hadrianPath -/- "src" --- TODO: Change @mk/config.h@ to @shake-build/cfg/config.h at . --- | Path to the generated @mk/config.h@ file. -configH :: FilePath -configH = "mk/config.h" - -- | The directory in 'buildRoot' containing the Shake database and other -- auxiliary files generated by Hadrian. shakeFilesDir :: FilePath ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -146,22 +146,31 @@ configurePackage context at Context {..} = do need deps -- Figure out what hooks we need. - hooks <- case C.buildType (C.flattenPackageDescription gpd) of + hooks <- if + -- Not quite right, but good enough for us: + | package == rts -> + -- Don't try to do post configuration validation for 'rts'. This + -- will simply not work, due to the @ld-options@ and @Stg.h at . + -- + -- We used to just mkae the whole 'postConf' a no-op, but now + -- that th RTS has a configure script we do need to at least run + -- it, which is the first part of the stock 'postConf'. + pure $ C.autoconfUserHooks { + C.postConf = \_ flags pd lbi -> do + _ <- C.runConfigureScriptAndReadAndValidateBuildInfo flags pd lbi + pure () + } + | otherwise -> case C.buildType (C.flattenPackageDescription gpd) of C.Configure -> pure C.autoconfUserHooks + C.Simple -> pure C.simpleUserHooks + C.Make -> fail "build-type: Make is not supported" -- The 'time' package has a 'C.Custom' Setup.hs, but it's actually -- 'C.Configure' plus a @./Setup test@ hook. However, Cabal is also -- 'C.Custom', but doesn't have a configure script. C.Custom -> do - configureExists <- doesFileExist $ - replaceFileName (pkgCabalFile package) "configure" - pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks - -- Not quite right, but good enough for us: - _ | package == rts -> - -- Don't try to do post configuration validation for 'rts'. This - -- will simply not work, due to the @ld-options@ and @Stg.h at . - pure $ C.simpleUserHooks { C.postConf = \_ _ _ _ -> return () } - | otherwise -> pure C.simpleUserHooks - + configureExists <- doesFileExist $ + replaceFileName (pkgCabalFile package) "configure" + pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks -- Compute the list of flags, and the Cabal configuration arguments flavourArgs <- args <$> flavour flagList <- interpret (target context (Cabal Flags stage) [] []) flavourArgs ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -147,7 +147,8 @@ generatePackageCode context@(Context stage pkg _ _) = do root -/- "**" -/- dir -/- "cmm/AutoApply.cmm" %> \file -> build $ target context GenApply [] [file] let go gen file = generate file (semiEmptyTarget stage) gen - root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> go generateGhcAutoconfH + root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> \_ -> + need . pure =<< pkgSetupConfigFile context root -/- "**" -/- dir -/- "include/ghcplatform.h" %> go generateGhcPlatformH root -/- "**" -/- dir -/- "include/DerivedConstants.h" %> genPlatformConstantsHeader context root -/- "**" -/- dir -/- "include/rts/EventLogConstants.h" %> genEventTypes "--event-types-defines" @@ -486,26 +487,6 @@ generateConfigHs = do stageString (Stage0 GlobalLibs) = error "stageString: StageBoot" --- | Generate @ghcautoconf.h@ header. -generateGhcAutoconfH :: Expr String -generateGhcAutoconfH = do - trackGenerateHs - configHContents <- expr $ mapMaybe undefinePackage <$> readFileLines configH - return . unlines $ - [ "#if !defined(__GHCAUTOCONF_H__)" - , "#define __GHCAUTOCONF_H__" ] - ++ configHContents ++ - [ "#endif /* __GHCAUTOCONF_H__ */" ] - where - undefinePackage s - | "#define PACKAGE_" `isPrefixOf` s - = Just $ "/* #undef " ++ takeWhile (/=' ') (drop 8 s) ++ " */" - | "#define __GLASGOW_HASKELL" `isPrefixOf` s - = Nothing - | "/* REMOVE ME */" == s - = Nothing - | otherwise = Just s - -- | Generate @Version.hs@ files. generateVersionHs :: Expr String generateVersionHs = do ===================================== hadrian/src/Rules/Lint.hs ===================================== @@ -11,13 +11,15 @@ lintRules :: Rules () lintRules = do "lint:base" ~> lint base "lint:compiler" ~> lint compiler + + -- Ensure that autoconf scripts, which are usually run by Cabal, are run to + -- avoid depending upon Cabal from the stage0 compiler.. "libraries" -/- "base" -/- "include" -/- "HsBaseConfig.h" %> \_ -> -- ./configure is called here manually because we need to generate -- HsBaseConfig.h, which is created from HsBaseConfig.h.in. ./configure - -- is usually run by Cabal which generates this file but if we do that - -- then hadrian thinks it needs to build the stage0 compiler before - -- attempting to configure. Therefore we just run it directly here. cmd_ (Cwd "libraries/base") "./configure" + "rts" -/- "include" -/- "ghcautoconf.h" %> \_ -> + cmd_ (Cwd "rts") "./configure" lint :: Action () -> Action () lint lintAction = do ===================================== hadrian/src/Rules/Register.hs ===================================== @@ -45,6 +45,12 @@ configurePackageRules = do isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend when isGmp $ need [buildP -/- "include/ghc-gmp.h"] + when (pkg == rts) $ do + -- Rts.h is a header listed in the cabal file, and configuring + -- therefore wants to ensure that the header "works" post-configure. + -- But it (transitively) includes this, so we must ensure it exists + -- for that check to work. + need [buildP -/- "include/ghcplatform.h"] Cabal.configurePackage ctx root -/- "**/autogen/cabal_macros.h" %> \out -> do ===================================== libraries/Cabal ===================================== @@ -1 +1 @@ -Subproject commit 6cd29789ca866464dc3af89f62c98c41264ce3cd +Subproject commit 5abfa5032cb6f011c9a7e02d14c9f10dcb2d660d ===================================== libraries/base/.gitignore ===================================== @@ -19,4 +19,3 @@ /include/EventConfig.h /include/HsBaseConfig.h /include/HsBaseConfig.h.in - ===================================== m4/fp_find_libdw.m4 ===================================== @@ -48,9 +48,6 @@ AC_DEFUN([FP_FIND_LIBDW], AC_SUBST(UseLibdw) if test $UseLibdw = "YES" ; then USE_LIBDW=1 - AC_SUBST([CabalHaveLibdw],[True]) - else - AC_SUBST([CabalHaveLibdw],[False]) fi AC_DEFINE_UNQUOTED([USE_LIBDW], [$USE_LIBDW], [Set to 1 to use libdw]) ]) ===================================== rts/.gitignore ===================================== @@ -12,7 +12,13 @@ /package.conf.install.raw /fs.* +/aclocal.m4 /autom4te.cache/ /config.log /config.status /configure + +/external-symbols.list +/ghcautoconf.h.autoconf.in +/ghcautoconf.h.autoconf +/include/ghcautoconf.h ===================================== rts/configure.ac ===================================== @@ -0,0 +1,86 @@ +# Configure script template for the Run-time System of GHC +# +# Process with 'autoreconf' to get a working configure script. +# +# For the generated configure script, do "./configure --help" to +# see what flags are available. (Better yet, read the documentation!) +# + +AC_INIT([GHC run-time system], [1.0.2], [libraries at haskell.org], [rts]) + +AC_CONFIG_MACRO_DIRS([../m4]) + +# Safety check: Ensure that we are in the correct source directory. +AC_CONFIG_SRCDIR([include/rts/Constants.h]) + +dnl * We require autoconf version 2.69 due to +dnl https://bugs.ruby-lang.org/issues/8179. Also see #14910. +dnl * We need 2.50 due to the use of AC_SYS_LARGEFILE and AC_MSG_NOTICE. +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.69]) + +AC_CONFIG_HEADERS([ghcautoconf.h.autoconf]) + +# We have to run these unconditionally, but we may discard their +# results in the following code +AC_CANONICAL_BUILD +AC_CANONICAL_HOST + +GHC_CONVERT_PLATFORM_PARTS([host], [Host]) +FPTOOLS_SET_PLATFORM_VARS([host], [Host]) +FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host]) + +AC_OUTPUT + +dnl ###################################################################### +dnl Generate ghcautoconf.h +dnl ###################################################################### + +[ +mkdir -p include +touch include/ghcautoconf.h +> include/ghcautoconf.h + +echo "#if !defined(__GHCAUTOCONF_H__)" >> include/ghcautoconf.h +echo "#define __GHCAUTOCONF_H__" >> include/ghcautoconf.h +# Copy the contents of $srcdir/../mk/config.h, turning '#define PACKAGE_FOO +# "blah"' into '/* #undef PACKAGE_FOO */' to avoid clashes. +cat $srcdir/../mk/config.h ghcautoconf.h.autoconf | sed \ + -e 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$,\1/* #undef \2 */,' \ + -e '/__GLASGOW_HASKELL/d' \ + -e '/REMOVE ME/d' \ + >> include/ghcautoconf.h +echo "#endif /* __GHCAUTOCONF_H__ */" >> include/ghcautoconf.h +] + +dnl ###################################################################### +dnl Generate external symbol flags (-Wl,-u...) +dnl ###################################################################### + +cat $srcdir/external-symbols.list.in \ + | "$CC" -E -P -traditional -Iinclude - -o - \ + | sed '/^$/d' \ + > external-symbols.list \ + || exit 1 + +mv external-symbols.list external-symbols.tmp +if [[ -n "$LeadingUnderscore" ]]; then + sed 's/^/ -Wl,-u_/' external-symbols.tmp > external-symbols.list +else + sed 's/^/ -Wl,-u/' external-symbols.tmp > external-symbols.list +fi +rm -f external-symbols.tmp + +dnl ###################################################################### +dnl Generate build-info +dnl ###################################################################### + +cat $srcdir/rts.buildinfo.in | \ + sed -e 's/^ *//' | \ + "$CC" -E -P -traditional - -o - \ + > rts.buildinfo +echo "" >> rts.buildinfo +rm -f external-symbols.list ===================================== rts/external-symbols.list.in ===================================== @@ -0,0 +1,103 @@ +#include "ghcautoconf.h" + +#if SIZEOF_VOID_P == 8 +hs_atomic_add64 +hs_atomic_sub64 +hs_atomic_and64 +hs_atomic_nand64 +hs_atomic_or64 +hs_atomic_xor64 +hs_atomicread64 +hs_atomicwrite64 +#endif + +#if mingw32_HOST_OS +base_GHCziEventziWindows_processRemoteCompletion_closure +#endif + +#if darwin_HOST_OS +#if 0 +See Note [fd_set_overflow] +#endif +__darwin_check_fd_set_overflow +#endif + +#if FIND_PTR +findPtr +#endif + +base_GHCziTopHandler_runIO_closure +base_GHCziTopHandler_runNonIO_closure +ghczmprim_GHCziTupleziPrim_Z0T_closure +ghczmprim_GHCziTypes_True_closure +ghczmprim_GHCziTypes_False_closure +base_GHCziPack_unpackCString_closure +base_GHCziWeakziFinalizze_runFinalizzerBatch_closure +base_GHCziIOziException_stackOverflow_closure +base_GHCziIOziException_heapOverflow_closure +base_GHCziIOziException_allocationLimitExceeded_closure +base_GHCziIOziException_blockedIndefinitelyOnMVar_closure +base_GHCziIOziException_blockedIndefinitelyOnSTM_closure +base_GHCziIOziException_cannotCompactFunction_closure +base_GHCziIOziException_cannotCompactPinned_closure +base_GHCziIOziException_cannotCompactMutable_closure +base_GHCziIOPort_doubleReadException_closure +base_ControlziExceptionziBase_nonTermination_closure +base_ControlziExceptionziBase_nestedAtomically_closure +base_GHCziEventziThread_blockedOnBadFD_closure +base_GHCziConcziSync_runSparks_closure +base_GHCziConcziIO_ensureIOManagerIsRunning_closure +base_GHCziConcziIO_interruptIOManager_closure +base_GHCziConcziIO_ioManagerCapabilitiesChanged_closure +base_GHCziConcziSignal_runHandlersPtr_closure +base_GHCziTopHandler_flushStdHandles_closure +base_GHCziTopHandler_runMainIO_closure +ghczmprim_GHCziTypes_Czh_con_info +ghczmprim_GHCziTypes_Izh_con_info +ghczmprim_GHCziTypes_Fzh_con_info +ghczmprim_GHCziTypes_Dzh_con_info +ghczmprim_GHCziTypes_Wzh_con_info +base_GHCziPtr_Ptr_con_info +base_GHCziPtr_FunPtr_con_info +base_GHCziInt_I8zh_con_info +base_GHCziInt_I16zh_con_info +base_GHCziInt_I32zh_con_info +base_GHCziInt_I64zh_con_info +base_GHCziWord_W8zh_con_info +base_GHCziWord_W16zh_con_info +base_GHCziWord_W32zh_con_info +base_GHCziWord_W64zh_con_info +base_GHCziStable_StablePtr_con_info +hs_atomic_add8 +hs_atomic_add16 +hs_atomic_add32 +hs_atomic_sub8 +hs_atomic_sub16 +hs_atomic_sub32 +hs_atomic_and8 +hs_atomic_and16 +hs_atomic_and32 +hs_atomic_nand8 +hs_atomic_nand16 +hs_atomic_nand32 +hs_atomic_or8 +hs_atomic_or16 +hs_atomic_or32 +hs_atomic_xor8 +hs_atomic_xor16 +hs_atomic_xor32 +hs_cmpxchg8 +hs_cmpxchg16 +hs_cmpxchg32 +hs_cmpxchg64 +hs_xchg8 +hs_xchg16 +hs_xchg32 +hs_xchg64 +hs_atomicread8 +hs_atomicread16 +hs_atomicread32 +hs_atomicwrite8 +hs_atomicwrite16 +hs_atomicwrite32 +base_GHCziStackziCloneStack_StackSnapshot_closure ===================================== rts/rts.buildinfo.in ===================================== @@ -0,0 +1,3 @@ +-- External symbols referenced by the RTS +ld-options: +#include "external-symbols.list" ===================================== rts/rts.cabal.in ===================================== @@ -1,9 +1,27 @@ cabal-version: 3.0 name: rts version: 1.0.2 +synopsis: The GHC runtime system +description: + The GHC runtime system. + + Code produced by GHC links this library to provide missing functionality + that cannot be written in Haskell itself. license: BSD-3-Clause maintainer: glasgow-haskell-users at haskell.org -build-type: Simple +build-type: Configure + +extra-source-files: + configure + configure.ac + external-symbols.list.in + rts.buildinfo.in + +extra-tmp-files: + autom4te.cache + rts.buildinfo + config.log + config.status source-repository head type: git @@ -206,6 +224,7 @@ library include-dirs: include includes: Rts.h + autogen-includes: ghcautoconf.h install-includes: Cmm.h HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h -- ^ from include @@ -275,200 +294,6 @@ library stg/SMP.h stg/Ticky.h stg/Types.h - if flag(64bit) - if flag(leading-underscore) - ld-options: - "-Wl,-u,_hs_atomic_add64" - "-Wl,-u,_hs_atomic_sub64" - "-Wl,-u,_hs_atomic_and64" - "-Wl,-u,_hs_atomic_nand64" - "-Wl,-u,_hs_atomic_or64" - "-Wl,-u,_hs_atomic_xor64" - "-Wl,-u,_hs_atomicread64" - "-Wl,-u,_hs_atomicwrite64" - else - ld-options: - "-Wl,-u,hs_atomic_add64" - "-Wl,-u,hs_atomic_sub64" - "-Wl,-u,hs_atomic_and64" - "-Wl,-u,hs_atomic_nand64" - "-Wl,-u,hs_atomic_or64" - "-Wl,-u,hs_atomic_xor64" - "-Wl,-u,hs_atomicread64" - "-Wl,-u,hs_atomicwrite64" - if flag(leading-underscore) - ld-options: - "-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_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" - "-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" - "-Wl,-u,_hs_atomic_sub8" - "-Wl,-u,_hs_atomic_sub16" - "-Wl,-u,_hs_atomic_sub32" - "-Wl,-u,_hs_atomic_and8" - "-Wl,-u,_hs_atomic_and16" - "-Wl,-u,_hs_atomic_and32" - "-Wl,-u,_hs_atomic_nand8" - "-Wl,-u,_hs_atomic_nand16" - "-Wl,-u,_hs_atomic_nand32" - "-Wl,-u,_hs_atomic_or8" - "-Wl,-u,_hs_atomic_or16" - "-Wl,-u,_hs_atomic_or32" - "-Wl,-u,_hs_atomic_xor8" - "-Wl,-u,_hs_atomic_xor16" - "-Wl,-u,_hs_atomic_xor32" - "-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" - "-Wl,-u,_hs_atomicwrite8" - "-Wl,-u,_hs_atomicwrite16" - "-Wl,-u,_hs_atomicwrite32" - "-Wl,-u,_base_GHCziStackziCloneStack_StackSnapshot_closure" - - if flag(find-ptr) - -- This symbol is useful in gdb, but not referred to anywhere, - -- so we need to force it to be included in the binary. - ld-options: "-Wl,-u,_findPtr" - - else - ld-options: - "-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_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" - "-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" - "-Wl,-u,hs_atomic_sub8" - "-Wl,-u,hs_atomic_sub16" - "-Wl,-u,hs_atomic_sub32" - "-Wl,-u,hs_atomic_and8" - "-Wl,-u,hs_atomic_and16" - "-Wl,-u,hs_atomic_and32" - "-Wl,-u,hs_atomic_nand8" - "-Wl,-u,hs_atomic_nand16" - "-Wl,-u,hs_atomic_nand32" - "-Wl,-u,hs_atomic_or8" - "-Wl,-u,hs_atomic_or16" - "-Wl,-u,hs_atomic_or32" - "-Wl,-u,hs_atomic_xor8" - "-Wl,-u,hs_atomic_xor16" - "-Wl,-u,hs_atomic_xor32" - "-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" - "-Wl,-u,hs_atomicwrite8" - "-Wl,-u,hs_atomicwrite16" - "-Wl,-u,hs_atomicwrite32" - "-Wl,-u,base_GHCziStackziCloneStack_StackSnapshot_closure" - - if flag(find-ptr) - -- This symbol is useful in gdb, but not referred to anywhere, - -- so we need to force it to be included in the binary. - ld-options: "-Wl,-u,findPtr" - - if os(windows) - if flag(leading-underscore) - ld-options: - "-Wl,-u,_base_GHCziEventziWindows_processRemoteCompletion_closure" - else - ld-options: - "-Wl,-u,base_GHCziEventziWindows_processRemoteCompletion_closure" if os(osx) ld-options: "-Wl,-search_paths_first" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5fc4044aa812d655f1a9d6efa86d0e4ac1e2a388...dde92d14a0dc64a1d3025ab97773bed72727b006 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5fc4044aa812d655f1a9d6efa86d0e4ac1e2a388...dde92d14a0dc64a1d3025ab97773bed72727b006 You're receiving 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 Jan 2 07:29:31 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Mon, 02 Jan 2023 02:29:31 -0500 Subject: [Git][ghc/ghc][wip/rts-configure-libdw-libnuma] Move lib{numa,dw} defines to RTS configure Message-ID: <63b287dbb3741_2a26f5563f80f820604d8@gitlab.mail> John Ericson pushed to branch wip/rts-configure-libdw-libnuma at Glasgow Haskell Compiler / GHC Commits: 7b2cf807 by John Ericson at 2023-01-02T02:28:55-05:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. - - - - - 5 changed files: - configure.ac - m4/fp_find_libdw.m4 - m4/fp_find_libnuma.m4 - rts/configure.ac - rts/posix/OSMem.c Changes: ===================================== configure.ac ===================================== @@ -1124,7 +1124,14 @@ AC_SUBST([UseLibffiForAdjustors]) dnl ** Other RTS features dnl -------------------------------------------------------------- FP_FIND_LIBDW +AC_SUBST(UseLibdw) +AC_SUBST(LibdwLibDir) +AC_SUBST(LibdwIncludeDir) + FP_FIND_LIBNUMA +AC_SUBST(UseLibNuma) +AC_SUBST(LibNumaLibDir) +AC_SUBST(LibNumaIncludeDir) dnl ** Documentation dnl -------------------------------------------------------------- ===================================== m4/fp_find_libdw.m4 ===================================== @@ -12,8 +12,6 @@ AC_DEFUN([FP_FIND_LIBDW], LIBDW_LDFLAGS="-L$withval" ]) - AC_SUBST(LibdwLibDir) - AC_ARG_WITH([libdw-includes], [AS_HELP_STRING([--with-libdw-includes=ARG], [Find includes for libdw in ARG [default=system default]]) @@ -23,32 +21,29 @@ AC_DEFUN([FP_FIND_LIBDW], LIBDW_CFLAGS="-I$withval" ]) - AC_SUBST(LibdwIncludeDir) + AC_ARG_ENABLE(dwarf-unwind, + [AS_HELP_STRING([--enable-dwarf-unwind], + [Enable DWARF unwinding support in the runtime system via elfutils' libdw [default=no]])], + [], + [enable_dwarf_unwind=no]) UseLibdw=NO - USE_LIBDW=0 - AC_ARG_ENABLE(dwarf-unwind, - [AS_HELP_STRING([--enable-dwarf-unwind], - [Enable DWARF unwinding support in the runtime system via elfutils' libdw [default=no]])]) - if test "$enable_dwarf_unwind" = "yes" ; then + if test "$enable_dwarf_unwind" != "no" ; then CFLAGS2="$CFLAGS" CFLAGS="$LIBDW_CFLAGS $CFLAGS" LDFLAGS2="$LDFLAGS" LDFLAGS="$LIBDW_LDFLAGS $LDFLAGS" - AC_CHECK_LIB(dw, dwfl_attach_state, - [AC_CHECK_HEADERS([elfutils/libdw.h], [break], []) - UseLibdw=YES], - [AC_MSG_ERROR([Cannot find system libdw (required by --enable-dwarf-unwind)])]) + AC_CHECK_HEADER([elfutils/libdwfl.h], + [AC_CHECK_LIB(dw, dwfl_attach_state, + [UseLibdw=YES])]) + + if test "x:$enable_dwarf_unwind:$UseLibdw" = "x:yes:NO" ; then + AC_MSG_ERROR([Cannot find system libdw (required by --enable-dwarf-unwind)]) + fi CFLAGS="$CFLAGS2" LDFLAGS="$LDFLAGS2" fi - - AC_SUBST(UseLibdw) - if test $UseLibdw = "YES" ; then - USE_LIBDW=1 - fi - AC_DEFINE_UNQUOTED([USE_LIBDW], [$USE_LIBDW], [Set to 1 to use libdw]) ]) ===================================== m4/fp_find_libnuma.m4 ===================================== @@ -11,8 +11,6 @@ AC_DEFUN([FP_FIND_LIBNUMA], LIBNUMA_LDFLAGS="-L$withval" ]) - AC_SUBST(LibNumaLibDir) - AC_ARG_WITH([libnuma-includes], [AS_HELP_STRING([--with-libnuma-includes=ARG], [Find includes for libnuma in ARG [default=system default]]) @@ -22,14 +20,14 @@ AC_DEFUN([FP_FIND_LIBNUMA], LIBNUMA_CFLAGS="-I$withval" ]) - AC_SUBST(LibNumaIncludeDir) - - HaveLibNuma=0 AC_ARG_ENABLE(numa, - [AS_HELP_STRING([--enable-numa], - [Enable NUMA memory policy and thread affinity support in the - runtime system via numactl's libnuma [default=auto]])]) + [AS_HELP_STRING([--enable-numa], + [Enable NUMA memory policy and thread affinity support in the + runtime system via numactl's libnuma [default=auto]])], + [], + [enable_numa=auto]) + UseLibNuma=NO if test "$enable_numa" != "no" ; then CFLAGS2="$CFLAGS" CFLAGS="$LIBNUMA_CFLAGS $CFLAGS" @@ -38,23 +36,14 @@ AC_DEFUN([FP_FIND_LIBNUMA], AC_CHECK_HEADERS([numa.h numaif.h]) - if test "$ac_cv_header_numa_h$ac_cv_header_numaif_h" = "yesyes" ; then - AC_CHECK_LIB(numa, numa_available,HaveLibNuma=1) + if test "x:$ac_cv_header_numa_h:$ac_cv_header_numaif_h" = "x:yes:yes" ; then + AC_CHECK_LIB([numa], [numa_available], [UseLibNuma=YES]) fi - if test "$enable_numa:$HaveLibNuma" = "yes:0" ; then - AC_MSG_ERROR([Cannot find system libnuma (required by --enable-numa)]) + if test "x:$enable_numa:$UseLibNuma" = "x:yes:NO" ; then + AC_MSG_ERROR([Cannot find system libnuma (required by --enable-numa)]) fi CFLAGS="$CFLAGS2" LDFLAGS="$LDFLAGS2" fi - - AC_DEFINE_UNQUOTED([HAVE_LIBNUMA], [$HaveLibNuma], [Define to 1 if you have libnuma]) - if test $HaveLibNuma = "1" ; then - AC_SUBST([UseLibNuma],[YES]) - AC_SUBST([CabalHaveLibNuma],[True]) - else - AC_SUBST([UseLibNuma],[NO]) - AC_SUBST([CabalHaveLibNuma],[False]) - fi ]) ===================================== rts/configure.ac ===================================== @@ -33,6 +33,15 @@ GHC_CONVERT_PLATFORM_PARTS([host], [Host]) FPTOOLS_SET_PLATFORM_VARS([host], [Host]) FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host]) +dnl ** Other RTS features +dnl -------------------------------------------------------------- +AC_DEFINE_UNQUOTED([USE_LIBDW], [$CABAL_FLAG_libdw], [Set to 1 to use libdw]) + +AC_DEFINE_UNQUOTED([HAVE_LIBNUMA], [$CABAL_FLAG_libnuma], [Define to 1 if you have libnuma]) + +dnl ** Write config files +dnl -------------------------------------------------------------- + AC_OUTPUT dnl ###################################################################### ===================================== rts/posix/OSMem.c ===================================== @@ -30,10 +30,8 @@ #if defined(HAVE_FCNTL_H) #include #endif -#if defined(HAVE_NUMA_H) +#if HAVE_LIBNUMA #include -#endif -#if defined(HAVE_NUMAIF_H) #include #endif #if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_SYS_TIME_H) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7b2cf80717a6b16e3f6135c6c6905bd5d3bbde72 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7b2cf80717a6b16e3f6135c6c6905bd5d3bbde72 You're receiving 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 Jan 2 07:55:00 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Mon, 02 Jan 2023 02:55:00 -0500 Subject: [Git][ghc/ghc][wip/rts-configure-2] 4 commits: Give the RTS it's own configure script Message-ID: <63b28dd49597c_2a26f5563f80f82060652@gitlab.mail> John Ericson pushed to branch wip/rts-configure-2 at Glasgow Haskell Compiler / GHC Commits: d0a146a5 by John Ericson at 2023-01-01T12:48:47-05:00 Give the RTS it's own configure script Currently it doesn't do much anything, we are just trying to introduce it without breaking the build. Later, we will move functionality from the top-level configure script over to it. We need to bump Cabal for https://github.com/haskell/cabal/pull/8649; to facilitate and existing hack of skipping some configure checks for the RTS we now need to skip just *part* not *all* of the "post configure" hook, as running the configure script (which we definitely want to do) is also implemented as part of the "post configure" hook. But doing this requires exposing functionality that wasn't exposed before. - - - - - dde92d14 by John Ericson at 2023-01-01T12:49:18-05:00 rts: Move external symbols logic to the configure script This is much more terse because we are programatically handling the leading underscore. - - - - - 7b2cf807 by John Ericson at 2023-01-02T02:28:55-05:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. - - - - - 7beb9fff by Ben Gamari at 2023-01-02T02:52:48-05:00 rts configure script Need to use CPP not `if` in rts.buildinfo Bump cabal submodule to include https://github.com/haskell/cabal/pull/8565 - - - - - 30 changed files: - boot - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Linker/Static.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings/IO.hs - configure.ac - distrib/configure.ac.in - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cabal.project - hadrian/cfg/system.config.in - hadrian/hadrian.cabal - hadrian/src/Base.hs - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Lint.hs - hadrian/src/Rules/Register.hs - hadrian/src/Settings/Packages.hs - libraries/Cabal - libraries/base/.gitignore - rts/.gitignore - + rts/configure.ac - + rts/external-symbols.list.in - rts/include/rts/PosixSource.h - rts/linker/Elf.c - rts/linker/elf_got.c - m4/fp_bfd_support.m4 → rts/m4/fp_bfd_support.m4 - m4/fp_cc_supports__atomics.m4 → rts/m4/fp_cc_supports__atomics.m4 The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7e365a6c44292f8f3e37c38a932c29339987e759...7beb9fff1bee1ccbf7f2258ce527b8d5df2a85ea -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7e365a6c44292f8f3e37c38a932c29339987e759...7beb9fff1bee1ccbf7f2258ce527b8d5df2a85ea You're receiving 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 Jan 2 07:56:10 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Mon, 02 Jan 2023 02:56:10 -0500 Subject: [Git][ghc/ghc][wip/rts-configure] 19 commits: Give the RTS it's own configure script Message-ID: <63b28e1a1a0f3_2a26f52aa67bb82061061@gitlab.mail> John Ericson pushed to branch wip/rts-configure at Glasgow Haskell Compiler / GHC Commits: d0a146a5 by John Ericson at 2023-01-01T12:48:47-05:00 Give the RTS it's own configure script Currently it doesn't do much anything, we are just trying to introduce it without breaking the build. Later, we will move functionality from the top-level configure script over to it. We need to bump Cabal for https://github.com/haskell/cabal/pull/8649; to facilitate and existing hack of skipping some configure checks for the RTS we now need to skip just *part* not *all* of the "post configure" hook, as running the configure script (which we definitely want to do) is also implemented as part of the "post configure" hook. But doing this requires exposing functionality that wasn't exposed before. - - - - - dde92d14 by John Ericson at 2023-01-01T12:49:18-05:00 rts: Move external symbols logic to the configure script This is much more terse because we are programatically handling the leading underscore. - - - - - 7b2cf807 by John Ericson at 2023-01-02T02:28:55-05:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. - - - - - 36a8f0e6 by John Ericson at 2023-01-02T02:55:22-05:00 RTS configure: handle ffi adjustor method - - - - - 17a32a15 by John Ericson at 2023-01-02T02:55:22-05:00 rts configure: Move over eventfd, __thread, and mem mgmt checks - - - - - b0883352 by John Ericson at 2023-01-02T02:55:22-05:00 move FP_CHECK_PTHREADS to RTS configure - - - - - a8fe729b by John Ericson at 2023-01-02T02:55:22-05:00 Move apple compat check to RTS configure - - - - - 569129db by John Ericson at 2023-01-02T02:55:22-05:00 Move visibility and clock_gettime checks to RTS configure - - - - - 93ba3eae by John Ericson at 2023-01-02T02:55:22-05:00 Move leading underscore checks to RTS configure - - - - - 2986dee7 by John Ericson at 2023-01-02T02:55:22-05:00 Move alloca, fork, const, and big endian checks to RTS configure - - - - - a66c9cdc by John Ericson at 2023-01-02T02:55:22-05:00 Move libdl check to RTS configure - - - - - 88648b4a by John Ericson at 2023-01-02T02:55:22-05:00 Do FP_FIND_LIBFFI in RTS configure too - - - - - ee8824e5 by John Ericson at 2023-01-02T02:55:22-05:00 Split BFD support to RTS configure - - - - - 12b63260 by John Ericson at 2023-01-02T02:55:22-05:00 Split libm check between top level and RTS - - - - - 3f9d0618 by John Ericson at 2023-01-02T02:55:22-05:00 Split mingwex check between top level and RTS - - - - - 4b0bb6ab by John Ericson at 2023-01-02T02:55:22-05:00 Move function checks to RTS configure Some of these functions are used in `base` too, but we can copy the checks over to its configure if that's an issue. - - - - - 4bf32240 by John Ericson at 2023-01-02T02:55:22-05:00 Move over a number of C-style checks to RTS configure - - - - - ec6d3c89 by John Ericson at 2023-01-02T02:55:22-05:00 Move/Copy remaining AC_DEFINE to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - e5be71a2 by John Ericson at 2023-01-02T02:55:22-05:00 Generate ghcplatform.h from RTS configure - - - - - 25 changed files: - boot - configure.ac - hadrian/cabal.project - hadrian/hadrian.cabal - hadrian/src/Base.hs - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Lint.hs - hadrian/src/Rules/Register.hs - libraries/Cabal - libraries/base/.gitignore - m4/fp_bfd_support.m4 - m4/fp_cc_supports__atomics.m4 - m4/fp_check_pthreads.m4 - m4/fp_find_libdw.m4 - m4/fp_find_libnuma.m4 - m4/fptools_set_haskell_platform_vars.m4 - rts/.gitignore - + rts/configure.ac - + rts/external-symbols.list.in - + rts/ghcplatform.h.bottom - + rts/ghcplatform.h.top.in - rts/posix/OSMem.c - + rts/rts.buildinfo.in - rts/rts.cabal.in Changes: ===================================== boot ===================================== @@ -63,7 +63,7 @@ def autoreconf(): else: reconf_cmd = 'autoreconf' - for dir_ in ['.'] + glob.glob('libraries/*/'): + for dir_ in ['.', 'rts'] + glob.glob('libraries/*/'): if os.path.isfile(os.path.join(dir_, 'configure.ac')): print("Booting %s" % dir_) # Update config.sub in submodules ===================================== configure.ac ===================================== @@ -142,28 +142,6 @@ if test "$EnableDistroToolchain" = "YES"; then TarballsAutodownload=NO fi -AC_ARG_ENABLE(asserts-all-ways, -[AS_HELP_STRING([--enable-asserts-all-ways], - [Usually ASSERTs are only compiled in the DEBUG way, - this will enable them in all ways.])], - [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableAssertsAllWays])], - [EnableAssertsAllWays=NO] -) -if test "$enable_asserts_all_ways" = "yes" ; then - AC_DEFINE([USE_ASSERTS_ALL_WAYS], [1], [Compile-in ASSERTs in all ways.]) -fi - -AC_ARG_ENABLE(native-io-manager, -[AS_HELP_STRING([--enable-native-io-manager], - [Enable the native I/O manager by default.])], - [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableNativeIOManager])], - [EnableNativeIOManager=NO] -) -if test "$EnableNativeIOManager" = "YES"; then - AC_DEFINE_UNQUOTED([DEFAULT_NATIVE_IO_MANAGER], [1], [Enable Native I/O manager as default.]) -fi - - dnl CC_STAGE0, LD_STAGE0, AR_STAGE0 are like the "previous" variable dnl CC, LD, AR (inherited by CC_STAGE[123], etc.) dnl but instead used by stage0 for bootstrapping stage1 @@ -325,9 +303,6 @@ dnl ** Do a build with tables next to code? dnl -------------------------------------------------------------- GHC_TABLES_NEXT_TO_CODE -if test x"$TablesNextToCode" = xYES; then - AC_DEFINE([TABLES_NEXT_TO_CODE], [1], [Define to 1 if info tables are laid out next to code]) -fi AC_SUBST(TablesNextToCode) dnl ** Does target have runtime linker support? @@ -637,14 +612,17 @@ dnl unregisterised, Sparc, and PPC backends. Also determines whether dnl linking to libatomic is required for atomic operations, e.g. on dnl RISCV64 GCC. FP_CC_SUPPORTS__ATOMICS +if test "$need_latomic" = 1; then + AC_SUBST([NeedLibatomic],[YES]) +else + AC_SUBST([NeedLibatomic],[NO]) +fi FP_GCC_EXTRA_FLAGS dnl ** look to see if we have a C compiler using an llvm back end. dnl FP_CC_LLVM_BACKEND -AS_IF([test x"$CcLlvmBackend" = x"YES"], - [AC_DEFINE([CC_LLVM_BACKEND], [1], [Define (to 1) if C compiler has an LLVM back end])]) AC_SUBST(CcLlvmBackend) FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS]) @@ -835,60 +813,8 @@ dnl -------------------------------------------------- dnl ### program checking section ends here ### dnl -------------------------------------------------- -dnl -------------------------------------------------- -dnl * Platform header file and syscall feature tests -dnl ### checking the state of the local header files and syscalls ### - -dnl ** Enable large file support. NB. do this before testing the type of -dnl off_t, because it will affect the result of that test. -AC_SYS_LARGEFILE - -dnl ** check for specific header (.h) files that we are interested in -AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timerfd.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h utime.h windows.h winsock.h sched.h]) - -dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708 -AC_CHECK_HEADERS([sys/cpuset.h], [], [], -[[#if HAVE_SYS_PARAM_H -# include -#endif -]]) - -dnl ** check whether a declaration for `environ` is provided by libc. -FP_CHECK_ENVIRON - -dnl ** do we have long longs? -AC_CHECK_TYPES([long long]) - -dnl ** what are the sizes of various types -FP_CHECK_SIZEOF_AND_ALIGNMENT(char) -FP_CHECK_SIZEOF_AND_ALIGNMENT(double) -FP_CHECK_SIZEOF_AND_ALIGNMENT(float) -FP_CHECK_SIZEOF_AND_ALIGNMENT(int) -FP_CHECK_SIZEOF_AND_ALIGNMENT(long) -if test "$ac_cv_type_long_long" = yes; then -FP_CHECK_SIZEOF_AND_ALIGNMENT(long long) -fi -FP_CHECK_SIZEOF_AND_ALIGNMENT(short) -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned char) -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned int) -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long) -if test "$ac_cv_type_long_long" = yes; then -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long long) -fi -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned short) -FP_CHECK_SIZEOF_AND_ALIGNMENT(void *) - -FP_CHECK_SIZEOF_AND_ALIGNMENT(int8_t) -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint8_t) -FP_CHECK_SIZEOF_AND_ALIGNMENT(int16_t) -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint16_t) -FP_CHECK_SIZEOF_AND_ALIGNMENT(int32_t) -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint32_t) -FP_CHECK_SIZEOF_AND_ALIGNMENT(int64_t) -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint64_t) - - dnl for use in settings file +AC_CHECK_SIZEOF([void *]) TargetWordSize=$ac_cv_sizeof_void_p if test "x$TargetWordSize" = x8; then AC_SUBST([Cabal64bit],[True]) @@ -900,28 +826,6 @@ AC_SUBST(TargetWordSize) AC_C_BIGENDIAN([TargetWordBigEndian=YES],[TargetWordBigEndian=NO]) AC_SUBST(TargetWordBigEndian) -FP_CHECK_FUNC([WinExec], - [@%:@include ], [WinExec("",0)]) - -FP_CHECK_FUNC([GetModuleFileName], - [@%:@include ], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)]) - -dnl ** check for more functions -dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too. -AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity sched_getaffinity setlocale uselocale]) - -dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if -dnl ** _POSIX_C_SOURCE is defined -AC_CHECK_DECLS([ctime_r], , , -[#define _POSIX_SOURCE 1 -#define _POSIX_C_SOURCE 199506L -#include ]) - -dnl On Linux we should have program_invocation_short_name -AC_CHECK_DECLS([program_invocation_short_name], , , -[#define _GNU_SOURCE 1 -#include ]) - dnl ** check for mingwex library AC_CHECK_LIB( [mingwex], @@ -929,27 +833,18 @@ AC_CHECK_LIB( [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 dnl for math functions or not dnl (see https://gitlab.haskell.org/ghc/ghc/issues/3730) -AC_CHECK_LIB(m, atan, HaveLibM=YES, HaveLibM=NO) -if test $HaveLibM = YES -then - AC_DEFINE([HAVE_LIBM], [1], [Define to 1 if you need to link with libm]) - AC_SUBST([UseLibm],[YES]) -else - AC_SUBST([UseLibm],[NO]) -fi -TargetHasLibm=$HaveLibM +AC_CHECK_LIB(m, atan, UseLibm=YES, UseLibm=NO) +AC_SUBST([UseLibm]) +TargetHasLibm=$UseLibM AC_SUBST(TargetHasLibm) FP_BFD_SUPPORT +AC_SUBST([UseLibbfd],[$haveLibbfd]) dnl ################################################################ dnl Check for libraries @@ -959,164 +854,27 @@ FP_FIND_LIBFFI AC_SUBST(UseSystemLibFFI) dnl ** check whether we need -ldl to get dlopen() -AC_CHECK_LIB([dl], [dlopen]) -AC_CHECK_LIB([dl], [dlopen], HaveLibdl=YES, HaveLibdl=NO) -AC_SUBST([UseLibdl],[$HaveLibdl]) -dnl ** check whether we have dlinfo -AC_CHECK_FUNCS([dlinfo]) - -dnl -------------------------------------------------- -dnl * Miscellaneous feature tests -dnl -------------------------------------------------- - -dnl ** can we get alloca? -AC_FUNC_ALLOCA - -dnl ** working vfork? -AC_FUNC_FORK - -dnl ** determine whether or not const works -AC_C_CONST - -dnl ** are we big endian? -AC_C_BIGENDIAN -FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN +AC_CHECK_LIB([dl], [dlopen], UseLibdl=YES, UseLibdl=NO) +AC_SUBST([UseLibdl]) dnl ** check for leading underscores in symbol names FP_LEADING_UNDERSCORE AC_SUBST([LeadingUnderscore], [`echo $fptools_cv_leading_underscore | sed 'y/yesno/YESNO/'`]) if test x"$fptools_cv_leading_underscore" = xyes; then AC_SUBST([CabalLeadingUnderscore],[True]) - AC_DEFINE([LEADING_UNDERSCORE], [1], [Define to 1 if C symbols have a leading underscore added by the compiler.]) else AC_SUBST([CabalLeadingUnderscore],[False]) fi -FP_VISIBILITY_HIDDEN - -FP_MUSTTAIL - dnl ** check for librt -AC_CHECK_LIB([rt], [clock_gettime]) -AC_CHECK_LIB([rt], [clock_gettime], HaveLibrt=YES, HaveLibrt=NO) -if test $HaveLibrt = YES -then - AC_SUBST([UseLibrt],[YES]) -else - AC_SUBST([UseLibrt],[NO]) -fi -AC_CHECK_FUNCS(clock_gettime timer_settime) -FP_CHECK_TIMER_CREATE - -dnl ** check for Apple's "interesting" long double compatibility scheme -AC_MSG_CHECKING(for printf\$LDBLStub) -AC_LINK_IFELSE([AC_LANG_CALL([], [printf\$LDBLStub])], - [ - AC_MSG_RESULT(yes) - AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[1], - [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).]) - ], - [ - AC_MSG_RESULT(no) - AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[0], - [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).]) - ]) +AC_CHECK_LIB([rt], [clock_gettime], UseLibrt=YES, UseLibrt=NO) +AC_SUBST([UseLibrt]) FP_CHECK_PTHREADS - -dnl ** check for eventfd which is needed by the I/O manager -AC_CHECK_HEADERS([sys/eventfd.h]) -AC_CHECK_FUNCS([eventfd]) - -AC_CHECK_FUNCS([getpid getuid raise]) - -dnl ** Check for __thread support in the compiler -AC_MSG_CHECKING(for __thread support) -AC_COMPILE_IFELSE( - [ AC_LANG_SOURCE([[__thread int tester = 0;]]) ], - [ - AC_MSG_RESULT(yes) - AC_DEFINE([CC_SUPPORTS_TLS],[1],[Define to 1 if __thread is supported]) - ], - [ - AC_MSG_RESULT(no) - AC_DEFINE([CC_SUPPORTS_TLS],[0],[Define to 1 if __thread is supported]) - ]) - -dnl large address space support (see rts/include/rts/storage/MBlock.h) -dnl -dnl Darwin has vm_allocate/vm_protect -dnl Linux has mmap(MAP_NORESERVE)/madv(MADV_DONTNEED) -dnl FreeBSD, Solaris and maybe other have MAP_NORESERVE/MADV_FREE -dnl (They also have MADV_DONTNEED, but it means something else!) -dnl -dnl Windows has VirtualAlloc MEM_RESERVE/MEM_COMMIT, however -dnl it counts page-table space as committed memory, and so quickly -dnl runs out of paging file when we have multiple processes reserving -dnl 1TB of address space, we get the following error: -dnl VirtualAlloc MEM_RESERVE 1099512676352 bytes failed: The paging file is too small for this operation to complete. -dnl - -AC_ARG_ENABLE(large-address-space, - [AS_HELP_STRING([--enable-large-address-space], - [Use a single large address space on 64 bit systems (enabled by default on 64 bit platforms)])], - EnableLargeAddressSpace=$enableval, - EnableLargeAddressSpace=yes -) - -use_large_address_space=no -if test "$ac_cv_sizeof_void_p" -eq 8 ; then - if test "x$EnableLargeAddressSpace" = "xyes" ; then - if test "$ghc_host_os" = "darwin" ; then - use_large_address_space=yes - elif test "$ghc_host_os" = "openbsd" ; then - # as of OpenBSD 5.8 (2015), OpenBSD does not support mmap with MAP_NORESERVE. - # The flag MAP_NORESERVE is supported for source compatibility reasons, - # but is completely ignored by OS mmap - use_large_address_space=no - elif test "$ghc_host_os" = "mingw32" ; then - # as of Windows 8.1/Server 2012 windows does no longer allocate the page - # tabe for reserved memory eagerly. So we are now free to use LAS there too. - use_large_address_space=yes - else - AC_CHECK_DECLS([MAP_NORESERVE, MADV_FREE, MADV_DONTNEED],[],[], - [ - #include - #include - #include - #include - ]) - if test "$ac_cv_have_decl_MAP_NORESERVE" = "yes" && - test "$ac_cv_have_decl_MADV_FREE" = "yes" || - test "$ac_cv_have_decl_MADV_DONTNEED" = "yes" ; then - use_large_address_space=yes - fi - fi - fi -fi -if test "$use_large_address_space" = "yes" ; then - AC_DEFINE([USE_LARGE_ADDRESS_SPACE], [1], [Enable single heap address space support]) -fi - -dnl ** Use MMAP in the runtime linker? -dnl -------------------------------------------------------------- - -case ${TargetOS} in - linux|linux-android|freebsd|dragonfly|netbsd|openbsd|kfreebsdgnu|gnu|solaris2) - RtsLinkerUseMmap=1 - ;; - darwin|ios|watchos|tvos) - RtsLinkerUseMmap=1 - ;; - *) - # Windows (which doesn't have mmap) and everything else. - RtsLinkerUseMmap=0 - ;; - esac - -AC_DEFINE_UNQUOTED([RTS_LINKER_USE_MMAP], [$RtsLinkerUseMmap], - [Use mmap in the runtime linker]) - +AS_IF([test x"$need_lpthread" = 1], + [UseLibpthread=YES], + [UseLibpthread=NO]) +AC_SUBST([UseLibpthread]) GHC_ADJUSTORS_METHOD([Target]) AC_SUBST([UseLibffiForAdjustors]) @@ -1124,7 +882,14 @@ AC_SUBST([UseLibffiForAdjustors]) dnl ** Other RTS features dnl -------------------------------------------------------------- FP_FIND_LIBDW +AC_SUBST(UseLibdw) +AC_SUBST(LibdwLibDir) +AC_SUBST(LibdwIncludeDir) + FP_FIND_LIBNUMA +AC_SUBST(UseLibNuma) +AC_SUBST(LibNumaLibDir) +AC_SUBST(LibNumaIncludeDir) dnl ** Documentation dnl -------------------------------------------------------------- ===================================== hadrian/cabal.project ===================================== @@ -1,4 +1,6 @@ packages: ./ +-- N.B. This could be removed once Cabal 3.9 is released. +packages: ../libraries/Cabal/Cabal, ../libraries/Cabal/Cabal-syntax -- This essentially freezes the build plan for hadrian index-state: 2022-11-19T22:13:06Z ===================================== hadrian/hadrian.cabal ===================================== @@ -147,7 +147,7 @@ executable hadrian , BangPatterns other-extensions: MultiParamTypeClasses , TypeFamilies - build-depends: Cabal >= 3.2 && < 3.9 + build-depends: Cabal >= 3.9 && < 3.10 , base >= 4.8 && < 5 , bytestring >= 0.10 && < 0.12 , containers >= 0.5 && < 0.7 ===================================== hadrian/src/Base.hs ===================================== @@ -20,9 +20,6 @@ module Base ( module Stage, module Way, - -- * Files - configH, - -- * Paths hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, @@ -72,11 +69,6 @@ configFile = configPath -/- "system.config" sourcePath :: FilePath sourcePath = hadrianPath -/- "src" --- TODO: Change @mk/config.h@ to @shake-build/cfg/config.h at . --- | Path to the generated @mk/config.h@ file. -configH :: FilePath -configH = "mk/config.h" - -- | The directory in 'buildRoot' containing the Shake database and other -- auxiliary files generated by Hadrian. shakeFilesDir :: FilePath ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -146,22 +146,31 @@ configurePackage context at Context {..} = do need deps -- Figure out what hooks we need. - hooks <- case C.buildType (C.flattenPackageDescription gpd) of + hooks <- if + -- Not quite right, but good enough for us: + | package == rts -> + -- Don't try to do post configuration validation for 'rts'. This + -- will simply not work, due to the @ld-options@ and @Stg.h at . + -- + -- We used to just mkae the whole 'postConf' a no-op, but now + -- that th RTS has a configure script we do need to at least run + -- it, which is the first part of the stock 'postConf'. + pure $ C.autoconfUserHooks { + C.postConf = \_ flags pd lbi -> do + _ <- C.runConfigureScriptAndReadAndValidateBuildInfo flags pd lbi + pure () + } + | otherwise -> case C.buildType (C.flattenPackageDescription gpd) of C.Configure -> pure C.autoconfUserHooks + C.Simple -> pure C.simpleUserHooks + C.Make -> fail "build-type: Make is not supported" -- The 'time' package has a 'C.Custom' Setup.hs, but it's actually -- 'C.Configure' plus a @./Setup test@ hook. However, Cabal is also -- 'C.Custom', but doesn't have a configure script. C.Custom -> do - configureExists <- doesFileExist $ - replaceFileName (pkgCabalFile package) "configure" - pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks - -- Not quite right, but good enough for us: - _ | package == rts -> - -- Don't try to do post configuration validation for 'rts'. This - -- will simply not work, due to the @ld-options@ and @Stg.h at . - pure $ C.simpleUserHooks { C.postConf = \_ _ _ _ -> return () } - | otherwise -> pure C.simpleUserHooks - + configureExists <- doesFileExist $ + replaceFileName (pkgCabalFile package) "configure" + pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks -- Compute the list of flags, and the Cabal configuration arguments flavourArgs <- args <$> flavour flagList <- interpret (target context (Cabal Flags stage) [] []) flavourArgs ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -146,9 +146,10 @@ generatePackageCode context@(Context stage pkg _ _) = do when (pkg == rts) $ do root -/- "**" -/- dir -/- "cmm/AutoApply.cmm" %> \file -> build $ target context GenApply [] [file] - let go gen file = generate file (semiEmptyTarget stage) gen - root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> go generateGhcAutoconfH - root -/- "**" -/- dir -/- "include/ghcplatform.h" %> go generateGhcPlatformH + root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> \_ -> + need . pure =<< pkgSetupConfigFile context + root -/- "**" -/- dir -/- "include/ghcplatform.h" %> \_ -> + need . pure =<< pkgSetupConfigFile context root -/- "**" -/- dir -/- "include/DerivedConstants.h" %> genPlatformConstantsHeader context root -/- "**" -/- dir -/- "include/rts/EventLogConstants.h" %> genEventTypes "--event-types-defines" root -/- "**" -/- dir -/- "include/rts/EventTypes.h" %> genEventTypes "--event-types-array" @@ -319,59 +320,6 @@ ghcWrapper stage = do else []) ++ [ "$@" ] --- | Given a 'String' replace characters '.' and '-' by underscores ('_') so that --- the resulting 'String' is a valid C preprocessor identifier. -cppify :: String -> String -cppify = replaceEq '-' '_' . replaceEq '.' '_' - --- | Generate @ghcplatform.h@ header. -generateGhcPlatformH :: Expr String -generateGhcPlatformH = do - trackGenerateHs - stage <- getStage - let chooseSetting x y = getSetting $ case stage of { Stage0 {} -> x; _ -> y } - buildPlatform <- chooseSetting BuildPlatform HostPlatform - buildArch <- chooseSetting BuildArch HostArch - buildOs <- chooseSetting BuildOs HostOs - buildVendor <- chooseSetting BuildVendor HostVendor - hostPlatform <- chooseSetting HostPlatform TargetPlatform - hostArch <- chooseSetting HostArch TargetArch - hostOs <- chooseSetting HostOs TargetOs - hostVendor <- chooseSetting HostVendor TargetVendor - ghcUnreg <- getFlag GhcUnregisterised - return . unlines $ - [ "#if !defined(__GHCPLATFORM_H__)" - , "#define __GHCPLATFORM_H__" - , "" - , "#define BuildPlatform_TYPE " ++ cppify buildPlatform - , "#define HostPlatform_TYPE " ++ cppify hostPlatform - , "" - , "#define " ++ cppify buildPlatform ++ "_BUILD 1" - , "#define " ++ cppify hostPlatform ++ "_HOST 1" - , "" - , "#define " ++ buildArch ++ "_BUILD_ARCH 1" - , "#define " ++ hostArch ++ "_HOST_ARCH 1" - , "#define BUILD_ARCH " ++ show buildArch - , "#define HOST_ARCH " ++ show hostArch - , "" - , "#define " ++ buildOs ++ "_BUILD_OS 1" - , "#define " ++ hostOs ++ "_HOST_OS 1" - , "#define BUILD_OS " ++ show buildOs - , "#define HOST_OS " ++ show hostOs - , "" - , "#define " ++ buildVendor ++ "_BUILD_VENDOR 1" - , "#define " ++ hostVendor ++ "_HOST_VENDOR 1" - , "#define BUILD_VENDOR " ++ show buildVendor - , "#define HOST_VENDOR " ++ show hostVendor - , "" - ] - ++ - [ "#define UnregisterisedCompiler 1" | ghcUnreg ] - ++ - [ "" - , "#endif /* __GHCPLATFORM_H__ */" - ] - -- See Note [tooldir: How GHC finds mingw on Windows] generateSettings :: Expr String generateSettings = do @@ -486,26 +434,6 @@ generateConfigHs = do stageString (Stage0 GlobalLibs) = error "stageString: StageBoot" --- | Generate @ghcautoconf.h@ header. -generateGhcAutoconfH :: Expr String -generateGhcAutoconfH = do - trackGenerateHs - configHContents <- expr $ mapMaybe undefinePackage <$> readFileLines configH - return . unlines $ - [ "#if !defined(__GHCAUTOCONF_H__)" - , "#define __GHCAUTOCONF_H__" ] - ++ configHContents ++ - [ "#endif /* __GHCAUTOCONF_H__ */" ] - where - undefinePackage s - | "#define PACKAGE_" `isPrefixOf` s - = Just $ "/* #undef " ++ takeWhile (/=' ') (drop 8 s) ++ " */" - | "#define __GLASGOW_HASKELL" `isPrefixOf` s - = Nothing - | "/* REMOVE ME */" == s - = Nothing - | otherwise = Just s - -- | Generate @Version.hs@ files. generateVersionHs :: Expr String generateVersionHs = do ===================================== hadrian/src/Rules/Lint.hs ===================================== @@ -11,13 +11,17 @@ lintRules :: Rules () lintRules = do "lint:base" ~> lint base "lint:compiler" ~> lint compiler + + -- Ensure that autoconf scripts, which are usually run by Cabal, are run to + -- avoid depending upon Cabal from the stage0 compiler.. "libraries" -/- "base" -/- "include" -/- "HsBaseConfig.h" %> \_ -> -- ./configure is called here manually because we need to generate -- HsBaseConfig.h, which is created from HsBaseConfig.h.in. ./configure - -- is usually run by Cabal which generates this file but if we do that - -- then hadrian thinks it needs to build the stage0 compiler before - -- attempting to configure. Therefore we just run it directly here. cmd_ (Cwd "libraries/base") "./configure" + "rts" -/- "include" -/- "ghcautoconf.h" %> \_ -> + cmd_ (Cwd "rts") "./configure" + "rts" -/- "include" -/- "ghcplatform.h" %> \_ -> + cmd_ (Cwd "rts") "./configure" lint :: Action () -> Action () lint lintAction = do @@ -64,7 +68,6 @@ base = do let includeDirs = [ "rts/include" , "libraries/base/include" - , stage1RtsInc ] runHLint includeDirs [] "libraries/base" ===================================== hadrian/src/Rules/Register.hs ===================================== @@ -45,6 +45,12 @@ configurePackageRules = do isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend when isGmp $ need [buildP -/- "include/ghc-gmp.h"] + when (pkg == rts) $ do + -- Rts.h is a header listed in the cabal file, and configuring + -- therefore wants to ensure that the header "works" post-configure. + -- But it (transitively) includes this, so we must ensure it exists + -- for that check to work. + need [buildP -/- "include/ghcplatform.h"] Cabal.configurePackage ctx root -/- "**/autogen/cabal_macros.h" %> \out -> do ===================================== libraries/Cabal ===================================== @@ -1 +1 @@ -Subproject commit 6cd29789ca866464dc3af89f62c98c41264ce3cd +Subproject commit 5abfa5032cb6f011c9a7e02d14c9f10dcb2d660d ===================================== libraries/base/.gitignore ===================================== @@ -19,4 +19,3 @@ /include/EventConfig.h /include/HsBaseConfig.h /include/HsBaseConfig.h.in - ===================================== m4/fp_bfd_support.m4 ===================================== @@ -2,7 +2,7 @@ # ---------------------- # whether to use libbfd for debugging RTS AC_DEFUN([FP_BFD_SUPPORT], [ - HaveLibbfd=NO + haveLibbfd=NO AC_ARG_ENABLE(bfd-debug, [AS_HELP_STRING([--enable-bfd-debug], [Enable symbol resolution for -debug rts ('+RTS -Di') via binutils' libbfd [default=no]])], @@ -40,10 +40,9 @@ AC_DEFUN([FP_BFD_SUPPORT], [ bfd_get_symbol_info(abfd,symbol_table[0],&info); } ]])], - HaveLibbfd=YES,dnl bfd seems to work + haveLibbfd=YES dnl bfd seems to work [AC_MSG_ERROR([can't use 'bfd' library])]) LIBS="$save_LIBS" ] ) - AC_SUBST([UseLibbfd],[$HaveLibbfd]) ]) ===================================== m4/fp_cc_supports__atomics.m4 ===================================== @@ -61,12 +61,4 @@ AC_DEFUN([FP_CC_SUPPORTS__ATOMICS], AC_MSG_RESULT(no) AC_MSG_ERROR([C compiler needs to support __atomic primitives.]) ]) - AC_DEFINE([HAVE_C11_ATOMICS], [1], [Does C compiler support __atomic primitives?]) - if test "$need_latomic" = 1; then - AC_SUBST([NeedLibatomic],[YES]) - else - AC_SUBST([NeedLibatomic],[NO]) - fi - AC_DEFINE_UNQUOTED([NEED_ATOMIC_LIB], [$need_latomic], - [Define to 1 if we need -latomic.]) ]) ===================================== m4/fp_check_pthreads.m4 ===================================== @@ -12,18 +12,15 @@ AC_DEFUN([FP_CHECK_PTHREADS], AC_CHECK_FUNC(pthread_create, [ AC_MSG_RESULT(no) - AC_SUBST([UseLibpthread],[NO]) need_lpthread=0 ], [ AC_CHECK_LIB(pthread, pthread_create, [ AC_MSG_RESULT(yes) - AC_SUBST([UseLibpthread],[YES]) need_lpthread=1 ], [ - AC_SUBST([UseLibpthread],[NO]) AC_MSG_RESULT([no pthreads support found.]) need_lpthread=0 ]) ===================================== m4/fp_find_libdw.m4 ===================================== @@ -12,8 +12,6 @@ AC_DEFUN([FP_FIND_LIBDW], LIBDW_LDFLAGS="-L$withval" ]) - AC_SUBST(LibdwLibDir) - AC_ARG_WITH([libdw-includes], [AS_HELP_STRING([--with-libdw-includes=ARG], [Find includes for libdw in ARG [default=system default]]) @@ -23,35 +21,29 @@ AC_DEFUN([FP_FIND_LIBDW], LIBDW_CFLAGS="-I$withval" ]) - AC_SUBST(LibdwIncludeDir) + AC_ARG_ENABLE(dwarf-unwind, + [AS_HELP_STRING([--enable-dwarf-unwind], + [Enable DWARF unwinding support in the runtime system via elfutils' libdw [default=no]])], + [], + [enable_dwarf_unwind=no]) UseLibdw=NO - USE_LIBDW=0 - AC_ARG_ENABLE(dwarf-unwind, - [AS_HELP_STRING([--enable-dwarf-unwind], - [Enable DWARF unwinding support in the runtime system via elfutils' libdw [default=no]])]) - if test "$enable_dwarf_unwind" = "yes" ; then + if test "$enable_dwarf_unwind" != "no" ; then CFLAGS2="$CFLAGS" CFLAGS="$LIBDW_CFLAGS $CFLAGS" LDFLAGS2="$LDFLAGS" LDFLAGS="$LIBDW_LDFLAGS $LDFLAGS" - AC_CHECK_LIB(dw, dwfl_attach_state, - [AC_CHECK_HEADERS([elfutils/libdw.h], [break], []) - UseLibdw=YES], - [AC_MSG_ERROR([Cannot find system libdw (required by --enable-dwarf-unwind)])]) + AC_CHECK_HEADER([elfutils/libdwfl.h], + [AC_CHECK_LIB(dw, dwfl_attach_state, + [UseLibdw=YES])]) + + if test "x:$enable_dwarf_unwind:$UseLibdw" = "x:yes:NO" ; then + AC_MSG_ERROR([Cannot find system libdw (required by --enable-dwarf-unwind)]) + fi CFLAGS="$CFLAGS2" LDFLAGS="$LDFLAGS2" fi - - AC_SUBST(UseLibdw) - if test $UseLibdw = "YES" ; then - USE_LIBDW=1 - AC_SUBST([CabalHaveLibdw],[True]) - else - AC_SUBST([CabalHaveLibdw],[False]) - fi - AC_DEFINE_UNQUOTED([USE_LIBDW], [$USE_LIBDW], [Set to 1 to use libdw]) ]) ===================================== m4/fp_find_libnuma.m4 ===================================== @@ -11,8 +11,6 @@ AC_DEFUN([FP_FIND_LIBNUMA], LIBNUMA_LDFLAGS="-L$withval" ]) - AC_SUBST(LibNumaLibDir) - AC_ARG_WITH([libnuma-includes], [AS_HELP_STRING([--with-libnuma-includes=ARG], [Find includes for libnuma in ARG [default=system default]]) @@ -22,14 +20,14 @@ AC_DEFUN([FP_FIND_LIBNUMA], LIBNUMA_CFLAGS="-I$withval" ]) - AC_SUBST(LibNumaIncludeDir) - - HaveLibNuma=0 AC_ARG_ENABLE(numa, - [AS_HELP_STRING([--enable-numa], - [Enable NUMA memory policy and thread affinity support in the - runtime system via numactl's libnuma [default=auto]])]) + [AS_HELP_STRING([--enable-numa], + [Enable NUMA memory policy and thread affinity support in the + runtime system via numactl's libnuma [default=auto]])], + [], + [enable_numa=auto]) + UseLibNuma=NO if test "$enable_numa" != "no" ; then CFLAGS2="$CFLAGS" CFLAGS="$LIBNUMA_CFLAGS $CFLAGS" @@ -38,23 +36,14 @@ AC_DEFUN([FP_FIND_LIBNUMA], AC_CHECK_HEADERS([numa.h numaif.h]) - if test "$ac_cv_header_numa_h$ac_cv_header_numaif_h" = "yesyes" ; then - AC_CHECK_LIB(numa, numa_available,HaveLibNuma=1) + if test "x:$ac_cv_header_numa_h:$ac_cv_header_numaif_h" = "x:yes:yes" ; then + AC_CHECK_LIB([numa], [numa_available], [UseLibNuma=YES]) fi - if test "$enable_numa:$HaveLibNuma" = "yes:0" ; then - AC_MSG_ERROR([Cannot find system libnuma (required by --enable-numa)]) + if test "x:$enable_numa:$UseLibNuma" = "x:yes:NO" ; then + AC_MSG_ERROR([Cannot find system libnuma (required by --enable-numa)]) fi CFLAGS="$CFLAGS2" LDFLAGS="$LDFLAGS2" fi - - AC_DEFINE_UNQUOTED([HAVE_LIBNUMA], [$HaveLibNuma], [Define to 1 if you have libnuma]) - if test $HaveLibNuma = "1" ; then - AC_SUBST([UseLibNuma],[YES]) - AC_SUBST([CabalHaveLibNuma],[True]) - else - AC_SUBST([UseLibNuma],[NO]) - AC_SUBST([CabalHaveLibNuma],[False]) - fi ]) ===================================== m4/fptools_set_haskell_platform_vars.m4 ===================================== @@ -162,8 +162,6 @@ AC_DEFUN([GHC_SUBSECTIONS_VIA_SYMBOLS], TargetHasSubsectionsViaSymbols=NO else TargetHasSubsectionsViaSymbols=YES - AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1], - [Define to 1 if Apple-style dead-stripping is supported.]) fi ], [TargetHasSubsectionsViaSymbols=NO ===================================== rts/.gitignore ===================================== @@ -12,7 +12,13 @@ /package.conf.install.raw /fs.* +/aclocal.m4 /autom4te.cache/ /config.log /config.status /configure + +/external-symbols.list +/ghcautoconf.h.autoconf.in +/ghcautoconf.h.autoconf +/include/ghcautoconf.h ===================================== rts/configure.ac ===================================== @@ -0,0 +1,430 @@ +# Configure script template for the Run-time System of GHC +# +# Process with 'autoreconf' to get a working configure script. +# +# For the generated configure script, do "./configure --help" to +# see what flags are available. (Better yet, read the documentation!) +# + +AC_INIT([GHC run-time system], [1.0.2], [libraries at haskell.org], [rts]) + +AC_CONFIG_MACRO_DIRS([../m4]) + +# Safety check: Ensure that we are in the correct source directory. +AC_CONFIG_SRCDIR([include/rts/Constants.h]) + +dnl * We require autoconf version 2.69 due to +dnl https://bugs.ruby-lang.org/issues/8179. Also see #14910. +dnl * We need 2.50 due to the use of AC_SYS_LARGEFILE and AC_MSG_NOTICE. +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.69]) + +AC_CONFIG_FILES([ghcplatform.h.top]) + +AC_CONFIG_HEADERS([ghcautoconf.h.autoconf]) + +AC_ARG_ENABLE(asserts-all-ways, +[AS_HELP_STRING([--enable-asserts-all-ways], + [Usually ASSERTs are only compiled in the DEBUG way, + this will enable them in all ways.])], + [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableAssertsAllWays])], + [EnableAssertsAllWays=NO] +) +if test "$enable_asserts_all_ways" = "yes" ; then + AC_DEFINE([USE_ASSERTS_ALL_WAYS], [1], [Compile-in ASSERTs in all ways.]) +fi + +AC_ARG_ENABLE(native-io-manager, +[AS_HELP_STRING([--enable-native-io-manager], + [Enable the native I/O manager by default.])], + [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableNativeIOManager])], + [EnableNativeIOManager=NO] +) +if test "$EnableNativeIOManager" = "YES"; then + AC_DEFINE_UNQUOTED([DEFAULT_NATIVE_IO_MANAGER], [1], [Enable Native I/O manager as default.]) +fi + +# We have to run these unconditionally, but we may discard their +# results in the following code +AC_CANONICAL_BUILD +AC_CANONICAL_HOST + +dnl ** Do an unregisterised build? +dnl -------------------------------------------------------------- + +GHC_UNREGISTERISED + +dnl ** Do a build with tables next to code? +dnl -------------------------------------------------------------- + +GHC_TABLES_NEXT_TO_CODE +if test x"$TablesNextToCode" = xYES; then + AC_DEFINE([TABLES_NEXT_TO_CODE], [1], [Define to 1 if info tables are laid out next to code]) +fi + +dnl detect compiler (prefer gcc over clang) and set $CC (unless CC already set), +dnl later CC is copied to CC_STAGE{1,2,3} +AC_PROG_CC([cc gcc clang]) + +dnl make extensions visible to allow feature-tests to detect them lateron +AC_USE_SYSTEM_EXTENSIONS + +dnl ** Used to determine how to compile ghc-prim's atomics.c, used by +dnl unregisterised, Sparc, and PPC backends. Also determines whether +dnl linking to libatomic is required for atomic operations, e.g. on +dnl RISCV64 GCC. +FP_CC_SUPPORTS__ATOMICS +AC_DEFINE([HAVE_C11_ATOMICS], [1], [Does C compiler support __atomic primitives?]) +AC_DEFINE_UNQUOTED([NEED_ATOMIC_LIB], [$need_latomic], + [Define to 1 if we need -latomic for sub-word atomic operations.]) + +dnl ** look to see if we have a C compiler using an llvm back end. +dnl +FP_CC_LLVM_BACKEND +AS_IF([test x"$CcLlvmBackend" = x"YES"], + [AC_DEFINE([CC_LLVM_BACKEND], [1], [Define (to 1) if C compiler has an LLVM back end])]) + +GHC_CONVERT_PLATFORM_PARTS([build], [Build]) +FPTOOLS_SET_PLATFORM_VARS([build],[Build]) +FPTOOLS_SET_HASKELL_PLATFORM_VARS([Build]) + +GHC_CONVERT_PLATFORM_PARTS([host], [Host]) +FPTOOLS_SET_PLATFORM_VARS([host], [Host]) +FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host]) + +GHC_SUBSECTIONS_VIA_SYMBOLS +AS_IF([test x"${TargetHasSubsectionsViaSymbols}" = x"YES"], + [AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1], + [Define to 1 if Apple-style dead-stripping is supported.])]) + +dnl -------------------------------------------------- +dnl * Platform header file and syscall feature tests +dnl ### checking the state of the local header files and syscalls ### + +dnl ** Enable large file support. NB. do this before testing the type of +dnl off_t, because it will affect the result of that test. +AC_SYS_LARGEFILE + +dnl ** check for specific header (.h) files that we are interested in +AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timerfd.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h utime.h windows.h winsock.h sched.h]) + +dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708 +AC_CHECK_HEADERS([sys/cpuset.h], [], [], +[[#if HAVE_SYS_PARAM_H +# include +#endif +]]) + +dnl ** check whether a declaration for `environ` is provided by libc. +FP_CHECK_ENVIRON + +dnl ** do we have long longs? +AC_CHECK_TYPES([long long]) + +dnl ** what are the sizes of various types +FP_CHECK_SIZEOF_AND_ALIGNMENT(char) +FP_CHECK_SIZEOF_AND_ALIGNMENT(double) +FP_CHECK_SIZEOF_AND_ALIGNMENT(float) +FP_CHECK_SIZEOF_AND_ALIGNMENT(int) +FP_CHECK_SIZEOF_AND_ALIGNMENT(long) +if test "$ac_cv_type_long_long" = yes; then +FP_CHECK_SIZEOF_AND_ALIGNMENT(long long) +fi +FP_CHECK_SIZEOF_AND_ALIGNMENT(short) +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned char) +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned int) +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long) +if test "$ac_cv_type_long_long" = yes; then +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long long) +fi +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned short) +FP_CHECK_SIZEOF_AND_ALIGNMENT(void *) + +FP_CHECK_SIZEOF_AND_ALIGNMENT(int8_t) +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint8_t) +FP_CHECK_SIZEOF_AND_ALIGNMENT(int16_t) +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint16_t) +FP_CHECK_SIZEOF_AND_ALIGNMENT(int32_t) +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint32_t) +FP_CHECK_SIZEOF_AND_ALIGNMENT(int64_t) +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint64_t) + + +FP_CHECK_FUNC([WinExec], + [@%:@include ], [WinExec("",0)]) + +FP_CHECK_FUNC([GetModuleFileName], + [@%:@include ], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)]) + +dnl ** check for more functions +dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too. +AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity sched_getaffinity setlocale uselocale]) + +dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if +dnl ** _POSIX_C_SOURCE is defined +AC_CHECK_DECLS([ctime_r], , , +[#define _POSIX_SOURCE 1 +#define _POSIX_C_SOURCE 199506L +#include ]) + +dnl On Linux we should have program_invocation_short_name +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([HaveLibMingwEx],[NO])]) + +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 +dnl for math functions or not +dnl (see https://gitlab.haskell.org/ghc/ghc/issues/3730) +AC_CHECK_LIB(m, atan, + [AC_DEFINE([HAVE_LIBM], [1], [Define to 1 if you need to link with libm])]) + +FP_BFD_SUPPORT + +dnl ################################################################ +dnl Check for libraries +dnl ################################################################ + +FP_FIND_LIBFFI + +dnl ** check whether we need -ldl to get dlopen() +AC_CHECK_LIB([dl], [dlopen]) +dnl ** check whether we have dlinfo +AC_CHECK_FUNCS([dlinfo]) + +dnl -------------------------------------------------- +dnl * Miscellaneous feature tests +dnl -------------------------------------------------- + +dnl ** can we get alloca? +AC_FUNC_ALLOCA + +dnl ** working vfork? +AC_FUNC_FORK + +dnl ** determine whether or not const works +AC_C_CONST + +dnl ** are we big endian? +AC_C_BIGENDIAN +FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN + +dnl ** check for leading underscores in symbol names +FP_LEADING_UNDERSCORE +if test x"$fptools_cv_leading_underscore" = xyes; then + AC_DEFINE([LEADING_UNDERSCORE], [1], [Define to 1 if C symbols have a leading underscore added by the compiler.]) +fi + +FP_VISIBILITY_HIDDEN + +FP_MUSTTAIL + +dnl ** check for librt +AC_CHECK_LIB([rt], [clock_gettime]) +AC_CHECK_FUNCS(clock_gettime timer_settime) +FP_CHECK_TIMER_CREATE + +dnl ** check for Apple's "interesting" long double compatibility scheme +AC_MSG_CHECKING(for printf\$LDBLStub) +AC_LINK_IFELSE([AC_LANG_CALL([], [printf\$LDBLStub])], + [ + AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[1], + [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).]) + ], + [ + AC_MSG_RESULT(no) + AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[0], + [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).]) + ]) + +FP_CHECK_PTHREADS + +dnl ** check for eventfd which is needed by the I/O manager +AC_CHECK_HEADERS([sys/eventfd.h]) +AC_CHECK_FUNCS([eventfd]) + +AC_CHECK_FUNCS([getpid getuid raise]) + +dnl ** Check for __thread support in the compiler +AC_MSG_CHECKING(for __thread support) +AC_COMPILE_IFELSE( + [ AC_LANG_SOURCE([[__thread int tester = 0;]]) ], + [ + AC_MSG_RESULT(yes) + AC_DEFINE([CC_SUPPORTS_TLS],[1],[Define to 1 if __thread is supported]) + ], + [ + AC_MSG_RESULT(no) + AC_DEFINE([CC_SUPPORTS_TLS],[0],[Define to 1 if __thread is supported]) + ]) + +dnl large address space support (see rts/include/rts/storage/MBlock.h) +dnl +dnl Darwin has vm_allocate/vm_protect +dnl Linux has mmap(MAP_NORESERVE)/madv(MADV_DONTNEED) +dnl FreeBSD, Solaris and maybe other have MAP_NORESERVE/MADV_FREE +dnl (They also have MADV_DONTNEED, but it means something else!) +dnl +dnl Windows has VirtualAlloc MEM_RESERVE/MEM_COMMIT, however +dnl it counts page-table space as committed memory, and so quickly +dnl runs out of paging file when we have multiple processes reserving +dnl 1TB of address space, we get the following error: +dnl VirtualAlloc MEM_RESERVE 1099512676352 bytes failed: The paging file is too small for this operation to complete. +dnl + +AC_ARG_ENABLE(large-address-space, + [AS_HELP_STRING([--enable-large-address-space], + [Use a single large address space on 64 bit systems (enabled by default on 64 bit platforms)])], + EnableLargeAddressSpace=$enableval, + EnableLargeAddressSpace=yes +) + +use_large_address_space=no +if test "$ac_cv_sizeof_void_p" -eq 8 ; then + if test "x$EnableLargeAddressSpace" = "xyes" ; then + if test "$ghc_host_os" = "darwin" ; then + use_large_address_space=yes + elif test "$ghc_host_os" = "openbsd" ; then + # as of OpenBSD 5.8 (2015), OpenBSD does not support mmap with MAP_NORESERVE. + # The flag MAP_NORESERVE is supported for source compatibility reasons, + # but is completely ignored by OS mmap + use_large_address_space=no + elif test "$ghc_host_os" = "mingw32" ; then + # as of Windows 8.1/Server 2012 windows does no longer allocate the page + # tabe for reserved memory eagerly. So we are now free to use LAS there too. + use_large_address_space=yes + else + AC_CHECK_DECLS([MAP_NORESERVE, MADV_FREE, MADV_DONTNEED],[],[], + [ + #include + #include + #include + #include + ]) + if test "$ac_cv_have_decl_MAP_NORESERVE" = "yes" && + test "$ac_cv_have_decl_MADV_FREE" = "yes" || + test "$ac_cv_have_decl_MADV_DONTNEED" = "yes" ; then + use_large_address_space=yes + fi + fi + fi +fi +if test "$use_large_address_space" = "yes" ; then + AC_DEFINE([USE_LARGE_ADDRESS_SPACE], [1], [Enable single heap address space support]) +fi + +dnl ** Use MMAP in the runtime linker? +dnl -------------------------------------------------------------- + +case ${HostOS} in + linux|linux-android|freebsd|dragonfly|netbsd|openbsd|kfreebsdgnu|gnu|solaris2) + RtsLinkerUseMmap=1 + ;; + darwin|ios|watchos|tvos) + RtsLinkerUseMmap=1 + ;; + *) + # Windows (which doesn't have mmap) and everything else. + RtsLinkerUseMmap=0 + ;; + esac + +AC_DEFINE_UNQUOTED([RTS_LINKER_USE_MMAP], [$RtsLinkerUseMmap], + [Use mmap in the runtime linker]) + +GHC_ADJUSTORS_METHOD([Host]) +AC_SUBST([UseLibffiForAdjustors]) + +dnl ** Other RTS features +dnl -------------------------------------------------------------- +AC_DEFINE_UNQUOTED([USE_LIBDW], [$CABAL_FLAG_libdw], [Set to 1 to use libdw]) + +AC_DEFINE_UNQUOTED([HAVE_LIBNUMA], [$CABAL_FLAG_libnuma], [Define to 1 if you have libnuma]) + +dnl ** Write config files +dnl -------------------------------------------------------------- + +AC_OUTPUT + +dnl ###################################################################### +dnl Generate ghcplatform.h +dnl ###################################################################### + +[ +mkdir -p include + +touch include/ghcplatform.h +> include/ghcplatform.h + +cat ghcplatform.h.top >> include/ghcplatform.h +] +AS_IF([test x"${Unregisterised}" = x"YES"], + [echo "#define UnregisterisedCompiler 1" >> include/ghcplatform.h]) +[ +cat $srcdir/ghcplatform.h.bottom >> include/ghcplatform.h +] + +dnl ###################################################################### +dnl Generate ghcautoconf.h +dnl ###################################################################### + +[ +touch include/ghcautoconf.h +> include/ghcautoconf.h + +echo "#if !defined(__GHCAUTOCONF_H__)" >> include/ghcautoconf.h +echo "#define __GHCAUTOCONF_H__" >> include/ghcautoconf.h +# Copy the contents of $srcdir/../mk/config.h, turning '#define PACKAGE_FOO +# "blah"' into '/* #undef PACKAGE_FOO */' to avoid clashes. +cat $srcdir/../mk/config.h ghcautoconf.h.autoconf | sed \ + -e 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$,\1/* #undef \2 */,' \ + -e '/__GLASGOW_HASKELL/d' \ + -e '/REMOVE ME/d' \ + >> include/ghcautoconf.h +echo "#endif /* __GHCAUTOCONF_H__ */" >> include/ghcautoconf.h +] + +dnl ###################################################################### +dnl Generate external symbol flags (-Wl,-u...) +dnl ###################################################################### + +cat $srcdir/external-symbols.list.in \ + | "$CC" -E -P -traditional -Iinclude - -o - \ + | sed '/^$/d' \ + > external-symbols.list \ + || exit 1 + +mv external-symbols.list external-symbols.tmp +if [[ -n "$LeadingUnderscore" ]]; then + sed 's/^/ -Wl,-u_/' external-symbols.tmp > external-symbols.list +else + sed 's/^/ -Wl,-u/' external-symbols.tmp > external-symbols.list +fi +rm -f external-symbols.tmp + +dnl ###################################################################### +dnl Generate build-info +dnl ###################################################################### + +cat $srcdir/rts.buildinfo.in | \ + sed -e 's/^ *//' | \ + "$CC" -E -P -traditional - -o - \ + > rts.buildinfo +echo "" >> rts.buildinfo +rm -f external-symbols.list ===================================== rts/external-symbols.list.in ===================================== @@ -0,0 +1,103 @@ +#include "ghcautoconf.h" + +#if SIZEOF_VOID_P == 8 +hs_atomic_add64 +hs_atomic_sub64 +hs_atomic_and64 +hs_atomic_nand64 +hs_atomic_or64 +hs_atomic_xor64 +hs_atomicread64 +hs_atomicwrite64 +#endif + +#if mingw32_HOST_OS +base_GHCziEventziWindows_processRemoteCompletion_closure +#endif + +#if darwin_HOST_OS +#if 0 +See Note [fd_set_overflow] +#endif +__darwin_check_fd_set_overflow +#endif + +#if FIND_PTR +findPtr +#endif + +base_GHCziTopHandler_runIO_closure +base_GHCziTopHandler_runNonIO_closure +ghczmprim_GHCziTupleziPrim_Z0T_closure +ghczmprim_GHCziTypes_True_closure +ghczmprim_GHCziTypes_False_closure +base_GHCziPack_unpackCString_closure +base_GHCziWeakziFinalizze_runFinalizzerBatch_closure +base_GHCziIOziException_stackOverflow_closure +base_GHCziIOziException_heapOverflow_closure +base_GHCziIOziException_allocationLimitExceeded_closure +base_GHCziIOziException_blockedIndefinitelyOnMVar_closure +base_GHCziIOziException_blockedIndefinitelyOnSTM_closure +base_GHCziIOziException_cannotCompactFunction_closure +base_GHCziIOziException_cannotCompactPinned_closure +base_GHCziIOziException_cannotCompactMutable_closure +base_GHCziIOPort_doubleReadException_closure +base_ControlziExceptionziBase_nonTermination_closure +base_ControlziExceptionziBase_nestedAtomically_closure +base_GHCziEventziThread_blockedOnBadFD_closure +base_GHCziConcziSync_runSparks_closure +base_GHCziConcziIO_ensureIOManagerIsRunning_closure +base_GHCziConcziIO_interruptIOManager_closure +base_GHCziConcziIO_ioManagerCapabilitiesChanged_closure +base_GHCziConcziSignal_runHandlersPtr_closure +base_GHCziTopHandler_flushStdHandles_closure +base_GHCziTopHandler_runMainIO_closure +ghczmprim_GHCziTypes_Czh_con_info +ghczmprim_GHCziTypes_Izh_con_info +ghczmprim_GHCziTypes_Fzh_con_info +ghczmprim_GHCziTypes_Dzh_con_info +ghczmprim_GHCziTypes_Wzh_con_info +base_GHCziPtr_Ptr_con_info +base_GHCziPtr_FunPtr_con_info +base_GHCziInt_I8zh_con_info +base_GHCziInt_I16zh_con_info +base_GHCziInt_I32zh_con_info +base_GHCziInt_I64zh_con_info +base_GHCziWord_W8zh_con_info +base_GHCziWord_W16zh_con_info +base_GHCziWord_W32zh_con_info +base_GHCziWord_W64zh_con_info +base_GHCziStable_StablePtr_con_info +hs_atomic_add8 +hs_atomic_add16 +hs_atomic_add32 +hs_atomic_sub8 +hs_atomic_sub16 +hs_atomic_sub32 +hs_atomic_and8 +hs_atomic_and16 +hs_atomic_and32 +hs_atomic_nand8 +hs_atomic_nand16 +hs_atomic_nand32 +hs_atomic_or8 +hs_atomic_or16 +hs_atomic_or32 +hs_atomic_xor8 +hs_atomic_xor16 +hs_atomic_xor32 +hs_cmpxchg8 +hs_cmpxchg16 +hs_cmpxchg32 +hs_cmpxchg64 +hs_xchg8 +hs_xchg16 +hs_xchg32 +hs_xchg64 +hs_atomicread8 +hs_atomicread16 +hs_atomicread32 +hs_atomicwrite8 +hs_atomicwrite16 +hs_atomicwrite32 +base_GHCziStackziCloneStack_StackSnapshot_closure ===================================== rts/ghcplatform.h.bottom ===================================== @@ -0,0 +1,2 @@ + +#endif /* __GHCPLATFORM_H__ */ ===================================== rts/ghcplatform.h.top.in ===================================== @@ -0,0 +1,23 @@ +#if !defined(__GHCPLATFORM_H__) +#define __GHCPLATFORM_H__ + +#define BuildPlatform_TYPE @BuildPlatform_CPP@ +#define HostPlatform_TYPE @HostPlatform_CPP@ + +#define @BuildPlatform_CPP at _BUILD 1 +#define @HostPlatform_CPP at _HOST 1 + +#define @BuildArch_CPP at _BUILD_ARCH 1 +#define @HostArch_CPP at _HOST_ARCH 1 +#define BUILD_ARCH "@BuildArch_CPP@" +#define HOST_ARCH "@HostArch_CPP@" + +#define @BuildOS_CPP at _BUILD_OS 1 +#define @HostOS_CPP at _HOST_OS 1 +#define BUILD_OS "@BuildOS_CPP@" +#define HOST_OS "@HostOS_CPP@" + +#define @BuildVendor_CPP at _BUILD_VENDOR 1 +#define @HostVendor_CPP at _HOST_VENDOR 1 +#define BUILD_VENDOR "@BuildVendor_CPP@" +#define HOST_VENDOR "@HostVendor_CPP@" ===================================== rts/posix/OSMem.c ===================================== @@ -30,10 +30,8 @@ #if defined(HAVE_FCNTL_H) #include #endif -#if defined(HAVE_NUMA_H) +#if HAVE_LIBNUMA #include -#endif -#if defined(HAVE_NUMAIF_H) #include #endif #if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_SYS_TIME_H) ===================================== rts/rts.buildinfo.in ===================================== @@ -0,0 +1,3 @@ +-- External symbols referenced by the RTS +ld-options: +#include "external-symbols.list" ===================================== rts/rts.cabal.in ===================================== @@ -1,9 +1,27 @@ cabal-version: 3.0 name: rts version: 1.0.2 +synopsis: The GHC runtime system +description: + The GHC runtime system. + + Code produced by GHC links this library to provide missing functionality + that cannot be written in Haskell itself. license: BSD-3-Clause maintainer: glasgow-haskell-users at haskell.org -build-type: Simple +build-type: Configure + +extra-source-files: + configure + configure.ac + external-symbols.list.in + rts.buildinfo.in + +extra-tmp-files: + autom4te.cache + rts.buildinfo + config.log + config.status source-repository head type: git @@ -206,6 +224,7 @@ library include-dirs: include includes: Rts.h + autogen-includes: ghcautoconf.h ghcplatform.h install-includes: Cmm.h HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h -- ^ from include @@ -275,200 +294,6 @@ library stg/SMP.h stg/Ticky.h stg/Types.h - if flag(64bit) - if flag(leading-underscore) - ld-options: - "-Wl,-u,_hs_atomic_add64" - "-Wl,-u,_hs_atomic_sub64" - "-Wl,-u,_hs_atomic_and64" - "-Wl,-u,_hs_atomic_nand64" - "-Wl,-u,_hs_atomic_or64" - "-Wl,-u,_hs_atomic_xor64" - "-Wl,-u,_hs_atomicread64" - "-Wl,-u,_hs_atomicwrite64" - else - ld-options: - "-Wl,-u,hs_atomic_add64" - "-Wl,-u,hs_atomic_sub64" - "-Wl,-u,hs_atomic_and64" - "-Wl,-u,hs_atomic_nand64" - "-Wl,-u,hs_atomic_or64" - "-Wl,-u,hs_atomic_xor64" - "-Wl,-u,hs_atomicread64" - "-Wl,-u,hs_atomicwrite64" - if flag(leading-underscore) - ld-options: - "-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_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" - "-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" - "-Wl,-u,_hs_atomic_sub8" - "-Wl,-u,_hs_atomic_sub16" - "-Wl,-u,_hs_atomic_sub32" - "-Wl,-u,_hs_atomic_and8" - "-Wl,-u,_hs_atomic_and16" - "-Wl,-u,_hs_atomic_and32" - "-Wl,-u,_hs_atomic_nand8" - "-Wl,-u,_hs_atomic_nand16" - "-Wl,-u,_hs_atomic_nand32" - "-Wl,-u,_hs_atomic_or8" - "-Wl,-u,_hs_atomic_or16" - "-Wl,-u,_hs_atomic_or32" - "-Wl,-u,_hs_atomic_xor8" - "-Wl,-u,_hs_atomic_xor16" - "-Wl,-u,_hs_atomic_xor32" - "-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" - "-Wl,-u,_hs_atomicwrite8" - "-Wl,-u,_hs_atomicwrite16" - "-Wl,-u,_hs_atomicwrite32" - "-Wl,-u,_base_GHCziStackziCloneStack_StackSnapshot_closure" - - if flag(find-ptr) - -- This symbol is useful in gdb, but not referred to anywhere, - -- so we need to force it to be included in the binary. - ld-options: "-Wl,-u,_findPtr" - - else - ld-options: - "-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_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" - "-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" - "-Wl,-u,hs_atomic_sub8" - "-Wl,-u,hs_atomic_sub16" - "-Wl,-u,hs_atomic_sub32" - "-Wl,-u,hs_atomic_and8" - "-Wl,-u,hs_atomic_and16" - "-Wl,-u,hs_atomic_and32" - "-Wl,-u,hs_atomic_nand8" - "-Wl,-u,hs_atomic_nand16" - "-Wl,-u,hs_atomic_nand32" - "-Wl,-u,hs_atomic_or8" - "-Wl,-u,hs_atomic_or16" - "-Wl,-u,hs_atomic_or32" - "-Wl,-u,hs_atomic_xor8" - "-Wl,-u,hs_atomic_xor16" - "-Wl,-u,hs_atomic_xor32" - "-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" - "-Wl,-u,hs_atomicwrite8" - "-Wl,-u,hs_atomicwrite16" - "-Wl,-u,hs_atomicwrite32" - "-Wl,-u,base_GHCziStackziCloneStack_StackSnapshot_closure" - - if flag(find-ptr) - -- This symbol is useful in gdb, but not referred to anywhere, - -- so we need to force it to be included in the binary. - ld-options: "-Wl,-u,findPtr" - - if os(windows) - if flag(leading-underscore) - ld-options: - "-Wl,-u,_base_GHCziEventziWindows_processRemoteCompletion_closure" - else - ld-options: - "-Wl,-u,base_GHCziEventziWindows_processRemoteCompletion_closure" if os(osx) ld-options: "-Wl,-search_paths_first" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/94a51526cc898d8d510e254f373db835d8cafc94...e5be71a2f99891e63afb203ed1f14303c3815ea5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/94a51526cc898d8d510e254f373db835d8cafc94...e5be71a2f99891e63afb203ed1f14303c3815ea5 You're receiving 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 Jan 2 17:24:36 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 02 Jan 2023 12:24:36 -0500 Subject: [Git][ghc/ghc][wip/andreask/spec-pragma] 2 commits: Allow combination of NOINLINE/INLINEABLE. Message-ID: <63b313546a27c_2a26f52aa67bb82141099@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/spec-pragma at Glasgow Haskell Compiler / GHC Commits: b10a67a7 by Andreas Klebinger at 2023-01-01T20:27:46+01:00 Allow combination of NOINLINE/INLINEABLE. We do this by also tracking INLINEABLE outside of the Unfolding data type as it's own flag. In the proccess of this I made a few other smaller changes. * Allow NOINLINE bindings to specialise with -fspecialise-aggressively. Fixes #21036 * Made rule source a proper type instead of Bool. ------------------------- Metric Decrease: T14766 T18304 Metric Increase: T10359 T13386 T15263 ------------------------- - - - - - 2d467d96 by Andreas Klebinger at 2023-01-02T18:23:11+01:00 Fix test outputs - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Id.hs - compiler/GHC/Types/Id/Info.hs - compiler/GHC/Utils/Outputable.hs - docs/users_guide/exts/pragmas.rst The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/18f2c302045fa26af9bb9d6be94dd56904a0f8f1...2d467d96c0f8e02dd0543aadbb5b58e1d92ffa81 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/18f2c302045fa26af9bb9d6be94dd56904a0f8f1...2d467d96c0f8e02dd0543aadbb5b58e1d92ffa81 You're receiving 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 Jan 2 18:47:45 2023 From: gitlab at gitlab.haskell.org (Richard Eisenberg (@rae)) Date: Mon, 02 Jan 2023 13:47:45 -0500 Subject: [Git][ghc/ghc][wip/t22519] Unwrap newtypes in two places Message-ID: <63b326d13c9fc_2a26f5fdf373a42149188@gitlab.mail> Richard Eisenberg pushed to branch wip/t22519 at Glasgow Haskell Compiler / GHC Commits: 7fdcf917 by Richard Eisenberg at 2023-01-02T13:47:33-05:00 Unwrap newtypes in two places - - - - - 2 changed files: - compiler/GHC/Tc/Solver/Canonical.hs - testsuite/tests/typecheck/should_fail/T15801.stderr Changes: ===================================== compiler/GHC/Tc/Solver/Canonical.hs ===================================== @@ -34,6 +34,7 @@ import GHC.Core.Reduction import GHC.Core import GHC.Types.Id( mkTemplateLocals ) import GHC.Core.FamInstEnv ( FamInstEnvs ) +import GHC.Tc.Instance.Family ( tcTopNormaliseNewTypeTF_maybe ) import GHC.Types.Var import GHC.Types.Var.Env( mkInScopeSet ) import GHC.Types.Var.Set( delVarSetList, anyVarSet ) @@ -1007,6 +1008,18 @@ can_eq_nc' True _rdr_env _envs ev ReprEq ty1 _ ty2 _ | ty1 `tcEqType` ty2 = canEqReflexive ev ReprEq ty1 +-- When working with ReprEq, unwrap newtypes. +-- See Note [Unwrap newtypes first] +-- This must be above the TyVarTy case, in order to guarantee (TyEq:N) +can_eq_nc' _rewritten rdr_env envs ev eq_rel ty1 ps_ty1 ty2 ps_ty2 + | ReprEq <- eq_rel + , Just stuff1 <- tcTopNormaliseNewTypeTF_maybe envs rdr_env ty1 + = can_eq_newtype_nc ev NotSwapped ty1 stuff1 ty2 ps_ty2 + + | ReprEq <- eq_rel + , Just stuff2 <- tcTopNormaliseNewTypeTF_maybe envs rdr_env ty2 + = can_eq_newtype_nc ev IsSwapped ty2 stuff2 ty1 ps_ty1 + -- Then, get rid of casts can_eq_nc' rewritten _rdr_env _envs ev eq_rel (CastTy ty1 co1) _ ty2 ps_ty2 | isNothing (canEqLHS_maybe ty2) -- See (3) in Note [Equalities with incompatible kinds] @@ -1036,17 +1049,14 @@ can_eq_nc' _rewritten _rdr_env _envs ev eq_rel -- Decompose type constructor applications -- NB: we have expanded type synonyms already can_eq_nc' rewritten _rdr_env _envs ev eq_rel ty1 _ ty2 _ - | (eq_rel == NomEq || rewritten) - -- NomEq: See Note [Unwrap newtypes first] - -- unwrapping is done in the rewriter, hence the check for `rewritten` - , Just (tc1, tys1) <- tcSplitTyConApp_maybe ty1 + | Just (tc1, tys1) <- tcSplitTyConApp_maybe ty1 , Just (tc2, tys2) <- tcSplitTyConApp_maybe ty2 -- we want to catch e.g. Maybe Int ~ (Int -> Int) here for better -- error messages rather than decomposing into AppTys; -- hence no direct match on TyConApp , not (isTypeFamilyTyCon tc1) , not (isTypeFamilyTyCon tc2) - = canTyConApp ev eq_rel tc1 tys1 tc2 tys2 + = canTyConApp rewritten ev eq_rel tc1 tys1 tc2 tys2 can_eq_nc' _rewritten _rdr_env _envs ev eq_rel s1@(ForAllTy (Bndr _ vis1) _) _ @@ -1068,11 +1078,8 @@ can_eq_nc' True _rdr_env _envs ev NomEq ty1 _ ty2 _ ------------------- -- No similarity in type structure detected. Rewrite and try again. -can_eq_nc' False rdr_env envs ev eq_rel _ ps_ty1 _ ps_ty2 - = do { (redn1@(Reduction _ xi1), rewriters1) <- rewrite ev ps_ty1 - ; (redn2@(Reduction _ xi2), rewriters2) <- rewrite ev ps_ty2 - ; new_ev <- rewriteEqEvidence (rewriters1 S.<> rewriters2) ev NotSwapped redn1 redn2 - ; can_eq_nc' True rdr_env envs new_ev eq_rel xi1 xi1 xi2 xi2 } +can_eq_nc' False _rdr_env _envs ev eq_rel _ ps_ty1 _ ps_ty2 + = rewrite_and_try_again ev eq_rel ps_ty1 ps_ty2 ---------------------------- -- Look for a canonical LHS. See Note [Canonical LHS]. @@ -1110,6 +1117,16 @@ can_eq_nc' True _rdr_env _envs ev eq_rel _ ps_ty1 _ ps_ty2 -- No need to call canEqFailure/canEqHardFailure because they -- rewrite, and the types involved here are already rewritten +-- Rewrite the two types and try again +rewrite_and_try_again :: CtEvidence -> EqRel -> TcType -> TcType -> TcS (StopOrContinue Ct) +rewrite_and_try_again ev eq_rel ty1 ty2 + = do { (redn1@(Reduction _ xi1), rewriters1) <- rewrite ev ty1 + ; (redn2@(Reduction _ xi2), rewriters2) <- rewrite ev ty2 + ; new_ev <- rewriteEqEvidence (rewriters1 S.<> rewriters2) ev NotSwapped redn1 redn2 + ; rdr_env <- getGlobalRdrEnvTcS + ; envs <- getFamInstEnvs + ; can_eq_nc' True rdr_env envs new_ev eq_rel xi1 xi1 xi2 xi2 } + {- Note [Unsolved equalities] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If we have an unsolved equality like @@ -1384,6 +1401,34 @@ we do a reflexivity check. E.] am worried that it would slow down the common case.) -} +------------------------ +-- | We're able to unwrap a newtype. Update the bits accordingly. +can_eq_newtype_nc :: CtEvidence -- ^ :: ty1 ~ ty2 + -> SwapFlag + -> TcType -- ^ ty1 + -> ((Bag GlobalRdrElt, TcCoercion), TcType) -- ^ :: ty1 ~ ty1' + -> TcType -- ^ ty2 + -> TcType -- ^ ty2, with type synonyms + -> TcS (StopOrContinue Ct) +can_eq_newtype_nc ev swapped ty1 ((gres, co1), ty1') ty2 ps_ty2 + = do { traceTcS "can_eq_newtype_nc" $ + vcat [ ppr ev, ppr swapped, ppr co1, ppr gres, ppr ty1', ppr ty2 ] + + -- check for blowing our stack: + -- See Note [Newtypes can blow the stack] + ; checkReductionDepth (ctEvLoc ev) ty1 + + -- Next, we record uses of newtype constructors, since coercing + -- through newtypes is tantamount to using their constructors. + ; recordUsedGREs gres + + ; let redn1 = mkReduction co1 ty1' + + ; new_ev <- rewriteEqEvidence emptyRewriterSet ev swapped + redn1 + (mkReflRedn Representational ps_ty2) + ; can_eq_nc False new_ev ReprEq ty1' ty1' ty2 ps_ty2 } + --------- -- ^ Decompose a type application. -- All input types must be rewritten. See Note [Canonicalising type applications] @@ -1458,7 +1503,8 @@ canEqCast rewritten ev eq_rel swapped ty1 co1 ty2 ps_ty2 role = eqRelRole eq_rel ------------------------ -canTyConApp :: CtEvidence -> EqRel +canTyConApp :: Bool -- True <=> the types have been rewritten + -> CtEvidence -> EqRel -> TyCon -> [TcType] -> TyCon -> [TcType] -> TcS (StopOrContinue Ct) @@ -1466,13 +1512,15 @@ canTyConApp :: CtEvidence -> EqRel -- See Note [Decomposing Dependent TyCons and Processing Wanted Equalities] -- Neither tc1 nor tc2 is a saturated funTyCon, nor a type family -- But they can be data families. -canTyConApp ev eq_rel tc1 tys1 tc2 tys2 +canTyConApp rewritten ev eq_rel tc1 tys1 tc2 tys2 | tc1 == tc2 , tys1 `equalLength` tys2 = do { inerts <- getTcSInerts ; if can_decompose inerts then canDecomposableTyConAppOK ev eq_rel tc1 tys1 tys2 - else canEqFailure ev eq_rel ty1 ty2 } + else if rewritten + then canEqFailure ev eq_rel ty1 ty2 + else rewrite_and_try_again ev eq_rel ty1 ty2 } -- See Note [Skolem abstract data] in GHC.Core.Tycon | tyConSkolem tc1 || tyConSkolem tc2 ===================================== testsuite/tests/typecheck/should_fail/T15801.stderr ===================================== @@ -1,6 +1,6 @@ T15801.hs:52:10: error: [GHC-18872] - • Couldn't match representation of type: op_a --> b - with that of: UnOp op_a -> UnOp b + • Couldn't match representation of type: UnOp op_a -> UnOp b + with that of: op_a --> b arising from the superclasses of an instance declaration • In the instance declaration for ‘OpRíki (Op (*))’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7fdcf917035e8d17493176adc263fcaf2f930874 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7fdcf917035e8d17493176adc263fcaf2f930874 You're receiving 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 Jan 2 19:03:32 2023 From: gitlab at gitlab.haskell.org (Richard Eisenberg (@rae)) Date: Mon, 02 Jan 2023 14:03:32 -0500 Subject: [Git][ghc/ghc][wip/t22519] Add stuff to Note Message-ID: <63b32a8428600_2a26f511310b30021493cc@gitlab.mail> Richard Eisenberg pushed to branch wip/t22519 at Glasgow Haskell Compiler / GHC Commits: efe7c324 by Richard Eisenberg at 2023-01-02T14:02:25-05:00 Add stuff to Note - - - - - 2 changed files: - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/Rewrite.hs Changes: ===================================== compiler/GHC/Tc/Solver/Canonical.hs ===================================== @@ -1368,8 +1368,39 @@ which in turn gives us [W] a ~R# b which is easier to satisfy. -Bottom line: unwrap newtypes before decomposing them! -c.f. #9123 comment:52,53 for a compelling example. +We thus must unwrap newtypes before decomposing them. But even this is +challenging. Here are two cases to consider: + +Case 1: + + newtype Age = MkAge Int + [G] c + [W] w1 :: IO Age ~R# IO Int + +Case 2: + + newtype A = MkA [A] + [W] A ~R# [A] + +For Case 1, recall that IO is an abstract newtype. Then read +Note [Decomposing newtype equalities]. According to that Note, +we should not decompose w1, as we have an Irred Given. Yet we still +want to solve the wanted! So we unwrap the newtypes we can, deeply. +This is done in the rewriter: GHC.Tc.Solver.Rewrite.rewrite_newtype_app. + +Yet for Case 2, deep rewriting would be a disaster: we would loop. Instead, +here, we just want to unwrap newtypes at the top level, allowing us to +succeed via Note [Eager reflexivity check]. + +To satisfy both cases, we unwrap *both* in can_eq_nc' and in the rewriter. +The former unwraps outer newtypes (when the data constructor is in scope). +The latter unwraps deeply -- but it won't be invoked in Case 2, when we +can recognize an equality between the types [A] and [A] before rewriting +deeply. + +This is delicate, but I think we're doomed to do *something* delicate, +as we're really trying to solve for equirecursive type equality. Bottom +line for users: recursive newtypes are dangerous. Note [Eager reflexivity check] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Tc/Solver/Rewrite.hs ===================================== @@ -497,6 +497,7 @@ rewrite_one ty@(TyConApp tc tys) -- NB: try rewrite_newtype_app even when tc isn't a newtype; -- the allows the possibility of having a newtype buried under -- a synonym. Needed for e.g. T12067. + -- See Note [Unwrap newtypes first] in GHC.Tc.Solver.Canonincal. then rewrite_newtype_app ty -- For * a normal data type application View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/efe7c324435dfabf1ec64088fc9d10e0f1c0a0db -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/efe7c324435dfabf1ec64088fc9d10e0f1c0a0db You're receiving 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 Jan 2 23:39:08 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 02 Jan 2023 18:39:08 -0500 Subject: [Git][ghc/ghc][wip/T22130] 26 commits: nonmoving: Fix race in marking of blackholes Message-ID: <63b36b1cb9ca6_2a26f5a43d37c821623f8@gitlab.mail> Matthew Pickering pushed to branch wip/T22130 at Glasgow Haskell Compiler / GHC Commits: 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-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). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Bodigrim at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 14ee7a04 by Ryan Scott at 2023-01-01T16:48:48+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 ``` - - - - - 6658c45d by Tamar Christina at 2023-01-02T23:38:30+00:00 linker: Fix BFD import libraries - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - 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/HsToCore/Quote.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/Tc/Errors.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/Types/Constraint.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/67cfa2cce93bcedbc720f6c6d6df27683d76ad30...6658c45d43de1a85ac4e823a92613b5c3d04d868 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/67cfa2cce93bcedbc720f6c6d6df27683d76ad30...6658c45d43de1a85ac4e823a92613b5c3d04d868 You're receiving 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 Jan 2 23:41:57 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 02 Jan 2023 18:41:57 -0500 Subject: [Git][ghc/ghc][wip/T22166] linker: Fix BFD import libraries Message-ID: <63b36bc5bc98d_2a26f5c980f164216254b@gitlab.mail> Matthew Pickering pushed to branch wip/T22166 at Glasgow Haskell Compiler / GHC Commits: 6658c45d by Tamar Christina at 2023-01-02T23:38:30+00:00 linker: Fix BFD import libraries - - - - - 10 changed files: - hadrian/src/Settings/Packages.hs - libraries/base/System/Posix/Internals.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 - testsuite/tests/rts/all.T Changes: ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -404,7 +404,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 ===================================== libraries/base/System/Posix/Internals.hs ===================================== @@ -904,6 +904,7 @@ foreign import capi unsafe "stdio.h value SEEK_END" sEEK_END :: CInt {- Note [Windows types] +~~~~~~~~~~~~~~~~~~~~ Windows' _read and _write have types that differ from POSIX. They take an unsigned int for length and return a signed int where POSIX uses size_t and ===================================== 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 ===================================== @@ -54,11 +54,16 @@ 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]. */ + * to process overflowing relocations. See Note [Processing overflowed relocations]. + * This is bitfield however only the option SYM_TYPE_DUP_DISCARD can be combined + * with the other values. */ 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 ===================================== testsuite/tests/rts/all.T ===================================== @@ -410,7 +410,7 @@ test('T10296b', [only_ways(['threaded2'])], compile_and_run, ['']) test('numa001', [ extra_run_opts('8'), unless(unregisterised(), extra_ways(['debug_numa'])) ] , compile_and_run, ['']) -test('T12497', [ unless(opsys('mingw32'), skip) +test('T12497', [ unless(opsys('mingw32'), skip), expect_broken(22694) ], makefile_test, ['T12497']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6658c45d43de1a85ac4e823a92613b5c3d04d868 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6658c45d43de1a85ac4e823a92613b5c3d04d868 You're receiving 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 Jan 3 03:03:56 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 02 Jan 2023 22:03:56 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/sized-literals Message-ID: <63b39b1c66b59_2a26f5a43d37c8218163@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/sized-literals at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/sized-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 Tue Jan 3 11:35:02 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 03 Jan 2023 06:35:02 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/t22695 Message-ID: <63b412e6b21c0_2a26f512e1369cc222806a@gitlab.mail> Matthew Pickering pushed new branch wip/t22695 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/t22695 You're receiving 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 Jan 3 12:18:08 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 03 Jan 2023 07:18:08 -0500 Subject: [Git][ghc/ghc][wip/various-hadrian-fixes] 98 commits: rts/Messages: Refactor Message-ID: <63b41d00ba058_2a26f5563f80f822379d4@gitlab.mail> Matthew Pickering pushed to branch wip/various-hadrian-fixes at Glasgow Haskell Compiler / GHC Commits: ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/ThreadPaused: Ordering fixes - - - - - 914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00 eventlog: Silence spurious data race - - - - - fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts: Use fences instead of explicit barriers - - - - - 2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - 70999283 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 98689f77 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - 86f20258 by Ben Gamari at 2022-12-16T16:12:45-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. - - - - - f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate access to capabilities array - - - - - 7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate sched_state - - - - - 1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Style fix - - - - - 82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00 compiler: Use release store in eager blackholing - - - - - eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Fix ordering of makeStableName - - - - - ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Note race with wakeBlockingQueue - - - - - 5acf33dd by Bodigrim at 2022-12-16T16:13:22-05:00 Bump submodule directory to 1.3.8.0 and hpc to HEAD - - - - - 0dd95421 by Bodigrim at 2022-12-16T16:13:22-05:00 Accept allocations increase on Windows This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips between lists and ByteArray. See #22625 for discussion. Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T10547 T12150 T12227 T12234 T12425 T13035 T13253 T13253-spj T13701 T13719 T15703 T16875 T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T21839r T5837 T6048 T9198 T9961 TcPlugin_RewritePerf hard_hole_fits - - - - - ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00 testsuite: Mark T9405 as fragile instead of broken on Windows It's starting to pass again, and the unexpected pass blocks CI. - - - - - 1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: remove obsolete commented code in wasm NCG It was just a temporary hack to workaround a bug in the relooper, that bug has been fixed long before the wasm backend is merged. - - - - - e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm Also removes some unreachable code here. - - - - - 1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: change fallback function signature to Cmm function signature in wasm NCG In the wasm NCG, when handling a `CLabel` of undefined function without knowing its function signature, we used to fallback to `() -> ()` which is accepted by `wasm-ld`. This patch changes it to the signature of Cmm functions, which equally works, but would be required when we emit tail call instructions. - - - - - 8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add optional tail-call support in wasm NCG When the `-mtail-call` clang flag is passed at configure time, wasm tail-call extension is enabled, and the wasm NCG will emit `return_call`/`return_call_indirect` instructions to take advantage of it and avoid the `StgRun` trampoline overhead. Closes #22461. - - - - - d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00 base: add missing autoconf checks for waitpid/umask These are not present in wasi-libc. Required for fixing #22589 - - - - - da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00 compiler: make .wasm the default executable extension on wasm32 Following convention as in other wasm toolchains. Fixes #22594. - - - - - ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00 ci: support hello.wasm in ci.sh cross testing logic - - - - - 6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00 Correct `exitWith` Haddocks The `IOError`-specific `catch` in the Prelude is long gone. - - - - - b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-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. - - - - - 761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00 rts/libdw: Silence uninitialized usage warnings As noted in #22538, previously some GCC versions warned that various locals in Libdw.c may be used uninitialized. Although this wasn't strictly true (since they were initialized in an inline assembler block) we fix this by providing explicit empty initializers. Fixes #22538 - - - - - 5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00 testsuite: Mark T16392 as fragile on windows See #22649 - - - - - 703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00 Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`. - - - - - 9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05: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 - - - - - 7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Drop uses of AC_PROG_CC_C99 As noted in #22566, this macro is deprecated as of autoconf-2.70 `AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself. Closes #22566. - - - - - 36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Use AS_HELP_STRING instead of AC_HELP_STRING The latter has been deprecated. See #22566. - - - - - befe6ff8 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: fix various usages of head and tail - - - - - 666d0ba7 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: avoid head and tail in parseCallEscape and around - - - - - 5d96fd50 by Bodigrim at 2022-12-20T21:16:37-05:00 Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty - - - - - 3ce2ab94 by Bodigrim at 2022-12-21T06:17:56-05:00 Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian - - - - - 954de93a by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule haskeline to HEAD (to allow transformers-0.6) - - - - - cefbeec3 by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule transformers to 0.6.0.4 - - - - - b4730b62 by Bodigrim at 2022-12-21T06:17:56-05:00 Fix tests T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations Metric Increase: T13253 - - - - - 0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05: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. - - - - - df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00 rts: explicitly store return value of ccall checkClosure to prevent type error (#22617) - - - - - e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix shadowing lacuna in OccurAnal Issue #22623 demonstrated another lacuna in the implementation of wrinkle (BS3) in Note [The binder-swap substitution] in the occurrence analyser. I was failing to add TyVar lambda binders using addInScope/addOneInScope and that led to a totally bogus binder-swap transformation. Very easy to fix. - - - - - 3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix an assertion check in addToEqualCtList The old assertion saw that a constraint ct could rewrite itself (of course it can) and complained (stupid). Fixes #22645 - - - - - ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00 configure: Bump version to 9.6 - - - - - fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00 base: Bump version to 4.18 Requires various submodule bumps. - - - - - 93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00 ghc-boot: Fix bootstrapping - - - - - fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00 Bump GHC version to 9.7 - - - - - 914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05: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. - - - - - 32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00 hadrian bindist: Install manpages to share/man/man1/ghc.1 When the installation makefile was copied over the manpages were no longer installed in the correct place. Now we install it into share/man/man1/ghc.1 as the make build system did. Fixes #22371 - - - - - b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00 rts: Drop paths from configure from cabal file A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them. - - - - - b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00 Bump libffi-tarballs submodule We will now use libffi-3.4.4. - - - - - 3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00 EPA: Make EOF position part of AnnsModule Closes #20951 Closes #19697 - - - - - 99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00 JS: fix support for -outputdir (#22641) The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug. - - - - - 02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00 Refactor mkRuntimeError This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions. - - - - - 35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00 base: Fix event manager shutdown race on non-Linux platforms During shutdown it's possible that we will attempt to use a closed fd to wakeup another capability's event manager. On the Linux eventfd path we were careful to handle this. However on the non-Linux path we failed to do so. Fix this. - - - - - 317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00 Fix unifier bug: failing to decompose over-saturated type family This simple patch fixes #22647 - - - - - 14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00 rts/m32: Fix sanity checking Previously we would attempt to clear pages which were marked as read-only. Fix this. - - - - - 16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00 ci: Move wasm pipelines into nightly rather than master See #22664 for the changes which need to be made to bring one of these back to the validate pipeline. - - - - - 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-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). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Bodigrim at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - e9318cf2 by Matthew Pickering at 2023-01-03T11:36:20+00: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. - - - - - 53f13af9 by Matthew Pickering at 2023-01-03T11:36:20+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - fa1d4eec by Matthew Pickering at 2023-01-03T11:36:20+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - 9cdb4d0a by Matthew Pickering at 2023-01-03T12:11:04+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 86561a2a by Matthew Pickering at 2023-01-03T12:12:49+00:00 check-exact: Fix build with -Werror - - - - - d8335579 by Matthew Pickering at 2023-01-03T12:12:49+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 - - - - - 4b9eff5f by Matthew Pickering at 2023-01-03T12:12:49+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - 11d7cc99 by Matthew Pickering at 2023-01-03T12:14:08+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 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Wasm.hs - compiler/GHC/CmmToAsm/Wasm/Asm.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/Wasm/Types.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unify.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ca836a37b4ad45576452c09456ab57794fa797b1...11d7cc9995619f0f02239a2441fd79852b3d3acd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ca836a37b4ad45576452c09456ab57794fa797b1...11d7cc9995619f0f02239a2441fd79852b3d3acd You're receiving 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 Jan 3 12:22:15 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 03 Jan 2023 07:22:15 -0500 Subject: [Git][ghc/ghc][wip/force-docs] 152 commits: Fix bounds-checking buglet in Data.Array.Byte Message-ID: <63b41df7ad15b_2a26f5a2ef9460224059c@gitlab.mail> Matthew Pickering pushed to branch wip/force-docs 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 - - - - - 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]. - - - - - 2eb0fb87 by Matthew Pickering at 2022-12-15T03:54:39-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 - - - - - 552b7908 by Ben Gamari at 2022-12-15T03:55:15-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. - - - - - 933d61a4 by Simon Peyton Jones at 2022-12-15T03:55:51-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. - - - - - 03ed0b95 by Ryan Scott at 2022-12-15T03:56:26-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. - - - - - ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/ThreadPaused: Ordering fixes - - - - - 914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00 eventlog: Silence spurious data race - - - - - fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts: Use fences instead of explicit barriers - - - - - 2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - 70999283 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 98689f77 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - 86f20258 by Ben Gamari at 2022-12-16T16:12:45-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. - - - - - f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate access to capabilities array - - - - - 7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate sched_state - - - - - 1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Style fix - - - - - 82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00 compiler: Use release store in eager blackholing - - - - - eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Fix ordering of makeStableName - - - - - ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Note race with wakeBlockingQueue - - - - - 5acf33dd by Bodigrim at 2022-12-16T16:13:22-05:00 Bump submodule directory to 1.3.8.0 and hpc to HEAD - - - - - 0dd95421 by Bodigrim at 2022-12-16T16:13:22-05:00 Accept allocations increase on Windows This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips between lists and ByteArray. See #22625 for discussion. Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T10547 T12150 T12227 T12234 T12425 T13035 T13253 T13253-spj T13701 T13719 T15703 T16875 T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T21839r T5837 T6048 T9198 T9961 TcPlugin_RewritePerf hard_hole_fits - - - - - ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00 testsuite: Mark T9405 as fragile instead of broken on Windows It's starting to pass again, and the unexpected pass blocks CI. - - - - - 1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: remove obsolete commented code in wasm NCG It was just a temporary hack to workaround a bug in the relooper, that bug has been fixed long before the wasm backend is merged. - - - - - e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm Also removes some unreachable code here. - - - - - 1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: change fallback function signature to Cmm function signature in wasm NCG In the wasm NCG, when handling a `CLabel` of undefined function without knowing its function signature, we used to fallback to `() -> ()` which is accepted by `wasm-ld`. This patch changes it to the signature of Cmm functions, which equally works, but would be required when we emit tail call instructions. - - - - - 8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add optional tail-call support in wasm NCG When the `-mtail-call` clang flag is passed at configure time, wasm tail-call extension is enabled, and the wasm NCG will emit `return_call`/`return_call_indirect` instructions to take advantage of it and avoid the `StgRun` trampoline overhead. Closes #22461. - - - - - d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00 base: add missing autoconf checks for waitpid/umask These are not present in wasi-libc. Required for fixing #22589 - - - - - da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00 compiler: make .wasm the default executable extension on wasm32 Following convention as in other wasm toolchains. Fixes #22594. - - - - - ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00 ci: support hello.wasm in ci.sh cross testing logic - - - - - 6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00 Correct `exitWith` Haddocks The `IOError`-specific `catch` in the Prelude is long gone. - - - - - b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-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. - - - - - 761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00 rts/libdw: Silence uninitialized usage warnings As noted in #22538, previously some GCC versions warned that various locals in Libdw.c may be used uninitialized. Although this wasn't strictly true (since they were initialized in an inline assembler block) we fix this by providing explicit empty initializers. Fixes #22538 - - - - - 5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00 testsuite: Mark T16392 as fragile on windows See #22649 - - - - - 703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00 Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`. - - - - - 9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05: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 - - - - - 7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Drop uses of AC_PROG_CC_C99 As noted in #22566, this macro is deprecated as of autoconf-2.70 `AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself. Closes #22566. - - - - - 36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Use AS_HELP_STRING instead of AC_HELP_STRING The latter has been deprecated. See #22566. - - - - - befe6ff8 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: fix various usages of head and tail - - - - - 666d0ba7 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: avoid head and tail in parseCallEscape and around - - - - - 5d96fd50 by Bodigrim at 2022-12-20T21:16:37-05:00 Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty - - - - - 3ce2ab94 by Bodigrim at 2022-12-21T06:17:56-05:00 Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian - - - - - 954de93a by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule haskeline to HEAD (to allow transformers-0.6) - - - - - cefbeec3 by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule transformers to 0.6.0.4 - - - - - b4730b62 by Bodigrim at 2022-12-21T06:17:56-05:00 Fix tests T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations Metric Increase: T13253 - - - - - 0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05: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. - - - - - df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00 rts: explicitly store return value of ccall checkClosure to prevent type error (#22617) - - - - - e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix shadowing lacuna in OccurAnal Issue #22623 demonstrated another lacuna in the implementation of wrinkle (BS3) in Note [The binder-swap substitution] in the occurrence analyser. I was failing to add TyVar lambda binders using addInScope/addOneInScope and that led to a totally bogus binder-swap transformation. Very easy to fix. - - - - - 3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix an assertion check in addToEqualCtList The old assertion saw that a constraint ct could rewrite itself (of course it can) and complained (stupid). Fixes #22645 - - - - - ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00 configure: Bump version to 9.6 - - - - - fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00 base: Bump version to 4.18 Requires various submodule bumps. - - - - - 93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00 ghc-boot: Fix bootstrapping - - - - - fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00 Bump GHC version to 9.7 - - - - - 914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05: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. - - - - - 32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00 hadrian bindist: Install manpages to share/man/man1/ghc.1 When the installation makefile was copied over the manpages were no longer installed in the correct place. Now we install it into share/man/man1/ghc.1 as the make build system did. Fixes #22371 - - - - - b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00 rts: Drop paths from configure from cabal file A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them. - - - - - b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00 Bump libffi-tarballs submodule We will now use libffi-3.4.4. - - - - - 3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00 EPA: Make EOF position part of AnnsModule Closes #20951 Closes #19697 - - - - - 99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00 JS: fix support for -outputdir (#22641) The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug. - - - - - 02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00 Refactor mkRuntimeError This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions. - - - - - 35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00 base: Fix event manager shutdown race on non-Linux platforms During shutdown it's possible that we will attempt to use a closed fd to wakeup another capability's event manager. On the Linux eventfd path we were careful to handle this. However on the non-Linux path we failed to do so. Fix this. - - - - - 317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00 Fix unifier bug: failing to decompose over-saturated type family This simple patch fixes #22647 - - - - - 14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00 rts/m32: Fix sanity checking Previously we would attempt to clear pages which were marked as read-only. Fix this. - - - - - 16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00 ci: Move wasm pipelines into nightly rather than master See #22664 for the changes which need to be made to bring one of these back to the validate pipeline. - - - - - 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-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). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Bodigrim at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - compiler/CodeGen.Platform.h - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info/Build.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.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.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/CmmToAsm/Wasm.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 The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/38a78f51b9b33f8bd39534f7930301b3310e49e2...62b9a7b23b20f5cf0a2de14251c2096098009f10 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/38a78f51b9b33f8bd39534f7930301b3310e49e2...62b9a7b23b20f5cf0a2de14251c2096098009f10 You're receiving 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 Jan 3 12:36:27 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 03 Jan 2023 07:36:27 -0500 Subject: [Git][ghc/ghc][wip/t22695] Only store Name in FunRhs rather than Id with knot-tied fields Message-ID: <63b4214bc340a_2a26f5c980f1642251495@gitlab.mail> Matthew Pickering pushed to branch wip/t22695 at Glasgow Haskell Compiler / GHC Commits: e9821db3 by Matthew Pickering at 2023-01-03T12:36:05+00:00 Only store Name in FunRhs rather than Id with knot-tied fields The Note [fixM for rhs_ty in tcMonoBinds] explains that certain fields of the Id created here are knot-tied and can't be referenced inside the scope of the fixM. The modification to `FunRhs` ensures that we can't accidentally force the knot-tied fields of the `Id`. The `Name` is just used for error messages and printing. The result is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. Fixes #22695 - - - - - 10 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/Language/Haskell/Syntax/Expr.hs - + testsuite/tests/ghci/scripts/T22695.script - + testsuite/tests/ghci/scripts/T22695.stderr - testsuite/tests/ghci/scripts/all.T - testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -2002,7 +2002,7 @@ matchSeparator ThPatSplice = panic "unused" matchSeparator ThPatQuote = panic "unused" matchSeparator PatSyn = panic "unused" -pprMatchContext :: (Outputable (IdP p), UnXRec p) +pprMatchContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContext ctxt | want_an ctxt = text "an" <+> pprMatchContextNoun ctxt @@ -2013,10 +2013,10 @@ pprMatchContext ctxt want_an (ArrowMatchCtxt KappaExpr) = True want_an _ = False -pprMatchContextNoun :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNoun :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNoun (FunRhs {mc_fun=fun}) = text "equation for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNoun CaseAlt = text "case alternative" pprMatchContextNoun (LamCaseAlt lc_variant) = lamCaseKeyword lc_variant <+> text "alternative" @@ -2032,10 +2032,10 @@ pprMatchContextNoun (StmtCtxt ctxt) = text "pattern binding in" $$ pprAStmtContext ctxt pprMatchContextNoun PatSyn = text "pattern synonym declaration" -pprMatchContextNouns :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNouns :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNouns (FunRhs {mc_fun=fun}) = text "equations for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNouns PatBindGuards = text "pattern binding guards" pprMatchContextNouns (ArrowMatchCtxt c) = pprArrowMatchContextNouns c pprMatchContextNouns (StmtCtxt ctxt) = text "pattern bindings in" @@ -2056,7 +2056,7 @@ pprArrowMatchContextNouns (ArrowLamCaseAlt lc_variant) = lamCaseKeyword lc_varia pprArrowMatchContextNouns ctxt = pprArrowMatchContextNoun ctxt <> char 's' ----------------- -pprAStmtContext, pprStmtContext :: (Outputable (IdP p), UnXRec p) +pprAStmtContext, pprStmtContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsStmtContext p -> SDoc pprAStmtContext (HsDoStmt flavour) = pprAHsDoFlavour flavour pprAStmtContext ctxt = text "a" <+> pprStmtContext ctxt ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -863,7 +863,7 @@ mkSimpleGeneratedFunBind loc fun pats expr emptyLocalBinds] -- | Make a prefix, non-strict function 'HsMatchContext' -mkPrefixFunRhs :: LIdP p -> HsMatchContext p +mkPrefixFunRhs :: LIdP (NoGhcTc p) -> HsMatchContext p mkPrefixFunRhs n = FunRhs { mc_fun = n , mc_fixity = Prefix , mc_strictness = NoSrcStrict } ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -957,7 +957,7 @@ instance HiePass p => ToHie (HsMatchContext (GhcPass p)) where name' :: LocatedN Name name' = case hiePass @p of HieRn -> name - HieTc -> fmap varName name + HieTc -> name toHie (StmtCtxt a) = toHie a toHie _ = pure [] ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -127,12 +127,7 @@ tcMatchesFun fun_id matches exp_ty herald = ExpectedFunTyMatches (NameThing fun_name) matches ctxt = GenSigCtxt -- Was: FunSigCtxt fun_name True -- But that's wrong for f :: Int -> forall a. blah - what = FunRhs { mc_fun = fun_id, mc_fixity = Prefix, mc_strictness = strictness } - -- Careful: this fun_id could be an unfilled - -- thunk from fixM in tcMonoBinds, so we're - -- not allowed to look at it, except for - -- idName. - -- See Note [fixM for rhs_ty in tcMonoBinds] + what = FunRhs { mc_fun = idName <$> fun_id, mc_fixity = Prefix, mc_strictness = strictness } match_ctxt = MC { mc_what = what, mc_body = tcBody } strictness | [L _ match] <- unLoc $ mg_alts matches ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -838,7 +838,7 @@ tcPatSynMatcher (L loc ps_name) lpat prag_fn args body] , mg_ext = MatchGroupTc (map unrestricted [pat_ty, cont_ty, fail_ty]) res_ty Generated } - match = mkMatch (mkPrefixFunRhs (L loc patsyn_id)) [] + match = mkMatch (mkPrefixFunRhs (L loc (idName patsyn_id))) [] (mkHsLams (rr_tv:res_tv:univ_tvs) req_dicts body') (EmptyLocalBinds noExtField) ===================================== compiler/Language/Haskell/Syntax/Expr.hs ===================================== @@ -1533,7 +1533,7 @@ data HsMatchContext p = FunRhs -- ^ A pattern matching on an argument of a -- function binding - { mc_fun :: LIdP p -- ^ function binder of @f@ + { mc_fun :: LIdP (NoGhcTc p) -- ^ function binder of @f@ , mc_fixity :: LexicalFixity -- ^ fixing of @f@ , mc_strictness :: SrcStrictness -- ^ was @f@ banged? -- See Note [FunBind vs PatBind] ===================================== testsuite/tests/ghci/scripts/T22695.script ===================================== @@ -0,0 +1 @@ +test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/T22695.stderr ===================================== @@ -0,0 +1,8 @@ + +:1:10: error: + • The constructor ‘Just’ should have 1 argument, but has been given none + • In the pattern: Just + In a stmt of a pattern guard for + an equation for ‘test’: + Just <- x + In an equation for ‘test’: test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -370,3 +370,4 @@ test('T21110', [extra_files(['T21110A.hs'])], ghci_script, test('T17830', [filter_stdout_lines(r'======.*')], ghci_script, ['T17830.script']) test('T21294a', normal, ghci_script, ['T21294a.script']) test('T21507', normal, ghci_script, ['T21507.script']) +test('T22695', normal, ghci_script, ['T22695.script']) ===================================== testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr ===================================== @@ -1560,7 +1560,7 @@ (FunRhs (L (SrcSpanAnn (EpAnnNotUsed) { DumpTypecheckedAst.hs:19:1-4 }) - {Var: main}) + {Name: main}) (Prefix) (NoSrcStrict)) [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e9821db3c8b484473a2debfb874e105bca96ea49 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e9821db3c8b484473a2debfb874e105bca96ea49 You're receiving 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 Jan 3 12:53:21 2023 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Tue, 03 Jan 2023 07:53:21 -0500 Subject: [Git][ghc/ghc][wip/req_smp] 2 commits: fixup: more naming fixes Message-ID: <63b425419058c_2a26f5237be3002257334@gitlab.mail> doyougnu pushed to branch wip/req_smp at Glasgow Haskell Compiler / GHC Commits: f87a405f by doyougnu at 2023-01-03T07:53:03-05:00 fixup: more naming fixes - - - - - cab788a1 by doyougnu at 2023-01-03T07:53:04-05:00 mark failing tests as host req smp - - - - - 6 changed files: - testsuite/driver/testlib.py - testsuite/tests/codeGen/should_run/all.T - testsuite/tests/concurrent/should_run/all.T - testsuite/tests/driver/T20030/test1/all.T - testsuite/tests/driver/j-space/all.T - testsuite/tests/driver/t22391/all.T Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -302,7 +302,7 @@ def req_host_smp( name, opts ): smp. Use this when the test needs to be compiled with smp support, but may not necessarily be run. """ - if not config.host_with_smp: + if not config.host_has_smp: opts.skip = True def req_target_smp( name, opts ): @@ -311,7 +311,7 @@ def req_target_smp( name, opts ): not support smp, then mark the test as an expected fail. Use this when the test needs to run with smp support. """ - if not config.target_with_smp: + if not config.target_has_smp: opts.expect = 'fail' def ignore_stdout(name, opts): ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -156,7 +156,7 @@ test('T10246', normal, compile_and_run, ['']) test('T9533', normal, compile_and_run, ['']) test('T9533b', normal, compile_and_run, ['']) test('T9533c', normal, compile_and_run, ['']) -test('T10414', [only_ways(['threaded2']), extra_ways(['threaded2']), req_target_smp], +test('T10414', [only_ways(['threaded2']), extra_ways(['threaded2']), req_target_smp, req_host_smp], compile_and_run, ['-feager-blackholing']) test('T10521', normal, compile_and_run, ['']) test('T10521b', normal, compile_and_run, ['']) ===================================== testsuite/tests/concurrent/should_run/all.T ===================================== @@ -240,7 +240,9 @@ test('setnumcapabilities001', [ only_ways(['threaded1','threaded2', 'nonmoving_thr', 'profthreaded']), extra_run_opts('8 12 2000'), when(have_thread_sanitizer(), expect_broken(18808)), - req_target_smp ], + req_target_smp, + req_host_smp + ], compile_and_run, ['']) test('T21651', @@ -248,7 +250,9 @@ test('T21651', when(opsys('mingw32'),skip), # uses POSIX pipes when(opsys('darwin'),extra_run_opts('8 12 2000 100')), unless(opsys('darwin'),extra_run_opts('8 12 2000 200')), # darwin runners complain of too many open files - req_target_smp ], + req_target_smp, + req_host_smp + ], compile_and_run, ['']) test('hs_try_putmvar001', ===================================== testsuite/tests/driver/T20030/test1/all.T ===================================== @@ -10,5 +10,6 @@ test('T20030_test1j', , 'D.hs' , 'E.hs-boot' , 'E.hs' , 'F.hs' , 'G.hs' , 'H.hs' , 'I.hs', 'J.hs-boot', 'J.hs', 'K.hs' ]) , req_target_smp + , req_host_smp ], multimod_compile, ['I.hs K.hs', '-v1 -j']) ===================================== testsuite/tests/driver/j-space/all.T ===================================== @@ -1 +1 @@ -test('jspace', [extra_files(['genJspace']), req_target_smp], makefile_test, ['jspace']) +test('jspace', [extra_files(['genJspace']), req_target_smp, req_host_smp], makefile_test, ['jspace']) ===================================== testsuite/tests/driver/t22391/all.T ===================================== @@ -1,5 +1,5 @@ test('t22391', [extra_files(['src'])], multimod_compile, ['Lib', '-v1 -Wall -fhide-source-paths -isrc -fdefer-diagnostics']) -test('t22391j', [req_target_smp, extra_files(['src'])], +test('t22391j', [req_target_smp, req_host_smp, extra_files(['src'])], multimod_compile, ['Lib', '-v1 -Wall -fhide-source-paths -isrc -fdefer-diagnostics -j2']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eb21f2f62b0ec2a1bd5a3001581658c6bfdfd170...cab788a163f391551da23b6d61ce9a83d8b404bc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eb21f2f62b0ec2a1bd5a3001581658c6bfdfd170...cab788a163f391551da23b6d61ce9a83d8b404bc You're receiving 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 Jan 3 14:56:19 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 03 Jan 2023 09:56:19 -0500 Subject: [Git][ghc/ghc][wip/T20666] 25 commits: nonmoving: Fix race in marking of blackholes Message-ID: <63b4421346563_2a26f5563f80f822727f6@gitlab.mail> Simon Peyton Jones pushed to branch wip/T20666 at Glasgow Haskell Compiler / GHC Commits: 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-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). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Bodigrim at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 44688140 by Richard Eisenberg at 2023-01-03T12:55:19+00:00 Refactor the treatment of loopy superclass dicts This patch completely re-engineers how we deal with loopy superclass dictionaries in instance declarations. It fixes #20666. The highlights are * Recognise that the loopy-superclass business should use precisely the Paterson conditions. This is much much nicer. See Note [Recursive superclasses] in GHC.Tc.TyCl.Instance * With that in mind, define "Paterson-smaller" in Note [Paterson conditions] in GHC.Tc.Validity, and the new data type `PatersonSize` in GHC.Tc.Utils.TcType, along with functions to compute and compare PatsonSizes * Use the new PatersonSize stuff when solving superclass constraints See Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance * In GHC.Tc.Solver.Monad.lookupInInerts, add a missing call to prohibitedSuperClassSolve. This was the original cause of #20666. * Treat (TypeError "stuff") as having PatersonSize zero. See Note [Paterson size for type family applications] in GHC.Tc.Utils.TcType. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Infer.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/InertSet.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/Tc/Solver/Monad.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a341d0e15a83dcd45d92398df48dd0051cb6b0a1...4468814072e208c7b86d6cd73e77f339be3c19e1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a341d0e15a83dcd45d92398df48dd0051cb6b0a1...4468814072e208c7b86d6cd73e77f339be3c19e1 You're receiving 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 Jan 3 15:59:55 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 03 Jan 2023 10:59:55 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/t22690 Message-ID: <63b450fb98150_2a26f5fdf373a4228247e@gitlab.mail> Matthew Pickering pushed new branch wip/t22690 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/t22690 You're receiving 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 Jan 3 16:28:24 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 03 Jan 2023 11:28:24 -0500 Subject: [Git][ghc/ghc][wip/t22695] Only store Name in FunRhs rather than Id with knot-tied fields Message-ID: <63b457a8d8797_2a26f5a2ef946022970bc@gitlab.mail> Matthew Pickering pushed to branch wip/t22695 at Glasgow Haskell Compiler / GHC Commits: a5037f2f by Matthew Pickering at 2023-01-03T16:27:37+00:00 Only store Name in FunRhs rather than Id with knot-tied fields The Note [fixM for rhs_ty in tcMonoBinds] explains that certain fields of the Id created here are knot-tied and can't be referenced inside the scope of the fixM. The modification to `FunRhs` ensures that we can't accidentally force the knot-tied fields of the `Id`. The `Name` is just used for error messages and printing. The result is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. Fixes #22695 - - - - - 11 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/Language/Haskell/Syntax/Expr.hs - + testsuite/tests/ghci/scripts/T22695.script - + testsuite/tests/ghci/scripts/T22695.stderr - testsuite/tests/ghci/scripts/all.T - testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -2002,7 +2002,7 @@ matchSeparator ThPatSplice = panic "unused" matchSeparator ThPatQuote = panic "unused" matchSeparator PatSyn = panic "unused" -pprMatchContext :: (Outputable (IdP p), UnXRec p) +pprMatchContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContext ctxt | want_an ctxt = text "an" <+> pprMatchContextNoun ctxt @@ -2013,10 +2013,10 @@ pprMatchContext ctxt want_an (ArrowMatchCtxt KappaExpr) = True want_an _ = False -pprMatchContextNoun :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNoun :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNoun (FunRhs {mc_fun=fun}) = text "equation for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNoun CaseAlt = text "case alternative" pprMatchContextNoun (LamCaseAlt lc_variant) = lamCaseKeyword lc_variant <+> text "alternative" @@ -2032,10 +2032,10 @@ pprMatchContextNoun (StmtCtxt ctxt) = text "pattern binding in" $$ pprAStmtContext ctxt pprMatchContextNoun PatSyn = text "pattern synonym declaration" -pprMatchContextNouns :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNouns :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNouns (FunRhs {mc_fun=fun}) = text "equations for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNouns PatBindGuards = text "pattern binding guards" pprMatchContextNouns (ArrowMatchCtxt c) = pprArrowMatchContextNouns c pprMatchContextNouns (StmtCtxt ctxt) = text "pattern bindings in" @@ -2056,7 +2056,7 @@ pprArrowMatchContextNouns (ArrowLamCaseAlt lc_variant) = lamCaseKeyword lc_varia pprArrowMatchContextNouns ctxt = pprArrowMatchContextNoun ctxt <> char 's' ----------------- -pprAStmtContext, pprStmtContext :: (Outputable (IdP p), UnXRec p) +pprAStmtContext, pprStmtContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsStmtContext p -> SDoc pprAStmtContext (HsDoStmt flavour) = pprAHsDoFlavour flavour pprAStmtContext ctxt = text "a" <+> pprStmtContext ctxt ===================================== compiler/GHC/Hs/Extension.hs ===================================== @@ -98,6 +98,13 @@ constraint of IsPass is *recursive*: it asserts that IsPass (NoGhcTcPass p) hold For this to make sense, we need -XUndecidableSuperClasses and the other constraint, saying that NoGhcTcPass is idempotent. +There are also situations (such as in HsMatchContext) where we start by storing a +RdrName in the parser, then a Name in the renamer but don't store an Id in the typechecker. +The reason here is that the Id we would use in the typechecker is in the middle of being +constructed by knot-tying (see Note [fixM for rhs_ty in tcMonoBinds]). All the fields +apart from the `Name` can't be inspected whilst in the loop, so it's safer to just store the +Name (see #22695 for where this went wrong). + -} -- See Note [XRec and Anno in the AST] in GHC.Parser.Annotation ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -863,7 +863,7 @@ mkSimpleGeneratedFunBind loc fun pats expr emptyLocalBinds] -- | Make a prefix, non-strict function 'HsMatchContext' -mkPrefixFunRhs :: LIdP p -> HsMatchContext p +mkPrefixFunRhs :: LIdP (NoGhcTc p) -> HsMatchContext p mkPrefixFunRhs n = FunRhs { mc_fun = n , mc_fixity = Prefix , mc_strictness = NoSrcStrict } ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -957,7 +957,7 @@ instance HiePass p => ToHie (HsMatchContext (GhcPass p)) where name' :: LocatedN Name name' = case hiePass @p of HieRn -> name - HieTc -> fmap varName name + HieTc -> name toHie (StmtCtxt a) = toHie a toHie _ = pure [] ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -127,12 +127,7 @@ tcMatchesFun fun_id matches exp_ty herald = ExpectedFunTyMatches (NameThing fun_name) matches ctxt = GenSigCtxt -- Was: FunSigCtxt fun_name True -- But that's wrong for f :: Int -> forall a. blah - what = FunRhs { mc_fun = fun_id, mc_fixity = Prefix, mc_strictness = strictness } - -- Careful: this fun_id could be an unfilled - -- thunk from fixM in tcMonoBinds, so we're - -- not allowed to look at it, except for - -- idName. - -- See Note [fixM for rhs_ty in tcMonoBinds] + what = FunRhs { mc_fun = idName <$> fun_id, mc_fixity = Prefix, mc_strictness = strictness } match_ctxt = MC { mc_what = what, mc_body = tcBody } strictness | [L _ match] <- unLoc $ mg_alts matches ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -838,7 +838,7 @@ tcPatSynMatcher (L loc ps_name) lpat prag_fn args body] , mg_ext = MatchGroupTc (map unrestricted [pat_ty, cont_ty, fail_ty]) res_ty Generated } - match = mkMatch (mkPrefixFunRhs (L loc patsyn_id)) [] + match = mkMatch (mkPrefixFunRhs (L loc (idName patsyn_id))) [] (mkHsLams (rr_tv:res_tv:univ_tvs) req_dicts body') (EmptyLocalBinds noExtField) ===================================== compiler/Language/Haskell/Syntax/Expr.hs ===================================== @@ -1533,7 +1533,14 @@ data HsMatchContext p = FunRhs -- ^ A pattern matching on an argument of a -- function binding - { mc_fun :: LIdP p -- ^ function binder of @f@ + { mc_fun :: LIdP (NoGhcTc p) -- ^ function binder of @f@ + -- See Note [NoGhcTc], this usage of 'NoGhcTc' is + -- because the 'Id' which would be put here + -- in 'tcMatchesFun' contains unfilled thunks + -- (see Note [fixM for rhs_ty in tcMonoBinds]) + -- As it is only printed + -- in error messages and traces, it's safer to just + -- store the Name. , mc_fixity :: LexicalFixity -- ^ fixing of @f@ , mc_strictness :: SrcStrictness -- ^ was @f@ banged? -- See Note [FunBind vs PatBind] ===================================== testsuite/tests/ghci/scripts/T22695.script ===================================== @@ -0,0 +1 @@ +test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/T22695.stderr ===================================== @@ -0,0 +1,8 @@ + +:1:10: error: + • The constructor ‘Just’ should have 1 argument, but has been given none + • In the pattern: Just + In a stmt of a pattern guard for + an equation for ‘test’: + Just <- x + In an equation for ‘test’: test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -370,3 +370,4 @@ test('T21110', [extra_files(['T21110A.hs'])], ghci_script, test('T17830', [filter_stdout_lines(r'======.*')], ghci_script, ['T17830.script']) test('T21294a', normal, ghci_script, ['T21294a.script']) test('T21507', normal, ghci_script, ['T21507.script']) +test('T22695', normal, ghci_script, ['T22695.script']) ===================================== testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr ===================================== @@ -1560,7 +1560,7 @@ (FunRhs (L (SrcSpanAnn (EpAnnNotUsed) { DumpTypecheckedAst.hs:19:1-4 }) - {Var: main}) + {Name: main}) (Prefix) (NoSrcStrict)) [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a5037f2f62d06fa21d7f8a733e833947124efd16 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a5037f2f62d06fa21d7f8a733e833947124efd16 You're receiving 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 Jan 3 16:29:56 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 03 Jan 2023 11:29:56 -0500 Subject: [Git][ghc/ghc][wip/T20666] Wibbles Message-ID: <63b45804d4f9c_2a26f5a2ef94602297433@gitlab.mail> Simon Peyton Jones pushed to branch wip/T20666 at Glasgow Haskell Compiler / GHC Commits: 50968773 by Simon Peyton Jones at 2023-01-03T16:30:11+00:00 Wibbles - - - - - 3 changed files: - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Validity.hs - testsuite/tests/indexed-types/should_fail/TyFamUndec.stderr Changes: ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -136,11 +136,12 @@ module GHC.Tc.Utils.TcType ( PatersonSize(..), PatersonSizeFailure(..), ltPatersonSize, pSizeZero, pSizeOne, - pSizeType, pSizeTypeX, + pSizeType, pSizeTypeX, pSizeTypes, pSizeClassPred, pSizeClassPredX, pSizeTyConApp, noMoreTyVars, allDistinctTyVars, TypeSize, sizeType, sizeTypes, scopedSort, + isTerminatingClass, isStuckTypeFamily, -------------------------------- -- Reexported from Kind @@ -2354,8 +2355,8 @@ described in #15177, which contains a number of examples. The suspicious bits are the calls to filterOutInvisibleTypes. See also #11833. -Note [Paterson size for type family applications] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Note [PatersonSize for type family applications] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A type-family application has infinite size (PS_TyFam); see (PC3) in Note [Paterson conditions] in GHC.Tc.Validity. @@ -2438,6 +2439,9 @@ addPSize (PS_Vanilla { ps_tvs = tvs1, ps_size = s1 }) pSizeType :: Type -> PatersonSize pSizeType = pSizeTypeX emptyVarSet +pSizeTypes :: [Type] -> PatersonSize +pSizeTypes = pSizeTypesX emptyVarSet pSizeZero + -- Free variables of a type, retaining repetitions, and expanding synonyms -- This ignores coercions, as coercions aren't user-written pSizeTypeX :: VarSet -> Type -> PatersonSize @@ -2446,10 +2450,7 @@ pSizeTypeX bvs (TyVarTy tv) | tv `elemVarSet` bvs = pSizeOne | otherwise = PS_Vanilla { ps_tvs = [tv], ps_size = 1 } pSizeTypeX _ (LitTy {}) = pSizeOne - -pSizeTypeX bvs (TyConApp tc tys) - | isTypeFamilyTyCon tc = pSizeTyFamApp tc - | otherwise = pSizeTyConAppX bvs tc tys +pSizeTypeX bvs (TyConApp tc tys) = pSizeTyConAppX bvs tc tys pSizeTypeX bvs (AppTy fun arg) = pSizeTypeX bvs fun `addPSize` pSizeTypeX bvs arg pSizeTypeX bvs (FunTy _ w arg res) = pSizeTypeX bvs w `addPSize` pSizeTypeX bvs arg `addPSize` pSizeTypeX bvs res @@ -2458,11 +2459,8 @@ pSizeTypeX bvs (ForAllTy (Bndr tv _) ty) = pSizeTypeX bvs (tyVarKind tv) `addPSi pSizeTypeX bvs (CastTy ty _) = pSizeTypeX bvs ty pSizeTypeX _ (CoercionTy {}) = pSizeOne -pSizeTyFamApp :: TyCon -> PatersonSize --- See Note [PatersonSize for type family applications] -pSizeTyFamApp tc - | tc `hasKey` errorMessageTypeErrorFamKey = pSizeZero - | otherwise = PS_TyFam tc +pSizeTypesX :: VarSet -> PatersonSize -> [Type] -> PatersonSize +pSizeTypesX bvs sz tys = foldr (addPSize . pSizeTypeX bvs) sz tys pSizeTyConApp :: TyCon -> [Type] -> PatersonSize pSizeTyConApp = pSizeTyConAppX emptyVarSet @@ -2470,7 +2468,15 @@ pSizeTyConApp = pSizeTyConAppX emptyVarSet pSizeTyConAppX :: VarSet -> TyCon -> [Type] -> PatersonSize -- Open question: do we count all args, or just the visible ones? -- See Note [Invisible arguments and termination] -pSizeTyConAppX bvs _tc tys = foldr (addPSize . pSizeTypeX bvs) pSizeOne tys +pSizeTyConAppX bvs tc tys + | isTypeFamilyTyCon tc = pSizeTyFamApp tc + | otherwise = pSizeTypesX bvs pSizeOne tys + +pSizeTyFamApp :: TyCon -> PatersonSize +-- See Note [PatersonSize for type family applications] +pSizeTyFamApp tc + | isStuckTypeFamily tc = pSizeZero + | otherwise = PS_TyFam tc pSizeClassPred :: Class -> [Type] -> PatersonSize pSizeClassPred = pSizeClassPredX emptyVarSet @@ -2480,10 +2486,16 @@ pSizeClassPredX bvs cls tys | isTerminatingClass cls -- See (PS1) in Note [The PatersonSize of a type] = pSizeZero | otherwise - = foldr (addPSize . pSizeTypeX bvs) pSizeOne $ + = pSizeTypesX bvs pSizeOne $ filterOutInvisibleTypes (classTyCon cls) tys -- filterOutInvisibleTypes Yuk! See Note [Invisible arguments and termination] +isStuckTypeFamily :: TyCon -> Bool +-- Special "stuck" type familes do not reduce to anything +isStuckTypeFamily tc + = tc `hasKey` errorMessageTypeErrorFamKey + || tc `hasKey` anyTyConKey + -- | When this says "True", ignore this class constraint during -- a termination check -- See (PS1) in Note [The PatersonSize of a type] ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -1913,14 +1913,14 @@ mkInstSizeError ps_failure head_pred pred pp_pred = text "constraint" <+> quotes (ppr pred) main_msg = case ps_failure of - PSF_Size -> hang (text "The" <+> pp_pred) - 2 (sep [ text "is no smaller than", text "the" <+> pp_head ]) - PSF_TyVar tvs -> hang (occMsg tvs) - 2 (sep [ text "in the" <+> pp_pred - , text "than in the" <+> pp_head ]) PSF_TyFam tc -> -- See (PC3) of Note [Paterson conditions] hang (text "Illegal use of type family" <+> quotes (ppr tc)) 2 (text "in the" <+> pp_pred) + PSF_TyVar tvs -> hang (occMsg tvs) + 2 (sep [ text "in the" <+> pp_pred + , text "than in the" <+> pp_head ]) + PSF_Size -> hang (text "The" <+> pp_pred) + 2 (sep [ text "is no smaller than", text "the" <+> pp_head ]) occMsg :: [TyVar] -> SDoc occMsg tvs = text "Variable" <> plural tvs <+> quotes (pprWithCommas ppr tvs) @@ -2149,10 +2149,10 @@ checkFamInstRhs :: TyCon -> [Type] -- LHS checkFamInstRhs lhs_tc lhs_tys famInsts = mapMaybe check famInsts where - lhs_size = pSizeTyConApp lhs_tc lhs_tys + lhs_size = pSizeTypes lhs_tys check (tc, tys) - | let call_size = pSizeTyConApp tc tys - , Just ps_failure <- call_size `ltPatersonSize` lhs_size + | not (stuckTypeFamily tc) + , Just ps_failure <- pSizeTypes tys `ltPatersonSize` lhs_size = Just $ mkFamSizeError ps_failure (TyConApp lhs_tc lhs_tys) (TyConApp tc tys) | otherwise = Nothing @@ -2167,14 +2167,14 @@ mkFamSizeError ps_failure lhs fam_call pp_call = text "type-family application" <+> quotes (ppr fam_call) main_msg = case ps_failure of - PSF_Size -> hang (text "The" <+> pp_call) - 2 (sep [ text "is no smaller than", text "the" <+> pp_lhs ]) - PSF_TyVar tvs -> hang (occMsg tvs) - 2 (sep [ text "in the" <+> pp_call - , text "than in the" <+> pp_lhs ]) PSF_TyFam tc -> -- See (PC3) of Note [Paterson conditions] hang (text "Illegal nested use of type family" <+> quotes (ppr tc)) 2 (text "in the arguments of the" <+> pp_call) + PSF_TyVar tvs -> hang (occMsg tvs) + 2 (sep [ text "in the" <+> pp_call + , text "than in the" <+> pp_lhs ]) + PSF_Size -> hang (text "The" <+> pp_call) + 2 (sep [ text "is no smaller than", text "the" <+> pp_lhs ]) ----------------- checkFamPatBinders :: TyCon ===================================== testsuite/tests/indexed-types/should_fail/TyFamUndec.stderr ===================================== @@ -1,4 +1,17 @@ +TyFamUndec.hs:6:15: error: + • Variable ‘b’ occurs more often + in the type-family application ‘T (b, b)’ + than in the LHS of the family instance ‘T (a, [b])’ + (Use UndecidableInstances to permit this) + • In the type instance declaration for ‘T’ + +TyFamUndec.hs:7:15: error: + • The type-family application ‘T (a, Maybe b)’ + is no smaller than the LHS of the family instance ‘T (a, Maybe b)’ + (Use UndecidableInstances to permit this) + • In the type instance declaration for ‘T’ + TyFamUndec.hs:8:15: error: • Illegal nested use of type family ‘T’ in the arguments of the type-family application ‘T (a, T b)’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5096877337cc23f64d25d70ba399b93d804e8258 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5096877337cc23f64d25d70ba399b93d804e8258 You're receiving 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 Jan 3 16:53:28 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 03 Jan 2023 11:53:28 -0500 Subject: [Git][ghc/ghc][ghc-9.6] 3 commits: head.hackage: Use slow-validate bindist for linting jobs Message-ID: <63b45d88d4048_2a26f52aa67bb823445a0@gitlab.mail> Matthew Pickering pushed to branch ghc-9.6 at Glasgow Haskell Compiler / GHC Commits: 5bc8709e by Matthew Pickering at 2023-01-03T16:52:35+00:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. (cherry picked from commit cbaebfb9d03d01f15eb6bbeee584a70fc09a15c4) - - - - - fdf71893 by Matthew Pickering at 2023-01-03T16:52:41+00:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) (cherry picked from commit f4850f365cee3d9030a61132931f4aba51f7e52a) - - - - - ad8f5f60 by Matthew Pickering at 2023-01-03T16:52:56+00:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. (cherry picked from commit c264b06b4e77976939386a6d373d00118562c376) - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -481,7 +481,6 @@ abi-test-nightly: - out rules: - if: $NIGHTLY - - if: '$RELEASE_JOB == "yes"' ############################################################ # Packaging @@ -679,19 +678,21 @@ test-bootstrap: # access to an unprivileged access token with the ability to query the ghc/ghc # project such that it can find the job ID of the fedora33 job for the current # pipeline. +# +# hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. +# Runs head.hackage with -dlint and a slow-validate bindist +# +# hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate +# head.hackage build with -dlint. +# +# nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. +# +# nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. +# +# release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. .hackage: stage: testing - needs: - - job: x86_64-linux-fedora33-release - optional: true - artifacts: false - - job: nightly-x86_64-linux-fedora33-release - optional: true - artifacts: false - - job: release-x86_64-linux-fedora33-release - optional: true - artifacts: false variables: UPSTREAM_PROJECT_PATH: "$CI_PROJECT_PATH" UPSTREAM_PROJECT_ID: "$CI_PROJECT_ID" @@ -699,34 +700,60 @@ test-bootstrap: RELEASE_JOB: "$RELEASE_JOB" trigger: project: "ghc/head.hackage" - branch: "master" + branch: "upstream-testing" strategy: "depend" hackage-lint: + needs: + - job: x86_64-linux-deb10-numa-slow-validate + optional: true + artifacts: false + - job: nightly-x86_64-linux-deb10-numa-slow-validate + optional: true + artifacts: false extends: .hackage variables: - EXTRA_HC_OPTS: "-dcore-lint" + SLOW_VALIDATE: 1 + EXTRA_HC_OPTS: "-dlint" + # No for release jobs because there isn't a slow-valdate bindist. There is an + # automatic pipeline for release bindists (see release-hackage-lint) + rules: + - if: '$RELEASE_JOB != "yes"' when: manual hackage-label-lint: + needs: + - job: x86_64-linux-deb10-numa-slow-validate + optional: true + artifacts: false extends: .hackage variables: - EXTRA_HC_OPTS: "-dcore-lint" + SLOW_VALIDATE: 1 + EXTRA_HC_OPTS: "-dlint" rules: - if: '$CI_MERGE_REQUEST_LABELS =~ /.*user-facing.*/' -# The head.hackage job is split into two jobs because enabling `-dcore-lint` +# The head.hackage job is split into two jobs because enabling `-dlint` # affects the total allocation numbers for the simplifier portion significantly. nightly-hackage-lint: + needs: + - job: nightly-x86_64-linux-deb10-numa-slow-validate + optional: true + artifacts: false rules: - if: $NIGHTLY variables: NIGHTLY: "$NIGHTLY" extends: .hackage variables: - EXTRA_HC_OPTS: "-dcore-lint" + SLOW_VALIDATE: 1 + EXTRA_HC_OPTS: "-dlint" nightly-hackage-perf: + needs: + - job: nightly-x86_64-linux-fedora33-release + optional: true + artifacts: false rules: - if: $NIGHTLY variables: @@ -738,6 +765,18 @@ nightly-hackage-perf: # Ask head.hackage to generate eventlogs EVENTLOGGING: 1 +release-hackage-lint: + needs: + - job: release-x86_64-linux-fedora33-release + optional: true + artifacts: false + rules: + - if: '$RELEASE_JOB == "yes"' + extends: .hackage + variables: + # No slow-validate bindist on release pipeline + EXTRA_HC_OPTS: "-dlint" + ############################################################ # Nofib testing # (Disabled: See #21859) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fb22372ee9b80b1b77ccbc3f3f994214a7efbe6f...ad8f5f60407b57747c66c59643dd714e52617020 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fb22372ee9b80b1b77ccbc3f3f994214a7efbe6f...ad8f5f60407b57747c66c59643dd714e52617020 You're receiving 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 Jan 3 16:56:49 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 03 Jan 2023 11:56:49 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: hadrian: Ensure that linker scripts are used when merging objects Message-ID: <63b45e51bb9e0_2a26f5527102356537@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Bodigrim at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 5cff237e by Facundo Domínguez at 2023-01-03T11:56:33-05:00 Explain the auxiliary functions of permutations - - - - - 14 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 - hadrian/src/Flavour.hs - libraries/base/Data/OldList.hs - libraries/ghc-prim/GHC/Classes.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 ===================================== @@ -738,6 +738,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) {- ************************************************************************ ===================================== hadrian/src/Flavour.hs ===================================== @@ -193,8 +193,12 @@ splitSectionsIf 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" + pkgPredicate pkg ? mconcat -- Only apply to these packages + [ builder (Ghc CompileHs) ? arg "-split-sections" + , builder MergeObjects ? ifM (expr isWinTarget) + (pure ["-t", "driver/utils/merge_sections_pe.ld"]) + (pure ["-t", "driver/utils/merge_sections.ld"]) + ] -- | Like 'splitSectionsIf', but with a fixed predicate: use -- split sections for all packages but the GHC library. ===================================== libraries/base/Data/OldList.hs ===================================== @@ -1266,15 +1266,42 @@ permutations :: [a] -> [[a]] -- Related discussions: -- * https://mail.haskell.org/pipermail/haskell-cafe/2021-December/134920.html -- * https://mail.haskell.org/pipermail/libraries/2007-December/008788.html +-- +-- Verification of the equivalences of the auxiliary functions with Liquid Haskell: +-- https://github.com/ucsd-progsys/liquidhaskell/blob/b86fb5b/tests/ple/pos/Permutations.hs permutations xs0 = xs0 : perms xs0 [] where + -- | @perms ts is@ is equivalent to + -- + -- > concat + -- > [ interleave {(ts!!n)} {(drop (n+1)} ts) xs [] + -- > | n <- [0..length ts - 1] + -- > , xs <- permutations (reverse (take n ts) ++ is) + -- > ] + -- + -- @{(ts!!n)}@ and @{(drop (n+1)}@ denote the values of variables @t@ and @ts@ which + -- appear free in the definition of @interleave@ and @interleave'@. perms :: forall a. [a] -> [a] -> [[a]] perms [] _ = [] perms (t:ts) is = foldr interleave (perms ts (t:is)) (permutations is) where + -- @interleave {t} {ts} xs r@ is equivalent to + -- + -- > [ insertAt n t xs ++ ts | n <- [0..length xs - 1] ] ++ r + -- + -- where + -- + -- > insertAt n y xs = take n xs ++ y : drop n xs + -- interleave :: [a] -> [[a]] -> [[a]] interleave xs r = let (_,zs) = interleave' id xs r in zs + -- @interleave' f ys r@ is equivalent to + -- + -- > ( ys ++ ts + -- > , [ f (insertAt n t ys ++ ts) | n <- [0..length ys - 1] ] ++ r + -- > ) + -- interleave' :: ([a] -> b) -> [a] -> [b] -> ([a], [b]) interleave' _ [] r = (ts, r) interleave' f (y:ys) r = let (us,zs) = interleave' (f . (y:)) ys r ===================================== libraries/ghc-prim/GHC/Classes.hs ===================================== @@ -410,19 +410,7 @@ instance Ord Char where (C# c1) <= (C# c2) = isTrue# (c1 `leChar#` c2) (C# c1) < (C# c2) = isTrue# (c1 `ltChar#` c2) --- | Note that due to the presence of @NaN@, `Float`'s 'Ord' instance does not --- satisfy reflexivity. --- --- >>> 0/0 <= (0/0 :: Float) --- False --- --- Also note that, due to the same, `Ord`'s operator interactions are not --- respected by `Float`'s instance: --- --- >>> (0/0 :: Float) > 1 --- False --- >>> compare (0/0 :: Float) 1 --- GT +-- | See @instance@ 'Ord' 'Double' for discussion of deviations from IEEE 754 standard. instance Ord Float where (F# x) `compare` (F# y) = if isTrue# (x `ltFloat#` y) then LT @@ -434,19 +422,38 @@ instance Ord Float where (F# x) >= (F# y) = isTrue# (x `geFloat#` y) (F# x) > (F# y) = isTrue# (x `gtFloat#` y) --- | Note that due to the presence of @NaN@, `Double`'s 'Ord' instance does not --- satisfy reflexivity. +-- | IEEE 754 'Double'-precision type includes not only numbers, but also +-- positive and negative infinities and a special element called @NaN@ +-- (which can be quiet or signal). -- --- >>> 0/0 <= (0/0 :: Double) --- False +-- IEEE 754-2008, section 5.11 requires that if at least one of arguments of +-- '<=', '<', '>', '>=' is @NaN@ then the result of the comparison is 'False', +-- and @instance@ 'Ord' 'Double' complies with this requirement. This violates +-- the reflexivity: both @NaN@ '<=' @NaN@ and @NaN@ '>=' @NaN@ are 'False'. -- --- Also note that, due to the same, `Ord`'s operator interactions are not --- respected by `Double`'s instance: +-- IEEE 754-2008, section 5.10 defines @totalOrder@ predicate. Unfortunately, +-- 'compare' on 'Double's violates the IEEE standard and does not define a total order. +-- More specifically, both 'compare' @NaN@ @x@ and 'compare' @x@ @NaN@ always return 'GT'. +-- +-- Thus, users must be extremely cautious when using @instance@ 'Ord' 'Double'. +-- For instance, one should avoid ordered containers with keys represented by 'Double', +-- because data loss and corruption may happen. An IEEE-compliant 'compare' is available +-- in @fp-ieee@ package as @TotallyOrdered@ newtype. +-- +-- Moving further, the behaviour of 'min' and 'max' with regards to @NaN@ is +-- also non-compliant. IEEE 754-2008, section 5.3.1 defines that quiet @NaN@ +-- should be treated as a missing data by @minNum@ and @maxNum@ functions, +-- for example, @minNum(NaN, 1) = minNum(1, NaN) = 1 at . Some languages such as Java +-- deviate from the standard implementing @minNum(NaN, 1) = minNum(1, NaN) = NaN at . +-- However, 'min' / 'max' in @base@ are even worse: 'min' @NaN@ 1 is 1, but 'min' 1 @NaN@ +-- is @NaN at . +-- +-- IEEE 754-2008 compliant 'min' / 'max' can be found in @ieee754@ package under +-- @minNum@ / @maxNum@ names. Implementations compliant with +-- @minimumNumber@ / @maximumNumber@ from a newer +-- [IEEE 754-2019](https://grouper.ieee.org/groups/msc/ANSI_IEEE-Std-754-2019/background/), +-- section 9.6 are available from @fp-ieee@ package. -- --- >>> (0/0 :: Double) > 1 --- False --- >>> compare (0/0 :: Double) 1 --- GT instance Ord Double where (D# x) `compare` (D# y) = if isTrue# (x <## y) then LT View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f83ce115bdc3410960d8c286fe8df232270ea748...5cff237e9736ed069b1e9222ed130f7881662c8a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f83ce115bdc3410960d8c286fe8df232270ea748...5cff237e9736ed069b1e9222ed130f7881662c8a You're receiving 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 Jan 3 17:44:01 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 03 Jan 2023 12:44:01 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/22426 Message-ID: <63b46961a0243_2a26f5a43d37c8243636d@gitlab.mail> Matthew Pickering pushed new branch wip/22426 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/22426 You're receiving 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 Jan 3 17:46:23 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 03 Jan 2023 12:46:23 -0500 Subject: [Git][ghc/ghc][wip/22426] darwin: Always pass -no_fixup_chains to linker Message-ID: <63b469ef28fa1_2a26f5237be300243658e@gitlab.mail> Matthew Pickering pushed to branch wip/22426 at Glasgow Haskell Compiler / GHC Commits: 85a3348f by Matthew Pickering at 2023-01-03T17:46:01+00:00 darwin: Always pass -no_fixup_chains to linker Recent versions of MacOS use a version of ld where `-fixup_chain` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chain` by passing `-no_fixup_chain` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 - - - - - 1 changed file: - compiler/GHC/SysTools/Info.hs Changes: ===================================== compiler/GHC/SysTools/Info.hs ===================================== @@ -136,7 +136,8 @@ getLinkerInfo' logger dflags = do -- Darwin has neither GNU Gold or GNU LD, but a strange linker -- that doesn't support --version. We can just assume that's -- what we're using. - return $ DarwinLD [] + -- See Note [Dynamic lookup and chained fixups] + return $ DarwinLD ["-Wl,-no_fixup_chains"] OSMinGW32 -> -- GHC doesn't support anything but GNU ld on Windows anyway. -- Process creation is also fairly expensive on win32, so @@ -236,3 +237,27 @@ getCompilerInfo' logger pgm = do text "Make sure you're using GNU gcc, or clang" return UnknownCC ) + +{- +Note [Dynamic lookup and chained fixups] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Recent versions of MacOS use a version of ld where `-fixup_chain` is on by default. +This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we +explicitly disable `fixup-chain` by passing `-no_fixup_chain` to the linker on +darwin. This results in a warning of the form: + +ld: warning: -undefined dynamic_lookup may not work with chained fixups + +The manual explains the incompatible nature of these two flags: + + -undefined treatment + Specifies how undefined symbols are to be treated. Options are: error, warning, + suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that + depends on lazy binding will not work with chained fixups. + +A relevant ticket is #22429 + +-} + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/85a3348ff72b12eaf87b4048265ac335fe8cdf30 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/85a3348ff72b12eaf87b4048265ac335fe8cdf30 You're receiving 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 Jan 3 18:04:41 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Tue, 03 Jan 2023 13:04:41 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/remove-rts-configure-hack Message-ID: <63b46e398948c_2a26f5a43d37c824461c3@gitlab.mail> John Ericson pushed new branch wip/remove-rts-configure-hack at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/remove-rts-configure-hack You're receiving 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 Jan 3 20:26:52 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 03 Jan 2023 15:26:52 -0500 Subject: [Git][ghc/ghc][wip/T20666] Wibble Message-ID: <63b48f8c6bf31_2a26f5a2ef94602464145@gitlab.mail> Simon Peyton Jones pushed to branch wip/T20666 at Glasgow Haskell Compiler / GHC Commits: e9be1b61 by Simon Peyton Jones at 2023-01-03T20:26:13+00:00 Wibble - - - - - 1 changed file: - compiler/GHC/Tc/Validity.hs Changes: ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -2151,7 +2151,7 @@ checkFamInstRhs lhs_tc lhs_tys famInsts where lhs_size = pSizeTypes lhs_tys check (tc, tys) - | not (stuckTypeFamily tc) + | not (isStuckTypeFamily tc) , Just ps_failure <- pSizeTypes tys `ltPatersonSize` lhs_size = Just $ mkFamSizeError ps_failure (TyConApp lhs_tc lhs_tys) (TyConApp tc tys) | otherwise View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e9be1b61b3132952ce3b7e07a8e42b6f9591a9dc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e9be1b61b3132952ce3b7e07a8e42b6f9591a9dc You're receiving 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 Jan 3 21:36:21 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Tue, 03 Jan 2023 16:36:21 -0500 Subject: [Git][ghc/ghc][wip/remove-rts-configure-hack] Draft: Remove RTS hack for configuring Message-ID: <63b49fd5d117a_2a26f5563f80f824915f@gitlab.mail> John Ericson pushed to branch wip/remove-rts-configure-hack at Glasgow Haskell Compiler / GHC Commits: e9cc3e5e by John Ericson at 2023-01-03T16:36:11-05:00 Draft: Remove RTS hack for configuring I expect this to fail on macOS. - - - - - 2 changed files: - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Rules/Register.hs Changes: ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -148,6 +148,8 @@ configurePackage context at Context {..} = do -- Figure out what hooks we need. hooks <- case C.buildType (C.flattenPackageDescription gpd) of C.Configure -> pure C.autoconfUserHooks + C.Simple -> pure C.simpleUserHooks + C.Make -> fail "build-type: Make is not supported" -- The 'time' package has a 'C.Custom' Setup.hs, but it's actually -- 'C.Configure' plus a @./Setup test@ hook. However, Cabal is also -- 'C.Custom', but doesn't have a configure script. @@ -155,12 +157,6 @@ configurePackage context at Context {..} = do configureExists <- doesFileExist $ replaceFileName (pkgCabalFile package) "configure" pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks - -- Not quite right, but good enough for us: - _ | package == rts -> - -- Don't try to do post configuration validation for 'rts'. This - -- will simply not work, due to the @ld-options@ and @Stg.h at . - pure $ C.simpleUserHooks { C.postConf = \_ _ _ _ -> return () } - | otherwise -> pure C.simpleUserHooks -- Compute the list of flags, and the Cabal configuration arguments flavourArgs <- args <$> flavour ===================================== hadrian/src/Rules/Register.hs ===================================== @@ -45,6 +45,14 @@ configurePackageRules = do isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend when isGmp $ need [buildP -/- "include/ghc-gmp.h"] + when (pkg == rts) $ do + -- Rts.h is a header listed in the cabal file, and configuring + -- therefore wants to ensure that the header "works" post-configure. + -- But it (transitively) includes these, so we must ensure they exist + -- for that check to work. + need [ buildP -/- "include/ghcautoconf.h" + , buildP -/- "include/ghcplatform.h" + ] Cabal.configurePackage ctx root -/- "**/autogen/cabal_macros.h" %> \out -> do View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e9cc3e5ed021db499e760d3b78cf9d2410ee5798 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e9cc3e5ed021db499e760d3b78cf9d2410ee5798 You're receiving 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 Jan 3 23:04:26 2023 From: gitlab at gitlab.haskell.org (Tamar Christina (@Phyx)) Date: Tue, 03 Jan 2023 18:04:26 -0500 Subject: [Git][ghc/ghc][wip/T22166] linker: Fix BFD import libraries Message-ID: <63b4b47a8ece_2a26f5237be3002511529@gitlab.mail> Tamar Christina pushed to branch wip/T22166 at Glasgow Haskell Compiler / GHC Commits: 4f9eecf5 by Tamar Christina at 2023-01-03T23:03:12+00:00 linker: Fix BFD import libraries This commit fixes the BFD style import library support in the runtime linker. This was accidentally broken during the refactoring to clang and went unnoticed because clang itself is unable to generate the BFD style import libraries. With this change we can not link against both GCC or Clang produced libraries again and intermix code produced by both compilers. - - - - - 10 changed files: - hadrian/src/Settings/Packages.hs - libraries/base/System/Posix/Internals.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 - testsuite/tests/rts/all.T Changes: ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -404,7 +404,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 ===================================== libraries/base/System/Posix/Internals.hs ===================================== @@ -904,6 +904,7 @@ foreign import capi unsafe "stdio.h value SEEK_END" sEEK_END :: CInt {- Note [Windows types] +~~~~~~~~~~~~~~~~~~~~ Windows' _read and _write have types that differ from POSIX. They take an unsigned int for length and return a signed int where POSIX uses size_t and ===================================== 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 ===================================== @@ -54,11 +54,16 @@ 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]. */ + * to process overflowing relocations. See Note [Processing overflowed relocations]. + * This is bitfield however only the option SYM_TYPE_DUP_DISCARD can be combined + * with the other values. */ 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 ===================================== testsuite/tests/rts/all.T ===================================== @@ -410,7 +410,7 @@ test('T10296b', [only_ways(['threaded2'])], compile_and_run, ['']) test('numa001', [ extra_run_opts('8'), unless(unregisterised(), extra_ways(['debug_numa'])) ] , compile_and_run, ['']) -test('T12497', [ unless(opsys('mingw32'), skip) +test('T12497', [ unless(opsys('mingw32'), skip), expect_broken(22694) ], makefile_test, ['T12497']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f9eecf55fb9c10334478859dd87da76481252e9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f9eecf55fb9c10334478859dd87da76481252e9 You're receiving 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 Jan 4 04:27:00 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 03 Jan 2023 23:27:00 -0500 Subject: [Git][ghc/ghc][master] Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Message-ID: <63b5001493791_2a26f5237be3002527961@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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 ===================================== @@ -738,6 +738,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/62b9a7b23b20f5cf0a2de14251c2096098009f10 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/62b9a7b23b20f5cf0a2de14251c2096098009f10 You're receiving 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 Jan 4 04:27:46 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 03 Jan 2023 23:27:46 -0500 Subject: [Git][ghc/ghc][master] Explain the auxiliary functions of permutations Message-ID: <63b50042ce26b_2a26f5527102531488@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 1 changed file: - libraries/base/Data/OldList.hs Changes: ===================================== libraries/base/Data/OldList.hs ===================================== @@ -1266,15 +1266,42 @@ permutations :: [a] -> [[a]] -- Related discussions: -- * https://mail.haskell.org/pipermail/haskell-cafe/2021-December/134920.html -- * https://mail.haskell.org/pipermail/libraries/2007-December/008788.html +-- +-- Verification of the equivalences of the auxiliary functions with Liquid Haskell: +-- https://github.com/ucsd-progsys/liquidhaskell/blob/b86fb5b/tests/ple/pos/Permutations.hs permutations xs0 = xs0 : perms xs0 [] where + -- | @perms ts is@ is equivalent to + -- + -- > concat + -- > [ interleave {(ts!!n)} {(drop (n+1)} ts) xs [] + -- > | n <- [0..length ts - 1] + -- > , xs <- permutations (reverse (take n ts) ++ is) + -- > ] + -- + -- @{(ts!!n)}@ and @{(drop (n+1)}@ denote the values of variables @t@ and @ts@ which + -- appear free in the definition of @interleave@ and @interleave'@. perms :: forall a. [a] -> [a] -> [[a]] perms [] _ = [] perms (t:ts) is = foldr interleave (perms ts (t:is)) (permutations is) where + -- @interleave {t} {ts} xs r@ is equivalent to + -- + -- > [ insertAt n t xs ++ ts | n <- [0..length xs - 1] ] ++ r + -- + -- where + -- + -- > insertAt n y xs = take n xs ++ y : drop n xs + -- interleave :: [a] -> [[a]] -> [[a]] interleave xs r = let (_,zs) = interleave' id xs r in zs + -- @interleave' f ys r@ is equivalent to + -- + -- > ( ys ++ ts + -- > , [ f (insertAt n t ys ++ ts) | n <- [0..length ys - 1] ] ++ r + -- > ) + -- interleave' :: ([a] -> b) -> [a] -> [b] -> ([a], [b]) interleave' _ [] r = (ts, r) interleave' f (y:ys) r = let (us,zs) = interleave' (f . (y:)) ys r View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/21bedd84f2cde6aa17d09c610a2a309f3e2a7f10 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/21bedd84f2cde6aa17d09c610a2a309f3e2a7f10 You're receiving 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 Jan 4 09:40:43 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 04 Jan 2023 04:40:43 -0500 Subject: [Git][ghc/ghc][wip/T20666] 3 commits: Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Message-ID: <63b5499beeb17_2a26f5a2ef9460257884b@gitlab.mail> Simon Peyton Jones pushed to branch wip/T20666 at Glasgow Haskell Compiler / GHC Commits: 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 0b030883 by Richard Eisenberg at 2023-01-04T09:41:08+00:00 Refactor the treatment of loopy superclass dicts This patch completely re-engineers how we deal with loopy superclass dictionaries in instance declarations. It fixes #20666. The highlights are * Recognise that the loopy-superclass business should use precisely the Paterson conditions. This is much much nicer. See Note [Recursive superclasses] in GHC.Tc.TyCl.Instance * With that in mind, define "Paterson-smaller" in Note [Paterson conditions] in GHC.Tc.Validity, and the new data type `PatersonSize` in GHC.Tc.Utils.TcType, along with functions to compute and compare PatsonSizes * Use the new PatersonSize stuff when solving superclass constraints See Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance * In GHC.Tc.Solver.Monad.lookupInInerts, add a missing call to prohibitedSuperClassSolve. This was the original cause of #20666. * Treat (TypeError "stuff") as having PatersonSize zero. See Note [Paterson size for type family applications] in GHC.Tc.Utils.TcType. - - - - - 30 changed files: - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Data/EnumSet.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/DocString.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Infer.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/InertSet.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types/Constraint.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/Tc/Validity.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 The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e9be1b61b3132952ce3b7e07a8e42b6f9591a9dc...0b030883233c58c90db3fbe27d1290a80aa3592a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e9be1b61b3132952ce3b7e07a8e42b6f9591a9dc...0b030883233c58c90db3fbe27d1290a80aa3592a You're receiving 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 Jan 4 10:22:17 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 04 Jan 2023 05:22:17 -0500 Subject: [Git][ghc/ghc][wip/22426] 2 commits: Only store Name in FunRhs rather than Id with knot-tied fields Message-ID: <63b55359b3107_2a26f5a2ef94602587771@gitlab.mail> Matthew Pickering pushed to branch wip/22426 at Glasgow Haskell Compiler / GHC Commits: e9821db3 by Matthew Pickering at 2023-01-03T12:36:05+00:00 Only store Name in FunRhs rather than Id with knot-tied fields The Note [fixM for rhs_ty in tcMonoBinds] explains that certain fields of the Id created here are knot-tied and can't be referenced inside the scope of the fixM. The modification to `FunRhs` ensures that we can't accidentally force the knot-tied fields of the `Id`. The `Name` is just used for error messages and printing. The result is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. Fixes #22695 - - - - - d9d85365 by Matthew Pickering at 2023-01-04T10:21:48+00:00 darwin: Always pass -no_fixup_chain to linker Recent versions of MacOS use a version of ld where `-fixup_chain` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chain` by passing `-no_fixup_chain` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 - - - - - 11 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/SysTools/Info.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/Language/Haskell/Syntax/Expr.hs - + testsuite/tests/ghci/scripts/T22695.script - + testsuite/tests/ghci/scripts/T22695.stderr - testsuite/tests/ghci/scripts/all.T - testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -2002,7 +2002,7 @@ matchSeparator ThPatSplice = panic "unused" matchSeparator ThPatQuote = panic "unused" matchSeparator PatSyn = panic "unused" -pprMatchContext :: (Outputable (IdP p), UnXRec p) +pprMatchContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContext ctxt | want_an ctxt = text "an" <+> pprMatchContextNoun ctxt @@ -2013,10 +2013,10 @@ pprMatchContext ctxt want_an (ArrowMatchCtxt KappaExpr) = True want_an _ = False -pprMatchContextNoun :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNoun :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNoun (FunRhs {mc_fun=fun}) = text "equation for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNoun CaseAlt = text "case alternative" pprMatchContextNoun (LamCaseAlt lc_variant) = lamCaseKeyword lc_variant <+> text "alternative" @@ -2032,10 +2032,10 @@ pprMatchContextNoun (StmtCtxt ctxt) = text "pattern binding in" $$ pprAStmtContext ctxt pprMatchContextNoun PatSyn = text "pattern synonym declaration" -pprMatchContextNouns :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNouns :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNouns (FunRhs {mc_fun=fun}) = text "equations for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNouns PatBindGuards = text "pattern binding guards" pprMatchContextNouns (ArrowMatchCtxt c) = pprArrowMatchContextNouns c pprMatchContextNouns (StmtCtxt ctxt) = text "pattern bindings in" @@ -2056,7 +2056,7 @@ pprArrowMatchContextNouns (ArrowLamCaseAlt lc_variant) = lamCaseKeyword lc_varia pprArrowMatchContextNouns ctxt = pprArrowMatchContextNoun ctxt <> char 's' ----------------- -pprAStmtContext, pprStmtContext :: (Outputable (IdP p), UnXRec p) +pprAStmtContext, pprStmtContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsStmtContext p -> SDoc pprAStmtContext (HsDoStmt flavour) = pprAHsDoFlavour flavour pprAStmtContext ctxt = text "a" <+> pprStmtContext ctxt ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -863,7 +863,7 @@ mkSimpleGeneratedFunBind loc fun pats expr emptyLocalBinds] -- | Make a prefix, non-strict function 'HsMatchContext' -mkPrefixFunRhs :: LIdP p -> HsMatchContext p +mkPrefixFunRhs :: LIdP (NoGhcTc p) -> HsMatchContext p mkPrefixFunRhs n = FunRhs { mc_fun = n , mc_fixity = Prefix , mc_strictness = NoSrcStrict } ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -957,7 +957,7 @@ instance HiePass p => ToHie (HsMatchContext (GhcPass p)) where name' :: LocatedN Name name' = case hiePass @p of HieRn -> name - HieTc -> fmap varName name + HieTc -> name toHie (StmtCtxt a) = toHie a toHie _ = pure [] ===================================== compiler/GHC/SysTools/Info.hs ===================================== @@ -136,7 +136,8 @@ getLinkerInfo' logger dflags = do -- Darwin has neither GNU Gold or GNU LD, but a strange linker -- that doesn't support --version. We can just assume that's -- what we're using. - return $ DarwinLD [] + -- See Note [Dynamic lookup and chained fixups] + return $ DarwinLD ["-Wl,-no_fixup_chains"] OSMinGW32 -> -- GHC doesn't support anything but GNU ld on Windows anyway. -- Process creation is also fairly expensive on win32, so @@ -236,3 +237,27 @@ getCompilerInfo' logger pgm = do text "Make sure you're using GNU gcc, or clang" return UnknownCC ) + +{- +Note [Dynamic lookup and chained fixups] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Recent versions of MacOS use a version of ld where `-fixup_chain` is on by default. +This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we +explicitly disable `fixup-chain` by passing `-no_fixup_chain` to the linker on +darwin. This results in a warning of the form: + +ld: warning: -undefined dynamic_lookup may not work with chained fixups + +The manual explains the incompatible nature of these two flags: + + -undefined treatment + Specifies how undefined symbols are to be treated. Options are: error, warning, + suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that + depends on lazy binding will not work with chained fixups. + +A relevant ticket is #22429 + +-} + + ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -127,12 +127,7 @@ tcMatchesFun fun_id matches exp_ty herald = ExpectedFunTyMatches (NameThing fun_name) matches ctxt = GenSigCtxt -- Was: FunSigCtxt fun_name True -- But that's wrong for f :: Int -> forall a. blah - what = FunRhs { mc_fun = fun_id, mc_fixity = Prefix, mc_strictness = strictness } - -- Careful: this fun_id could be an unfilled - -- thunk from fixM in tcMonoBinds, so we're - -- not allowed to look at it, except for - -- idName. - -- See Note [fixM for rhs_ty in tcMonoBinds] + what = FunRhs { mc_fun = idName <$> fun_id, mc_fixity = Prefix, mc_strictness = strictness } match_ctxt = MC { mc_what = what, mc_body = tcBody } strictness | [L _ match] <- unLoc $ mg_alts matches ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -838,7 +838,7 @@ tcPatSynMatcher (L loc ps_name) lpat prag_fn args body] , mg_ext = MatchGroupTc (map unrestricted [pat_ty, cont_ty, fail_ty]) res_ty Generated } - match = mkMatch (mkPrefixFunRhs (L loc patsyn_id)) [] + match = mkMatch (mkPrefixFunRhs (L loc (idName patsyn_id))) [] (mkHsLams (rr_tv:res_tv:univ_tvs) req_dicts body') (EmptyLocalBinds noExtField) ===================================== compiler/Language/Haskell/Syntax/Expr.hs ===================================== @@ -1533,7 +1533,7 @@ data HsMatchContext p = FunRhs -- ^ A pattern matching on an argument of a -- function binding - { mc_fun :: LIdP p -- ^ function binder of @f@ + { mc_fun :: LIdP (NoGhcTc p) -- ^ function binder of @f@ , mc_fixity :: LexicalFixity -- ^ fixing of @f@ , mc_strictness :: SrcStrictness -- ^ was @f@ banged? -- See Note [FunBind vs PatBind] ===================================== testsuite/tests/ghci/scripts/T22695.script ===================================== @@ -0,0 +1 @@ +test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/T22695.stderr ===================================== @@ -0,0 +1,8 @@ + +:1:10: error: + • The constructor ‘Just’ should have 1 argument, but has been given none + • In the pattern: Just + In a stmt of a pattern guard for + an equation for ‘test’: + Just <- x + In an equation for ‘test’: test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -370,3 +370,4 @@ test('T21110', [extra_files(['T21110A.hs'])], ghci_script, test('T17830', [filter_stdout_lines(r'======.*')], ghci_script, ['T17830.script']) test('T21294a', normal, ghci_script, ['T21294a.script']) test('T21507', normal, ghci_script, ['T21507.script']) +test('T22695', normal, ghci_script, ['T22695.script']) ===================================== testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr ===================================== @@ -1560,7 +1560,7 @@ (FunRhs (L (SrcSpanAnn (EpAnnNotUsed) { DumpTypecheckedAst.hs:19:1-4 }) - {Var: main}) + {Name: main}) (Prefix) (NoSrcStrict)) [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/85a3348ff72b12eaf87b4048265ac335fe8cdf30...d9d85365458f6c8ecea937b6dffa77b09d9e2123 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/85a3348ff72b12eaf87b4048265ac335fe8cdf30...d9d85365458f6c8ecea937b6dffa77b09d9e2123 You're receiving 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 Jan 4 10:27:26 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 04 Jan 2023 05:27:26 -0500 Subject: [Git][ghc/ghc][wip/22426] darwin: Always pass -no_fixup_chain to linker Message-ID: <63b5548e398ea_2a26f55271025881f8@gitlab.mail> Matthew Pickering pushed to branch wip/22426 at Glasgow Haskell Compiler / GHC Commits: 84df1f21 by Matthew Pickering at 2023-01-04T10:27:18+00:00 darwin: Always pass -no_fixup_chain to linker Recent versions of MacOS use a version of ld where `-fixup_chain` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chain` by passing `-no_fixup_chain` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 - - - - - 1 changed file: - compiler/GHC/SysTools/Info.hs Changes: ===================================== compiler/GHC/SysTools/Info.hs ===================================== @@ -136,7 +136,8 @@ getLinkerInfo' logger dflags = do -- Darwin has neither GNU Gold or GNU LD, but a strange linker -- that doesn't support --version. We can just assume that's -- what we're using. - return $ DarwinLD [] + -- See Note [Dynamic lookup and chained fixups] + return $ DarwinLD ["-Wl,-no_fixup_chains"] OSMinGW32 -> -- GHC doesn't support anything but GNU ld on Windows anyway. -- Process creation is also fairly expensive on win32, so @@ -236,3 +237,27 @@ getCompilerInfo' logger pgm = do text "Make sure you're using GNU gcc, or clang" return UnknownCC ) + +{- +Note [Dynamic lookup and chained fixups] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Recent versions of MacOS use a version of ld where `-fixup_chain` is on by default. +This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we +explicitly disable `fixup-chain` by passing `-no_fixup_chain` to the linker on +darwin. This results in a warning of the form: + +ld: warning: -undefined dynamic_lookup may not work with chained fixups + +The manual explains the incompatible nature of these two flags: + + -undefined treatment + Specifies how undefined symbols are to be treated. Options are: error, warning, + suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that + depends on lazy binding will not work with chained fixups. + +A relevant ticket is #22429 + +-} + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84df1f217f92eb698188c8371c66c59dca26691c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84df1f217f92eb698188c8371c66c59dca26691c You're receiving 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 Jan 4 10:30:22 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 04 Jan 2023 05:30:22 -0500 Subject: [Git][ghc/ghc][wip/22426] darwin: Always pass -no_fixup_chains to linker Message-ID: <63b5553e95cbf_2a26f52aa67bb82590720@gitlab.mail> Matthew Pickering pushed to branch wip/22426 at Glasgow Haskell Compiler / GHC Commits: fef9849e by Matthew Pickering at 2023-01-04T10:30:16+00:00 darwin: Always pass -no_fixup_chains to linker Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 - - - - - 1 changed file: - compiler/GHC/SysTools/Info.hs Changes: ===================================== compiler/GHC/SysTools/Info.hs ===================================== @@ -136,7 +136,8 @@ getLinkerInfo' logger dflags = do -- Darwin has neither GNU Gold or GNU LD, but a strange linker -- that doesn't support --version. We can just assume that's -- what we're using. - return $ DarwinLD [] + -- See Note [Dynamic lookup and chained fixups] + return $ DarwinLD [Option "-Wl,-no_fixup_chains"] OSMinGW32 -> -- GHC doesn't support anything but GNU ld on Windows anyway. -- Process creation is also fairly expensive on win32, so @@ -236,3 +237,27 @@ getCompilerInfo' logger pgm = do text "Make sure you're using GNU gcc, or clang" return UnknownCC ) + +{- +Note [Dynamic lookup and chained fixups] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. +This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we +explicitly disable `fixup_chains` by passing `-no_fixup_chains` to the linker on +darwin. This results in a warning of the form: + +ld: warning: -undefined dynamic_lookup may not work with chained fixups + +The manual explains the incompatible nature of these two flags: + + -undefined treatment + Specifies how undefined symbols are to be treated. Options are: error, warning, + suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that + depends on lazy binding will not work with chained fixups. + +A relevant ticket is #22429 + +-} + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fef9849e490391139587041f21a5c747e3a07b1c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fef9849e490391139587041f21a5c747e3a07b1c You're receiving 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 Jan 4 11:55:21 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 04 Jan 2023 06:55:21 -0500 Subject: [Git][ghc/ghc][wip/t22695] Only store Name in FunRhs rather than Id with knot-tied fields Message-ID: <63b569295ea25_2a26f5237be30026285ae@gitlab.mail> Matthew Pickering pushed to branch wip/t22695 at Glasgow Haskell Compiler / GHC Commits: f1a7fa8c by Matthew Pickering at 2023-01-04T11:54:05+00:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - 15 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Match.hs-boot - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/Language/Haskell/Syntax/Expr.hs - + testsuite/tests/ghci/scripts/T22695.script - + testsuite/tests/ghci/scripts/T22695.stderr - testsuite/tests/ghci/scripts/all.T - testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -2002,7 +2002,7 @@ matchSeparator ThPatSplice = panic "unused" matchSeparator ThPatQuote = panic "unused" matchSeparator PatSyn = panic "unused" -pprMatchContext :: (Outputable (IdP p), UnXRec p) +pprMatchContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContext ctxt | want_an ctxt = text "an" <+> pprMatchContextNoun ctxt @@ -2013,10 +2013,10 @@ pprMatchContext ctxt want_an (ArrowMatchCtxt KappaExpr) = True want_an _ = False -pprMatchContextNoun :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNoun :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNoun (FunRhs {mc_fun=fun}) = text "equation for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNoun CaseAlt = text "case alternative" pprMatchContextNoun (LamCaseAlt lc_variant) = lamCaseKeyword lc_variant <+> text "alternative" @@ -2032,10 +2032,10 @@ pprMatchContextNoun (StmtCtxt ctxt) = text "pattern binding in" $$ pprAStmtContext ctxt pprMatchContextNoun PatSyn = text "pattern synonym declaration" -pprMatchContextNouns :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNouns :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNouns (FunRhs {mc_fun=fun}) = text "equations for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNouns PatBindGuards = text "pattern binding guards" pprMatchContextNouns (ArrowMatchCtxt c) = pprArrowMatchContextNouns c pprMatchContextNouns (StmtCtxt ctxt) = text "pattern bindings in" @@ -2056,7 +2056,7 @@ pprArrowMatchContextNouns (ArrowLamCaseAlt lc_variant) = lamCaseKeyword lc_varia pprArrowMatchContextNouns ctxt = pprArrowMatchContextNoun ctxt <> char 's' ----------------- -pprAStmtContext, pprStmtContext :: (Outputable (IdP p), UnXRec p) +pprAStmtContext, pprStmtContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsStmtContext p -> SDoc pprAStmtContext (HsDoStmt flavour) = pprAHsDoFlavour flavour pprAStmtContext ctxt = text "a" <+> pprStmtContext ctxt ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -863,7 +863,7 @@ mkSimpleGeneratedFunBind loc fun pats expr emptyLocalBinds] -- | Make a prefix, non-strict function 'HsMatchContext' -mkPrefixFunRhs :: LIdP p -> HsMatchContext p +mkPrefixFunRhs :: LIdP (NoGhcTc p) -> HsMatchContext p mkPrefixFunRhs n = FunRhs { mc_fun = n , mc_fixity = Prefix , mc_strictness = NoSrcStrict } ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -957,7 +957,7 @@ instance HiePass p => ToHie (HsMatchContext (GhcPass p)) where name' :: LocatedN Name name' = case hiePass @p of HieRn -> name - HieTc -> fmap varName name + HieTc -> name toHie (StmtCtxt a) = toHie a toHie _ = pure [] ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -927,14 +927,10 @@ instance Diagnostic TcRnMessage where same_rec_group_msg = text "it is defined and used in the same recursive group" TcRnMatchesHaveDiffNumArgs argsContext (MatchArgMatches match1 bad_matches) -> mkSimpleDecorated $ - (vcat [ pprArgsContext argsContext <+> + (vcat [ pprMatchContextNouns argsContext <+> text "have different numbers of arguments" , nest 2 (ppr (getLocA match1)) , nest 2 (ppr (getLocA (NE.head bad_matches)))]) - where - pprArgsContext = \case - EquationArgs name -> (text "Equations for" <+>) . quotes $ ppr name - PatternArgs matchCtx -> pprMatchContextNouns matchCtx TcRnCannotBindScopedTyVarInPatSig sig_tvs -> mkSimpleDecorated $ hang (text "You cannot bind scoped type variable" ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2094,7 +2094,7 @@ data TcRnMessage where typecheck/should_fail/T20768_fail -} TcRnMatchesHaveDiffNumArgs - :: !MatchArgsContext + :: !(HsMatchContext GhcTc) -- ^ Pattern match specifics -> !MatchArgBadMatches -> TcRnMessage ===================================== compiler/GHC/Tc/Gen/Arrow.hs ===================================== @@ -172,7 +172,6 @@ tc_cmd env in_cmd@(HsCmdCase x scrut matches) (stk, res_ty) tc_cmd env cmd@(HsCmdLamCase x lc_variant match) cmd_ty = addErrCtxt (cmdCtxt cmd) do { let match_ctxt = ArrowLamCaseAlt lc_variant - ; checkPatCounts (ArrowMatchCtxt match_ctxt) match ; (wrap, match') <- tcCmdMatchLambda env match_ctxt match cmd_ty ; return (mkHsCmdWrap wrap (HsCmdLamCase x lc_variant match')) } ===================================== compiler/GHC/Tc/Gen/Bind.hs ===================================== @@ -624,7 +624,7 @@ tcPolyCheck prag_fn -- See Note [Relevant bindings and the binder stack] setSrcSpanA bind_loc $ - tcMatchesFun (L nm_loc mono_id) matches + tcMatchesFun (L nm_loc (idName mono_id)) matches (mkCheckExpType rho_ty) -- We make a funny AbsBinds, abstracting over nothing, @@ -1263,18 +1263,14 @@ tcMonoBinds is_rec sig_fn no_gen | NonRecursive <- is_rec -- ...binder isn't mentioned in RHS , Nothing <- sig_fn name -- ...with no type signature = setSrcSpanA b_loc $ - do { ((co_fn, matches'), mono_id, _) <- fixM $ \ ~(_, _, rhs_ty) -> - -- See Note [fixM for rhs_ty in tcMonoBinds] - do { mono_id <- newLetBndr no_gen name ManyTy rhs_ty - ; (matches', rhs_ty') - <- tcInfer $ \ exp_ty -> + do { ((co_fn, matches'), rhs_ty') + <- tcInfer $ \ exp_ty -> tcExtendBinderStack [TcIdBndr_ExpType name exp_ty NotTopLevel] $ -- We extend the error context even for a non-recursive -- function so that in type error messages we show the -- type of the thing whose rhs we are type checking - tcMatchesFun (L nm_loc mono_id) matches exp_ty - ; return (matches', mono_id, rhs_ty') - } + tcMatchesFun (L nm_loc name) matches exp_ty + ; mono_id <- newLetBndr no_gen name ManyTy rhs_ty' ; return (unitBag $ L b_loc $ FunBind { fun_id = L nm_loc mono_id, @@ -1388,19 +1384,6 @@ correctly elaborate 'id'. But we want to /infer/ q's higher rank type. There seems to be no way to do this. So currently we only switch to inference when we have no signature for any of the binders. -Note [fixM for rhs_ty in tcMonoBinds] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -In order to create mono_id we need rhs_ty but we don't have it yet, -we only get it from tcMatchesFun later (which needs mono_id to put -into HsMatchContext for pretty printing). To solve this, create -a thunk of rhs_ty with fixM that we fill in later. - -This is fine only because neither newLetBndr or tcMatchesFun look -at the varType field of the Id. tcMatchesFun only looks at idName -of mono_id. - -Also see #20415 for the bigger picture of why tcMatchesFun needs -mono_id in the first place. -} @@ -1528,7 +1511,7 @@ tcRhs (TcFunBind info@(MBI { mbi_sig = mb_sig, mbi_mono_id = mono_id }) = tcExtendIdBinderStackForRhs [info] $ tcExtendTyVarEnvForRhs mb_sig $ do { traceTc "tcRhs: fun bind" (ppr mono_id $$ ppr (idType mono_id)) - ; (co_fn, matches') <- tcMatchesFun (L (noAnnSrcSpan loc) mono_id) + ; (co_fn, matches') <- tcMatchesFun (L (noAnnSrcSpan loc) (idName mono_id)) matches (mkCheckExpType $ idType mono_id) ; return ( FunBind { fun_id = L (noAnnSrcSpan loc) mono_id , fun_matches = matches' ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -31,7 +31,6 @@ module GHC.Tc.Gen.Match , tcBody , tcDoStmt , tcGuardStmt - , checkPatCounts ) where @@ -93,12 +92,12 @@ is used in error messages. It checks that all the equations have the same number of arguments before using @tcMatches@ to do the work. -} -tcMatchesFun :: LocatedN Id -- MatchContext Id +tcMatchesFun :: LocatedN Name -- MatchContext Id -> MatchGroup GhcRn (LHsExpr GhcRn) -> ExpRhoType -- Expected type of function -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) -- Returns type of body -tcMatchesFun fun_id matches exp_ty +tcMatchesFun fun_name matches exp_ty = do { -- Check that they all have the same no of arguments -- Location is in the monad, set the caller so that -- any inter-equation error messages get some vaguely @@ -106,9 +105,7 @@ tcMatchesFun fun_id matches exp_ty -- ann-grabbing, because we don't always have annotations in -- hand when we call tcMatchesFun... traceTc "tcMatchesFun" (ppr fun_name $$ ppr exp_ty) - -- We can't easily call checkPatCounts here because fun_id can be an - -- unfilled thunk - ; checkArgCounts fun_name matches + ; checkArgCounts what matches ; matchExpectedFunTys herald ctxt arity exp_ty $ \ pat_tys rhs_ty -> -- NB: exp_type may be polymorphic, but @@ -122,17 +119,11 @@ tcMatchesFun fun_id matches exp_ty -- a multiplicity argument, and scale accordingly. tcMatches match_ctxt pat_tys rhs_ty matches } where - fun_name = idName (unLoc fun_id) arity = matchGroupArity matches - herald = ExpectedFunTyMatches (NameThing fun_name) matches + herald = ExpectedFunTyMatches (NameThing (unLoc fun_name)) matches ctxt = GenSigCtxt -- Was: FunSigCtxt fun_name True -- But that's wrong for f :: Int -> forall a. blah - what = FunRhs { mc_fun = fun_id, mc_fixity = Prefix, mc_strictness = strictness } - -- Careful: this fun_id could be an unfilled - -- thunk from fixM in tcMonoBinds, so we're - -- not allowed to look at it, except for - -- idName. - -- See Note [fixM for rhs_ty in tcMonoBinds] + what = FunRhs { mc_fun = fun_name, mc_fixity = Prefix, mc_strictness = strictness } match_ctxt = MC { mc_what = what, mc_body = tcBody } strictness | [L _ match] <- unLoc $ mg_alts matches @@ -164,8 +155,7 @@ tcMatchLambda :: ExpectedFunTyOrigin -- see Note [Herald for matchExpectedFunTys -> ExpRhoType -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) tcMatchLambda herald match_ctxt match res_ty - = do { checkPatCounts (mc_what match_ctxt) match - ; matchExpectedFunTys herald GenSigCtxt n_pats res_ty $ \ pat_tys rhs_ty -> do + = do { matchExpectedFunTys herald GenSigCtxt n_pats res_ty $ \ pat_tys rhs_ty -> do -- checking argument counts since this is also used for \cases tcMatches match_ctxt pat_tys rhs_ty match } where @@ -1136,28 +1126,16 @@ the variables they bind into scope, and typecheck the thing_inside. \subsection{Errors and contexts} * * ************************************************************************ - - at checkArgCounts@ takes a @[RenamedMatch]@ and decides whether the same -number of args are used in each equation. -} +-- | @checkArgCounts@ takes a @[RenamedMatch]@ and decides whether the same +-- number of args are used in each equation. checkArgCounts :: AnnoBody body - => Name -> MatchGroup GhcRn (LocatedA (body GhcRn)) -> TcM () -checkArgCounts = check_match_pats . EquationArgs - --- @checkPatCounts@ takes a @[RenamedMatch]@ and decides whether the same --- number of patterns are used in each alternative -checkPatCounts :: AnnoBody body - => HsMatchContext GhcTc -> MatchGroup GhcRn (LocatedA (body GhcRn)) - -> TcM () -checkPatCounts = check_match_pats . PatternArgs - -check_match_pats :: AnnoBody body - => MatchArgsContext -> MatchGroup GhcRn (LocatedA (body GhcRn)) - -> TcM () -check_match_pats _ (MG { mg_alts = L _ [] }) + => HsMatchContext GhcTc -> MatchGroup GhcRn (LocatedA (body GhcRn)) + -> TcM () +checkArgCounts match mg = return () -check_match_pats matchContext (MG { mg_alts = L _ (match1:matches) }) +checkArgCounts matchContext (MG { mg_alts = L _ (match1:matches) }) | Just bad_matches <- mb_bad_matches = failWithTc $ TcRnMatchesHaveDiffNumArgs matchContext $ MatchArgMatches match1 bad_matches ===================================== compiler/GHC/Tc/Gen/Match.hs-boot ===================================== @@ -5,13 +5,13 @@ import GHC.Tc.Utils.TcType( ExpSigmaType, ExpRhoType ) import GHC.Tc.Types ( TcM ) import GHC.Hs.Extension ( GhcRn, GhcTc ) import GHC.Parser.Annotation ( LocatedN ) -import GHC.Types.Id (Id) +import GHC.Types.Name (Name) tcGRHSsPat :: GRHSs GhcRn (LHsExpr GhcRn) -> ExpRhoType -> TcM (GRHSs GhcTc (LHsExpr GhcTc)) -tcMatchesFun :: LocatedN Id +tcMatchesFun :: LocatedN Name -> MatchGroup GhcRn (LHsExpr GhcRn) -> ExpSigmaType -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -838,7 +838,7 @@ tcPatSynMatcher (L loc ps_name) lpat prag_fn args body] , mg_ext = MatchGroupTc (map unrestricted [pat_ty, cont_ty, fail_ty]) res_ty Generated } - match = mkMatch (mkPrefixFunRhs (L loc patsyn_id)) [] + match = mkMatch (mkPrefixFunRhs (L loc (idName patsyn_id))) [] (mkHsLams (rr_tv:res_tv:univ_tvs) req_dicts body') (EmptyLocalBinds noExtField) ===================================== compiler/Language/Haskell/Syntax/Expr.hs ===================================== @@ -1533,7 +1533,9 @@ data HsMatchContext p = FunRhs -- ^ A pattern matching on an argument of a -- function binding - { mc_fun :: LIdP p -- ^ function binder of @f@ + { mc_fun :: LIdP (NoGhcTc p) -- ^ function binder of @f@ + -- See #20415 for a long discussion about + -- this field and why it uses NoGhcTc. , mc_fixity :: LexicalFixity -- ^ fixing of @f@ , mc_strictness :: SrcStrictness -- ^ was @f@ banged? -- See Note [FunBind vs PatBind] ===================================== testsuite/tests/ghci/scripts/T22695.script ===================================== @@ -0,0 +1 @@ +test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/T22695.stderr ===================================== @@ -0,0 +1,8 @@ + +:1:10: error: + • The constructor ‘Just’ should have 1 argument, but has been given none + • In the pattern: Just + In a stmt of a pattern guard for + an equation for ‘test’: + Just <- x + In an equation for ‘test’: test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -370,3 +370,4 @@ test('T21110', [extra_files(['T21110A.hs'])], ghci_script, test('T17830', [filter_stdout_lines(r'======.*')], ghci_script, ['T17830.script']) test('T21294a', normal, ghci_script, ['T21294a.script']) test('T21507', normal, ghci_script, ['T21507.script']) +test('T22695', normal, ghci_script, ['T22695.script']) ===================================== testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr ===================================== @@ -1560,7 +1560,7 @@ (FunRhs (L (SrcSpanAnn (EpAnnNotUsed) { DumpTypecheckedAst.hs:19:1-4 }) - {Var: main}) + {Name: main}) (Prefix) (NoSrcStrict)) [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f1a7fa8ccede501a03cbe7a061cfb10f110b55da -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f1a7fa8ccede501a03cbe7a061cfb10f110b55da You're receiving 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 Jan 4 11:58:49 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 04 Jan 2023 06:58:49 -0500 Subject: [Git][ghc/ghc][wip/various-hadrian-fixes] 10 commits: Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Message-ID: <63b569f99cd42_2a26f512e1369cc26305b0@gitlab.mail> Matthew Pickering pushed to branch wip/various-hadrian-fixes at Glasgow Haskell Compiler / GHC Commits: 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Data/EnumSet.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.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 - docs/users_guide/phases.rst - hadrian/README.md - hadrian/doc/flavours.md - hadrian/doc/testsuite.md - hadrian/hadrian.cabal - hadrian/src/Flavour.hs - hadrian/src/Flavour/Type.hs - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Rules/Test.hs - hadrian/src/Settings/Builders/RunTest.hs - + hadrian/src/Settings/Builders/SplitSections.hs - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Flavours/Performance.hs - libraries/base/Data/OldList.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/11d7cc9995619f0f02239a2441fd79852b3d3acd...be9dd9b03479070ba6387c251541f4569392c4bb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/11d7cc9995619f0f02239a2441fd79852b3d3acd...be9dd9b03479070ba6387c251541f4569392c4bb You're receiving 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 Jan 4 12:15:44 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 04 Jan 2023 07:15:44 -0500 Subject: [Git][ghc/ghc][wip/t22599] 115 commits: Mark T21336a fragile Message-ID: <63b56df039a76_2a26f52aa67bb826408a0@gitlab.mail> Matthew Pickering pushed to branch wip/t22599 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 - - - - - 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]. - - - - - 2eb0fb87 by Matthew Pickering at 2022-12-15T03:54:39-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 - - - - - 552b7908 by Ben Gamari at 2022-12-15T03:55:15-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. - - - - - 933d61a4 by Simon Peyton Jones at 2022-12-15T03:55:51-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. - - - - - 03ed0b95 by Ryan Scott at 2022-12-15T03:56:26-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. - - - - - ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/ThreadPaused: Ordering fixes - - - - - 914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00 eventlog: Silence spurious data race - - - - - fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts: Use fences instead of explicit barriers - - - - - 2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - 70999283 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 98689f77 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - 86f20258 by Ben Gamari at 2022-12-16T16:12:45-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. - - - - - f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate access to capabilities array - - - - - 7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate sched_state - - - - - 1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Style fix - - - - - 82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00 compiler: Use release store in eager blackholing - - - - - eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Fix ordering of makeStableName - - - - - ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Note race with wakeBlockingQueue - - - - - 5acf33dd by Bodigrim at 2022-12-16T16:13:22-05:00 Bump submodule directory to 1.3.8.0 and hpc to HEAD - - - - - 0dd95421 by Bodigrim at 2022-12-16T16:13:22-05:00 Accept allocations increase on Windows This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips between lists and ByteArray. See #22625 for discussion. Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T10547 T12150 T12227 T12234 T12425 T13035 T13253 T13253-spj T13701 T13719 T15703 T16875 T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T21839r T5837 T6048 T9198 T9961 TcPlugin_RewritePerf hard_hole_fits - - - - - ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00 testsuite: Mark T9405 as fragile instead of broken on Windows It's starting to pass again, and the unexpected pass blocks CI. - - - - - 1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: remove obsolete commented code in wasm NCG It was just a temporary hack to workaround a bug in the relooper, that bug has been fixed long before the wasm backend is merged. - - - - - e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm Also removes some unreachable code here. - - - - - 1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: change fallback function signature to Cmm function signature in wasm NCG In the wasm NCG, when handling a `CLabel` of undefined function without knowing its function signature, we used to fallback to `() -> ()` which is accepted by `wasm-ld`. This patch changes it to the signature of Cmm functions, which equally works, but would be required when we emit tail call instructions. - - - - - 8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add optional tail-call support in wasm NCG When the `-mtail-call` clang flag is passed at configure time, wasm tail-call extension is enabled, and the wasm NCG will emit `return_call`/`return_call_indirect` instructions to take advantage of it and avoid the `StgRun` trampoline overhead. Closes #22461. - - - - - d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00 base: add missing autoconf checks for waitpid/umask These are not present in wasi-libc. Required for fixing #22589 - - - - - da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00 compiler: make .wasm the default executable extension on wasm32 Following convention as in other wasm toolchains. Fixes #22594. - - - - - ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00 ci: support hello.wasm in ci.sh cross testing logic - - - - - 6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00 Correct `exitWith` Haddocks The `IOError`-specific `catch` in the Prelude is long gone. - - - - - b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-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. - - - - - 761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00 rts/libdw: Silence uninitialized usage warnings As noted in #22538, previously some GCC versions warned that various locals in Libdw.c may be used uninitialized. Although this wasn't strictly true (since they were initialized in an inline assembler block) we fix this by providing explicit empty initializers. Fixes #22538 - - - - - 5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00 testsuite: Mark T16392 as fragile on windows See #22649 - - - - - 703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00 Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`. - - - - - 9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05: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 - - - - - 7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Drop uses of AC_PROG_CC_C99 As noted in #22566, this macro is deprecated as of autoconf-2.70 `AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself. Closes #22566. - - - - - 36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Use AS_HELP_STRING instead of AC_HELP_STRING The latter has been deprecated. See #22566. - - - - - befe6ff8 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: fix various usages of head and tail - - - - - 666d0ba7 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: avoid head and tail in parseCallEscape and around - - - - - 5d96fd50 by Bodigrim at 2022-12-20T21:16:37-05:00 Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty - - - - - 3ce2ab94 by Bodigrim at 2022-12-21T06:17:56-05:00 Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian - - - - - 954de93a by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule haskeline to HEAD (to allow transformers-0.6) - - - - - cefbeec3 by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule transformers to 0.6.0.4 - - - - - b4730b62 by Bodigrim at 2022-12-21T06:17:56-05:00 Fix tests T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations Metric Increase: T13253 - - - - - 0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05: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. - - - - - df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00 rts: explicitly store return value of ccall checkClosure to prevent type error (#22617) - - - - - e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix shadowing lacuna in OccurAnal Issue #22623 demonstrated another lacuna in the implementation of wrinkle (BS3) in Note [The binder-swap substitution] in the occurrence analyser. I was failing to add TyVar lambda binders using addInScope/addOneInScope and that led to a totally bogus binder-swap transformation. Very easy to fix. - - - - - 3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix an assertion check in addToEqualCtList The old assertion saw that a constraint ct could rewrite itself (of course it can) and complained (stupid). Fixes #22645 - - - - - ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00 configure: Bump version to 9.6 - - - - - fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00 base: Bump version to 4.18 Requires various submodule bumps. - - - - - 93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00 ghc-boot: Fix bootstrapping - - - - - fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00 Bump GHC version to 9.7 - - - - - 914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05: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. - - - - - 32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00 hadrian bindist: Install manpages to share/man/man1/ghc.1 When the installation makefile was copied over the manpages were no longer installed in the correct place. Now we install it into share/man/man1/ghc.1 as the make build system did. Fixes #22371 - - - - - b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00 rts: Drop paths from configure from cabal file A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them. - - - - - b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00 Bump libffi-tarballs submodule We will now use libffi-3.4.4. - - - - - 3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00 EPA: Make EOF position part of AnnsModule Closes #20951 Closes #19697 - - - - - 99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00 JS: fix support for -outputdir (#22641) The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug. - - - - - 02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00 Refactor mkRuntimeError This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions. - - - - - 35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00 base: Fix event manager shutdown race on non-Linux platforms During shutdown it's possible that we will attempt to use a closed fd to wakeup another capability's event manager. On the Linux eventfd path we were careful to handle this. However on the non-Linux path we failed to do so. Fix this. - - - - - 317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00 Fix unifier bug: failing to decompose over-saturated type family This simple patch fixes #22647 - - - - - 14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00 rts/m32: Fix sanity checking Previously we would attempt to clear pages which were marked as read-only. Fix this. - - - - - 16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00 ci: Move wasm pipelines into nightly rather than master See #22664 for the changes which need to be made to bring one of these back to the validate pipeline. - - - - - 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-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). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Bodigrim at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - efb2718a by Matthew Pickering at 2023-01-04T12:10:52+00:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 8d5c713e by Matthew Pickering at 2023-01-04T12:14:22+00:00 Debug: Use nix-build for full log - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info/Build.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.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Wasm.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 - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5b8e9a2eb6b854ed9d9f2c4fda0bf2b3fe7fb5f0...8d5c713e17b3c1dbc922d5fbf48c188bc7067c10 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5b8e9a2eb6b854ed9d9f2c4fda0bf2b3fe7fb5f0...8d5c713e17b3c1dbc922d5fbf48c188bc7067c10 You're receiving 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 Jan 4 14:10:52 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 04 Jan 2023 09:10:52 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/spec-transitive Message-ID: <63b588ec3537c_2a26f5a43d37c8269342b@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/spec-transitive at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/spec-transitive You're receiving 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 Jan 4 14:12:41 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 04 Jan 2023 09:12:41 -0500 Subject: [Git][ghc/ghc][wip/t22695] Only store Name in FunRhs rather than Id with knot-tied fields Message-ID: <63b58959dcff_2a26f52aa67bb826936cb@gitlab.mail> Matthew Pickering pushed to branch wip/t22695 at Glasgow Haskell Compiler / GHC Commits: df0ed844 by Matthew Pickering at 2023-01-04T14:12:22+00:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - 15 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Match.hs-boot - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/Language/Haskell/Syntax/Expr.hs - + testsuite/tests/ghci/scripts/T22695.script - + testsuite/tests/ghci/scripts/T22695.stderr - testsuite/tests/ghci/scripts/all.T - testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -2002,7 +2002,7 @@ matchSeparator ThPatSplice = panic "unused" matchSeparator ThPatQuote = panic "unused" matchSeparator PatSyn = panic "unused" -pprMatchContext :: (Outputable (IdP p), UnXRec p) +pprMatchContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContext ctxt | want_an ctxt = text "an" <+> pprMatchContextNoun ctxt @@ -2013,10 +2013,10 @@ pprMatchContext ctxt want_an (ArrowMatchCtxt KappaExpr) = True want_an _ = False -pprMatchContextNoun :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNoun :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNoun (FunRhs {mc_fun=fun}) = text "equation for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNoun CaseAlt = text "case alternative" pprMatchContextNoun (LamCaseAlt lc_variant) = lamCaseKeyword lc_variant <+> text "alternative" @@ -2032,10 +2032,10 @@ pprMatchContextNoun (StmtCtxt ctxt) = text "pattern binding in" $$ pprAStmtContext ctxt pprMatchContextNoun PatSyn = text "pattern synonym declaration" -pprMatchContextNouns :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNouns :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNouns (FunRhs {mc_fun=fun}) = text "equations for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNouns PatBindGuards = text "pattern binding guards" pprMatchContextNouns (ArrowMatchCtxt c) = pprArrowMatchContextNouns c pprMatchContextNouns (StmtCtxt ctxt) = text "pattern bindings in" @@ -2056,7 +2056,7 @@ pprArrowMatchContextNouns (ArrowLamCaseAlt lc_variant) = lamCaseKeyword lc_varia pprArrowMatchContextNouns ctxt = pprArrowMatchContextNoun ctxt <> char 's' ----------------- -pprAStmtContext, pprStmtContext :: (Outputable (IdP p), UnXRec p) +pprAStmtContext, pprStmtContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsStmtContext p -> SDoc pprAStmtContext (HsDoStmt flavour) = pprAHsDoFlavour flavour pprAStmtContext ctxt = text "a" <+> pprStmtContext ctxt ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -863,7 +863,7 @@ mkSimpleGeneratedFunBind loc fun pats expr emptyLocalBinds] -- | Make a prefix, non-strict function 'HsMatchContext' -mkPrefixFunRhs :: LIdP p -> HsMatchContext p +mkPrefixFunRhs :: LIdP (NoGhcTc p) -> HsMatchContext p mkPrefixFunRhs n = FunRhs { mc_fun = n , mc_fixity = Prefix , mc_strictness = NoSrcStrict } ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -957,7 +957,7 @@ instance HiePass p => ToHie (HsMatchContext (GhcPass p)) where name' :: LocatedN Name name' = case hiePass @p of HieRn -> name - HieTc -> fmap varName name + HieTc -> name toHie (StmtCtxt a) = toHie a toHie _ = pure [] ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -927,14 +927,10 @@ instance Diagnostic TcRnMessage where same_rec_group_msg = text "it is defined and used in the same recursive group" TcRnMatchesHaveDiffNumArgs argsContext (MatchArgMatches match1 bad_matches) -> mkSimpleDecorated $ - (vcat [ pprArgsContext argsContext <+> + (vcat [ pprMatchContextNouns argsContext <+> text "have different numbers of arguments" , nest 2 (ppr (getLocA match1)) , nest 2 (ppr (getLocA (NE.head bad_matches)))]) - where - pprArgsContext = \case - EquationArgs name -> (text "Equations for" <+>) . quotes $ ppr name - PatternArgs matchCtx -> pprMatchContextNouns matchCtx TcRnCannotBindScopedTyVarInPatSig sig_tvs -> mkSimpleDecorated $ hang (text "You cannot bind scoped type variable" ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2094,7 +2094,7 @@ data TcRnMessage where typecheck/should_fail/T20768_fail -} TcRnMatchesHaveDiffNumArgs - :: !MatchArgsContext + :: !(HsMatchContext GhcTc) -- ^ Pattern match specifics -> !MatchArgBadMatches -> TcRnMessage ===================================== compiler/GHC/Tc/Gen/Arrow.hs ===================================== @@ -172,7 +172,6 @@ tc_cmd env in_cmd@(HsCmdCase x scrut matches) (stk, res_ty) tc_cmd env cmd@(HsCmdLamCase x lc_variant match) cmd_ty = addErrCtxt (cmdCtxt cmd) do { let match_ctxt = ArrowLamCaseAlt lc_variant - ; checkPatCounts (ArrowMatchCtxt match_ctxt) match ; (wrap, match') <- tcCmdMatchLambda env match_ctxt match cmd_ty ; return (mkHsCmdWrap wrap (HsCmdLamCase x lc_variant match')) } ===================================== compiler/GHC/Tc/Gen/Bind.hs ===================================== @@ -624,7 +624,7 @@ tcPolyCheck prag_fn -- See Note [Relevant bindings and the binder stack] setSrcSpanA bind_loc $ - tcMatchesFun (L nm_loc mono_id) matches + tcMatchesFun (L nm_loc (idName mono_id)) matches (mkCheckExpType rho_ty) -- We make a funny AbsBinds, abstracting over nothing, @@ -1263,18 +1263,14 @@ tcMonoBinds is_rec sig_fn no_gen | NonRecursive <- is_rec -- ...binder isn't mentioned in RHS , Nothing <- sig_fn name -- ...with no type signature = setSrcSpanA b_loc $ - do { ((co_fn, matches'), mono_id, _) <- fixM $ \ ~(_, _, rhs_ty) -> - -- See Note [fixM for rhs_ty in tcMonoBinds] - do { mono_id <- newLetBndr no_gen name ManyTy rhs_ty - ; (matches', rhs_ty') - <- tcInfer $ \ exp_ty -> + do { ((co_fn, matches'), rhs_ty') + <- tcInfer $ \ exp_ty -> tcExtendBinderStack [TcIdBndr_ExpType name exp_ty NotTopLevel] $ -- We extend the error context even for a non-recursive -- function so that in type error messages we show the -- type of the thing whose rhs we are type checking - tcMatchesFun (L nm_loc mono_id) matches exp_ty - ; return (matches', mono_id, rhs_ty') - } + tcMatchesFun (L nm_loc name) matches exp_ty + ; mono_id <- newLetBndr no_gen name ManyTy rhs_ty' ; return (unitBag $ L b_loc $ FunBind { fun_id = L nm_loc mono_id, @@ -1388,19 +1384,6 @@ correctly elaborate 'id'. But we want to /infer/ q's higher rank type. There seems to be no way to do this. So currently we only switch to inference when we have no signature for any of the binders. -Note [fixM for rhs_ty in tcMonoBinds] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -In order to create mono_id we need rhs_ty but we don't have it yet, -we only get it from tcMatchesFun later (which needs mono_id to put -into HsMatchContext for pretty printing). To solve this, create -a thunk of rhs_ty with fixM that we fill in later. - -This is fine only because neither newLetBndr or tcMatchesFun look -at the varType field of the Id. tcMatchesFun only looks at idName -of mono_id. - -Also see #20415 for the bigger picture of why tcMatchesFun needs -mono_id in the first place. -} @@ -1528,7 +1511,7 @@ tcRhs (TcFunBind info@(MBI { mbi_sig = mb_sig, mbi_mono_id = mono_id }) = tcExtendIdBinderStackForRhs [info] $ tcExtendTyVarEnvForRhs mb_sig $ do { traceTc "tcRhs: fun bind" (ppr mono_id $$ ppr (idType mono_id)) - ; (co_fn, matches') <- tcMatchesFun (L (noAnnSrcSpan loc) mono_id) + ; (co_fn, matches') <- tcMatchesFun (L (noAnnSrcSpan loc) (idName mono_id)) matches (mkCheckExpType $ idType mono_id) ; return ( FunBind { fun_id = L (noAnnSrcSpan loc) mono_id , fun_matches = matches' ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -31,7 +31,6 @@ module GHC.Tc.Gen.Match , tcBody , tcDoStmt , tcGuardStmt - , checkPatCounts ) where @@ -93,12 +92,12 @@ is used in error messages. It checks that all the equations have the same number of arguments before using @tcMatches@ to do the work. -} -tcMatchesFun :: LocatedN Id -- MatchContext Id +tcMatchesFun :: LocatedN Name -- MatchContext Id -> MatchGroup GhcRn (LHsExpr GhcRn) -> ExpRhoType -- Expected type of function -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) -- Returns type of body -tcMatchesFun fun_id matches exp_ty +tcMatchesFun fun_name matches exp_ty = do { -- Check that they all have the same no of arguments -- Location is in the monad, set the caller so that -- any inter-equation error messages get some vaguely @@ -106,9 +105,7 @@ tcMatchesFun fun_id matches exp_ty -- ann-grabbing, because we don't always have annotations in -- hand when we call tcMatchesFun... traceTc "tcMatchesFun" (ppr fun_name $$ ppr exp_ty) - -- We can't easily call checkPatCounts here because fun_id can be an - -- unfilled thunk - ; checkArgCounts fun_name matches + ; checkArgCounts what matches ; matchExpectedFunTys herald ctxt arity exp_ty $ \ pat_tys rhs_ty -> -- NB: exp_type may be polymorphic, but @@ -122,17 +119,11 @@ tcMatchesFun fun_id matches exp_ty -- a multiplicity argument, and scale accordingly. tcMatches match_ctxt pat_tys rhs_ty matches } where - fun_name = idName (unLoc fun_id) arity = matchGroupArity matches - herald = ExpectedFunTyMatches (NameThing fun_name) matches + herald = ExpectedFunTyMatches (NameThing (unLoc fun_name)) matches ctxt = GenSigCtxt -- Was: FunSigCtxt fun_name True -- But that's wrong for f :: Int -> forall a. blah - what = FunRhs { mc_fun = fun_id, mc_fixity = Prefix, mc_strictness = strictness } - -- Careful: this fun_id could be an unfilled - -- thunk from fixM in tcMonoBinds, so we're - -- not allowed to look at it, except for - -- idName. - -- See Note [fixM for rhs_ty in tcMonoBinds] + what = FunRhs { mc_fun = fun_name, mc_fixity = Prefix, mc_strictness = strictness } match_ctxt = MC { mc_what = what, mc_body = tcBody } strictness | [L _ match] <- unLoc $ mg_alts matches @@ -164,8 +155,7 @@ tcMatchLambda :: ExpectedFunTyOrigin -- see Note [Herald for matchExpectedFunTys -> ExpRhoType -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) tcMatchLambda herald match_ctxt match res_ty - = do { checkPatCounts (mc_what match_ctxt) match - ; matchExpectedFunTys herald GenSigCtxt n_pats res_ty $ \ pat_tys rhs_ty -> do + = do { matchExpectedFunTys herald GenSigCtxt n_pats res_ty $ \ pat_tys rhs_ty -> do -- checking argument counts since this is also used for \cases tcMatches match_ctxt pat_tys rhs_ty match } where @@ -1136,28 +1126,14 @@ the variables they bind into scope, and typecheck the thing_inside. \subsection{Errors and contexts} * * ************************************************************************ - - at checkArgCounts@ takes a @[RenamedMatch]@ and decides whether the same -number of args are used in each equation. -} +-- | @checkArgCounts@ takes a @[RenamedMatch]@ and decides whether the same +-- number of args are used in each equation. checkArgCounts :: AnnoBody body - => Name -> MatchGroup GhcRn (LocatedA (body GhcRn)) -> TcM () -checkArgCounts = check_match_pats . EquationArgs - --- @checkPatCounts@ takes a @[RenamedMatch]@ and decides whether the same --- number of patterns are used in each alternative -checkPatCounts :: AnnoBody body - => HsMatchContext GhcTc -> MatchGroup GhcRn (LocatedA (body GhcRn)) - -> TcM () -checkPatCounts = check_match_pats . PatternArgs - -check_match_pats :: AnnoBody body - => MatchArgsContext -> MatchGroup GhcRn (LocatedA (body GhcRn)) - -> TcM () -check_match_pats _ (MG { mg_alts = L _ [] }) - = return () -check_match_pats matchContext (MG { mg_alts = L _ (match1:matches) }) + => HsMatchContext GhcTc -> MatchGroup GhcRn (LocatedA (body GhcRn)) + -> TcM () +checkArgCounts matchContext (MG { mg_alts = L _ (match1:matches) }) | Just bad_matches <- mb_bad_matches = failWithTc $ TcRnMatchesHaveDiffNumArgs matchContext $ MatchArgMatches match1 bad_matches ===================================== compiler/GHC/Tc/Gen/Match.hs-boot ===================================== @@ -5,13 +5,13 @@ import GHC.Tc.Utils.TcType( ExpSigmaType, ExpRhoType ) import GHC.Tc.Types ( TcM ) import GHC.Hs.Extension ( GhcRn, GhcTc ) import GHC.Parser.Annotation ( LocatedN ) -import GHC.Types.Id (Id) +import GHC.Types.Name (Name) tcGRHSsPat :: GRHSs GhcRn (LHsExpr GhcRn) -> ExpRhoType -> TcM (GRHSs GhcTc (LHsExpr GhcTc)) -tcMatchesFun :: LocatedN Id +tcMatchesFun :: LocatedN Name -> MatchGroup GhcRn (LHsExpr GhcRn) -> ExpSigmaType -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -838,7 +838,7 @@ tcPatSynMatcher (L loc ps_name) lpat prag_fn args body] , mg_ext = MatchGroupTc (map unrestricted [pat_ty, cont_ty, fail_ty]) res_ty Generated } - match = mkMatch (mkPrefixFunRhs (L loc patsyn_id)) [] + match = mkMatch (mkPrefixFunRhs (L loc (idName patsyn_id))) [] (mkHsLams (rr_tv:res_tv:univ_tvs) req_dicts body') (EmptyLocalBinds noExtField) ===================================== compiler/Language/Haskell/Syntax/Expr.hs ===================================== @@ -1533,7 +1533,9 @@ data HsMatchContext p = FunRhs -- ^ A pattern matching on an argument of a -- function binding - { mc_fun :: LIdP p -- ^ function binder of @f@ + { mc_fun :: LIdP (NoGhcTc p) -- ^ function binder of @f@ + -- See #20415 for a long discussion about + -- this field and why it uses NoGhcTc. , mc_fixity :: LexicalFixity -- ^ fixing of @f@ , mc_strictness :: SrcStrictness -- ^ was @f@ banged? -- See Note [FunBind vs PatBind] ===================================== testsuite/tests/ghci/scripts/T22695.script ===================================== @@ -0,0 +1 @@ +test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/T22695.stderr ===================================== @@ -0,0 +1,8 @@ + +:1:10: error: + • The constructor ‘Just’ should have 1 argument, but has been given none + • In the pattern: Just + In a stmt of a pattern guard for + an equation for ‘test’: + Just <- x + In an equation for ‘test’: test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -370,3 +370,4 @@ test('T21110', [extra_files(['T21110A.hs'])], ghci_script, test('T17830', [filter_stdout_lines(r'======.*')], ghci_script, ['T17830.script']) test('T21294a', normal, ghci_script, ['T21294a.script']) test('T21507', normal, ghci_script, ['T21507.script']) +test('T22695', normal, ghci_script, ['T22695.script']) ===================================== testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr ===================================== @@ -1560,7 +1560,7 @@ (FunRhs (L (SrcSpanAnn (EpAnnNotUsed) { DumpTypecheckedAst.hs:19:1-4 }) - {Var: main}) + {Name: main}) (Prefix) (NoSrcStrict)) [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/df0ed8442e3a004934c264f357355642062037d2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/df0ed8442e3a004934c264f357355642062037d2 You're receiving 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 Jan 4 15:32:14 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 04 Jan 2023 10:32:14 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 10 commits: Explain the auxiliary functions of permutations Message-ID: <63b59bfee8587_2a26f552710272153e@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - afe78202 by Matthew Pickering at 2023-01-04T10:32:01-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - 21 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Driver/Session.hs - docs/users_guide/ghc_config.py.in - docs/users_guide/phases.rst - hadrian/README.md - hadrian/doc/flavours.md - hadrian/doc/testsuite.md - hadrian/hadrian.cabal - hadrian/src/Flavour.hs - hadrian/src/Flavour/Type.hs - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Rules/Test.hs - hadrian/src/Settings/Builders/RunTest.hs - + hadrian/src/Settings/Builders/SplitSections.hs - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Flavours/Performance.hs - libraries/base/Data/OldList.hs - utils/check-exact/ExactPrint.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -500,7 +500,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: @@ -524,7 +524,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,24 +799,24 @@ 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) , disableValidate (standardBuildsWithConfig AArch64 (Linux Debian10) llvm) - , 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 ===================================== @@ -2046,7 +2046,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", @@ -2056,7 +2056,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": { @@ -2098,11 +2098,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" } }, @@ -2297,7 +2297,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", @@ -2307,7 +2307,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": { @@ -2349,18 +2349,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", @@ -2370,7 +2370,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": { @@ -2412,12 +2412,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" } }, @@ -2601,7 +2601,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", @@ -2611,7 +2611,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": { @@ -2653,11 +2653,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" } }, @@ -2908,7 +2908,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" @@ -2917,7 +2917,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": { @@ -2955,8 +2955,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", @@ -2964,11 +2964,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" @@ -2977,7 +2977,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": { @@ -3015,8 +3015,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", @@ -3024,7 +3024,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,14 +2192,10 @@ dynamic_flags_deps = [ , make_ord_flag defGhcFlag "split-objs" (NoArg $ addWarn "ignoring -split-objs") + -- N.B. We may someday deprecate this in favor of -fsplit-sections, + -- which has the benefit of also having a negating -fno-split-sections. , make_ord_flag defGhcFlag "split-sections" - (noArgM (\dflags -> do - if platformHasSubsectionsViaSymbols (targetPlatform dflags) - then do addWarn $ - "-split-sections is not useful on this platform " ++ - "since it always uses subsections via symbols. Ignoring." - return dflags - else return (gopt_set dflags Opt_SplitSections))) + (NoArg $ setGeneralFlag Opt_SplitSections) -------- ghc -M ----------------------------------------------------- , make_ord_flag defGhcFlag "dep-suffix" (hasArg addDepSuffix) @@ -3514,7 +3510,8 @@ fFlagsDeps = [ (addWarn "-compact-unwind is only implemented by the darwin platform. Ignoring.") return dflags)), flagSpec "show-error-context" Opt_ShowErrorContext, - flagSpec "cmm-thread-sanitizer" Opt_CmmThreadSanitizer + flagSpec "cmm-thread-sanitizer" Opt_CmmThreadSanitizer, + flagSpec "split-sections" Opt_SplitSections ] ++ fHoleFlags @@ -4800,6 +4797,13 @@ makeDynFlagsConsistent dflags warn = "-dynamic-too is ignored when using -dynamic" in loop dflags' warn + | gopt Opt_SplitSections dflags + , platformHasSubsectionsViaSymbols (targetPlatform dflags) + = 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 + -- Via-C backend only supports unregisterised ABI. Switch to a backend -- supporting it if possible. | backendUnregisterisedAbiOnly (backend dflags) && ===================================== docs/users_guide/ghc_config.py.in ===================================== @@ -1,6 +1,6 @@ extlinks = { - 'ghc-ticket': ('https://gitlab.haskell.org/ghc/ghc/issues/%s', '#'), - 'ghc-wiki': ('https://gitlab.haskell.org/ghc/ghc/wikis/%s', '#'), + 'ghc-ticket': ('https://gitlab.haskell.org/ghc/ghc/issues/%s', '%s'), + 'ghc-wiki': ('https://gitlab.haskell.org/ghc/ghc/wikis/%s', '#%s'), } libs_base_uri = '../libraries' ===================================== docs/users_guide/phases.rst ===================================== @@ -909,10 +909,12 @@ for example). option for Apple's Linker (``-F`` already means something else for GHC). -.. ghc-flag:: -split-sections +.. ghc-flag:: -fsplit-sections + -split-sections :shortdesc: Split sections for link-time dead-code stripping :type: dynamic :category: linking + :reverse: -fno-split-sections Place each generated function or data item into its own section in the output file if the target supports arbitrary sections. The name of the ===================================== 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 + @@ -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/hadrian.cabal ===================================== @@ -112,6 +112,7 @@ executable hadrian , Settings.Builders.Ld , Settings.Builders.Make , Settings.Builders.MergeObjects + , Settings.Builders.SplitSections , Settings.Builders.RunTest , Settings.Builders.Win32Tarballs , Settings.Builders.Xelatex ===================================== hadrian/src/Flavour.hs ===================================== @@ -5,7 +5,7 @@ module Flavour -- * Flavour transformers , flavourTransformers , addArgs - , splitSections, splitSectionsIf + , splitSections , enableThreadSanitizer , enableDebugInfo, enableTickyGhc , viaLlvmBackend @@ -37,7 +37,6 @@ import Text.Parsec.Char as P import Control.Monad.Except import UserSettings import Oracles.Flag -import Oracles.Setting flavourTransformers :: Map String (Flavour -> Flavour) @@ -46,6 +45,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 @@ -181,31 +181,13 @@ enableHaddock = ] -- | Transform the input 'Flavour' so as to build with --- @-split-sections@ whenever appropriate. You can --- select which package gets built with split sections --- by passing a suitable predicate. If the predicate holds --- for a given package, then @split-sections@ is used when --- building it. Note that this transformer doesn't do anything +-- @-split-sections@ whenever appropriate. +-- 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 - pkg <- getPackage - osx <- expr isOsxTarget - not osx ? -- osx doesn't support split sections - pkgPredicate pkg ? mconcat -- Only apply to these packages - [ builder (Ghc CompileHs) ? arg "-split-sections" - , builder MergeObjects ? ifM (expr isWinTarget) - (pure ["-t", "driver/utils/merge_sections_pe.ld"]) - (pure ["-t", "driver/utils/merge_sections.ld"]) - ] - --- | Like 'splitSectionsIf', but with a fixed predicate: use --- split sections for all packages but the GHC library. -splitSections :: Flavour -> Flavour -splitSections = splitSectionsIf (/=ghc) --- Disable section splitting for the GHC library. It takes too long and --- there is little benefit. +splitSections, noSplitSections :: Flavour -> Flavour +splitSections f = f { ghcSplitSections = True } +noSplitSections f = f { ghcSplitSections = False } -- | Build GHC and libraries with ThreadSanitizer support. You likely want to -- configure with @--disable-large-address-space@ when using this. ===================================== hadrian/src/Flavour/Type.hs ===================================== @@ -43,6 +43,8 @@ data Flavour = Flavour { -- | Build the GHC executable against the threaded runtime system. ghcThreaded :: Stage -- ^ stage of the /built/ compiler -> Bool, + + ghcSplitSections :: Bool, -- ^ Whether to enable split sections -- | Whether to build docs and which ones -- (haddocks, user manual, haddock manual) ghcDocs :: Action DocTargets } ===================================== 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/Builders/SplitSections.hs ===================================== @@ -0,0 +1,36 @@ +-- | Settings required when split-sections is enabled. +module Settings.Builders.SplitSections where + +import Expression +import Packages +import Settings +import Flavour.Type + +import Oracles.Setting + +-- | Does it make sense to enable or disable split sections? +splitSectionsArgs :: Args +splitSectionsArgs = do + pkg <- getPackage + osx <- expr isOsxTarget + notSt0 <- notStage0 + flav <- expr flavour + if ( ghcSplitSections flav + -- Flavour enables split-sections + && not osx + -- OS X doesn't support split sections + && notSt0 + -- Disable for stage 0 because we aren't going to ship + -- the resulting binaries and consequently there is no + -- reason to minimize size. + && (pkg /= ghc) + -- Disable section splitting for the GHC library. + -- It takes too long and there is little benefit. + ) then + ( mconcat + [ builder (Ghc CompileHs) ? arg "-fsplit-sections" + , builder MergeObjects ? ifM (expr isWinTarget) + (pure ["-t", "driver/utils/merge_sections_pe.ld"]) + (pure ["-t", "driver/utils/merge_sections.ld"]) + ] + ) else mempty ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -41,6 +41,7 @@ import Settings.Builders.Ar import Settings.Builders.Ld import Settings.Builders.Make import Settings.Builders.MergeObjects +import Settings.Builders.SplitSections import Settings.Builders.RunTest import Settings.Builders.Xelatex import Settings.Packages @@ -243,6 +244,7 @@ defaultFlavour = Flavour , ghcDebugged = const False , ghcThreaded = const True , ghcDebugAssertions = const False + , ghcSplitSections = False , ghcDocs = cmdDocsArgs } -- | Default logic for determining whether to build @@ -279,6 +281,7 @@ defaultBuilderArgs = mconcat , validateBuilderArgs , xelatexBuilderArgs , win32TarballsArgs + , splitSectionsArgs -- Generic builders from the Hadrian library: , builder (Sphinx HtmlMode ) ? Hadrian.Builder.Sphinx.args HtmlMode , builder (Sphinx LatexMode) ? Hadrian.Builder.Sphinx.args LatexMode ===================================== 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 } ===================================== libraries/base/Data/OldList.hs ===================================== @@ -1266,15 +1266,42 @@ permutations :: [a] -> [[a]] -- Related discussions: -- * https://mail.haskell.org/pipermail/haskell-cafe/2021-December/134920.html -- * https://mail.haskell.org/pipermail/libraries/2007-December/008788.html +-- +-- Verification of the equivalences of the auxiliary functions with Liquid Haskell: +-- https://github.com/ucsd-progsys/liquidhaskell/blob/b86fb5b/tests/ple/pos/Permutations.hs permutations xs0 = xs0 : perms xs0 [] where + -- | @perms ts is@ is equivalent to + -- + -- > concat + -- > [ interleave {(ts!!n)} {(drop (n+1)} ts) xs [] + -- > | n <- [0..length ts - 1] + -- > , xs <- permutations (reverse (take n ts) ++ is) + -- > ] + -- + -- @{(ts!!n)}@ and @{(drop (n+1)}@ denote the values of variables @t@ and @ts@ which + -- appear free in the definition of @interleave@ and @interleave'@. perms :: forall a. [a] -> [a] -> [[a]] perms [] _ = [] perms (t:ts) is = foldr interleave (perms ts (t:is)) (permutations is) where + -- @interleave {t} {ts} xs r@ is equivalent to + -- + -- > [ insertAt n t xs ++ ts | n <- [0..length xs - 1] ] ++ r + -- + -- where + -- + -- > insertAt n y xs = take n xs ++ y : drop n xs + -- interleave :: [a] -> [[a]] -> [[a]] interleave xs r = let (_,zs) = interleave' id xs r in zs + -- @interleave' f ys r@ is equivalent to + -- + -- > ( ys ++ ts + -- > , [ f (insertAt n t ys ++ ts) | n <- [0..length ys - 1] ] ++ r + -- > ) + -- interleave' :: ([a] -> b) -> [a] -> [b] -> ([a], [b]) interleave' _ [] r = (ts, r) interleave' f (y:ys) r = let (us,zs) = interleave' (f . (y:)) ys r ===================================== 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 ( @@ -2938,7 +2939,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/5cff237e9736ed069b1e9222ed130f7881662c8a...afe7820203ad101fb527295ce01bde77509d1693 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5cff237e9736ed069b1e9222ed130f7881662c8a...afe7820203ad101fb527295ce01bde77509d1693 You're receiving 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 Jan 4 17:59:29 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Wed, 04 Jan 2023 12:59:29 -0500 Subject: [Git][ghc/ghc][wip/az/epa-zerowidth-semis1] 3 commits: Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Message-ID: <63b5be813f0be_f192a52710971e6@gitlab.mail> Alan Zimmerman pushed to branch wip/az/epa-zerowidth-semis1 at Glasgow Haskell Compiler / GHC Commits: 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - ab60e583 by Alan Zimmerman at 2023-01-04T17:59:23+00:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 21 changed files: - compiler/GHC/Data/EnumSet.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/DocString.hs - compiler/GHC/Parser.y - 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 - libraries/base/Data/OldList.hs - testsuite/tests/ghc-api/exactprint/RmDecl4.expected.hs - testsuite/tests/ghc-api/exactprint/Test20239.stderr - + testsuite/tests/ghc-api/exactprint/ZeroWidthSemi.hs - + testsuite/tests/ghc-api/exactprint/ZeroWidthSemi.stderr - testsuite/tests/ghc-api/exactprint/all.T - testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr - testsuite/tests/parser/should_compile/T20718.stderr - testsuite/tests/printer/Test20297.stdout 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/Parser.y ===================================== @@ -1076,8 +1076,10 @@ qcname :: { LocatedN RdrName } -- Variable or type constructor -- One or more semicolons semis1 :: { Located [TrailingAnn] } -semis1 : semis1 ';' { sLL $1 $> $ if isZeroWidthSpan (gl $2) then (unLoc $1) else (AddSemiAnn (glAA $2) : (unLoc $1)) } - | ';' { sL1 $1 $ msemi $1 } +semis1 : semis1 ';' { if isZeroWidthSpan (gl $2) then (sL1 $1 $ unLoc $1) else (sLL $1 $> $ AddSemiAnn (glAA $2) : (unLoc $1)) } + | ';' { case msemi $1 of + [] -> noLoc [] + ms -> sL1 $1 $ ms } -- Zero or more semicolons semis :: { [TrailingAnn] } ===================================== 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 ===================================== @@ -738,6 +738,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) {- ************************************************************************ ===================================== libraries/base/Data/OldList.hs ===================================== @@ -1266,15 +1266,42 @@ permutations :: [a] -> [[a]] -- Related discussions: -- * https://mail.haskell.org/pipermail/haskell-cafe/2021-December/134920.html -- * https://mail.haskell.org/pipermail/libraries/2007-December/008788.html +-- +-- Verification of the equivalences of the auxiliary functions with Liquid Haskell: +-- https://github.com/ucsd-progsys/liquidhaskell/blob/b86fb5b/tests/ple/pos/Permutations.hs permutations xs0 = xs0 : perms xs0 [] where + -- | @perms ts is@ is equivalent to + -- + -- > concat + -- > [ interleave {(ts!!n)} {(drop (n+1)} ts) xs [] + -- > | n <- [0..length ts - 1] + -- > , xs <- permutations (reverse (take n ts) ++ is) + -- > ] + -- + -- @{(ts!!n)}@ and @{(drop (n+1)}@ denote the values of variables @t@ and @ts@ which + -- appear free in the definition of @interleave@ and @interleave'@. perms :: forall a. [a] -> [a] -> [[a]] perms [] _ = [] perms (t:ts) is = foldr interleave (perms ts (t:is)) (permutations is) where + -- @interleave {t} {ts} xs r@ is equivalent to + -- + -- > [ insertAt n t xs ++ ts | n <- [0..length xs - 1] ] ++ r + -- + -- where + -- + -- > insertAt n y xs = take n xs ++ y : drop n xs + -- interleave :: [a] -> [[a]] -> [[a]] interleave xs r = let (_,zs) = interleave' id xs r in zs + -- @interleave' f ys r@ is equivalent to + -- + -- > ( ys ++ ts + -- > , [ f (insertAt n t ys ++ ts) | n <- [0..length ys - 1] ] ++ r + -- > ) + -- interleave' :: ([a] -> b) -> [a] -> [b] -> ([a], [b]) interleave' _ [] r = (ts, r) interleave' f (y:ys) r = let (us,zs) = interleave' (f . (y:)) ys r ===================================== testsuite/tests/ghc-api/exactprint/RmDecl4.expected.hs ===================================== @@ -7,5 +7,4 @@ ff y = y + zz + xx zz = 1 - -- EOF ===================================== testsuite/tests/ghc-api/exactprint/Test20239.stderr ===================================== @@ -24,7 +24,14 @@ { Test20239.hs:7:34-63 }))) (EpaCommentsBalanced [] - [])) + [(L + (Anchor + { Test20239.hs:7:34-63 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- ^ Run any arbitrary IO code") + { Test20239.hs:6:86 }))])) (VirtualBraces (1)) (Nothing) @@ -50,15 +57,7 @@ (EpaComment (EpaLineComment "-- | Leading Haddock Comment") - { Test20239.hs:1:18-22 })) - ,(L - (Anchor - { Test20239.hs:7:34-63 } - (UnchangedAnchor)) - (EpaComment - (EpaLineComment - "-- ^ Run any arbitrary IO code") - { Test20239.hs:6:86 }))])) { Test20239.hs:(4,1)-(6,86) }) + { Test20239.hs:1:18-22 }))])) { Test20239.hs:(4,1)-(6,86) }) (InstD (NoExtField) (DataFamInstD ===================================== testsuite/tests/ghc-api/exactprint/ZeroWidthSemi.hs ===================================== @@ -0,0 +1,8 @@ +module ZeroWidthSemi where + +-- leading comments + +-- Function comment +a = 0 + +-- Trailing comment, should be in HsModule extension point ===================================== testsuite/tests/ghc-api/exactprint/ZeroWidthSemi.stderr ===================================== @@ -0,0 +1,134 @@ + +==================== Parser AST ==================== + +(L + { ZeroWidthSemi.hs:1:1 } + (HsModule + (XModulePs + (EpAnn + (Anchor + { ZeroWidthSemi.hs:1:1 } + (UnchangedAnchor)) + (AnnsModule + [(AddEpAnn AnnModule (EpaSpan { ZeroWidthSemi.hs:1:1-6 })) + ,(AddEpAnn AnnWhere (EpaSpan { ZeroWidthSemi.hs:1:22-26 }))] + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (Just + ((,) + { ZeroWidthSemi.hs:9:1 } + { ZeroWidthSemi.hs:8:1-58 }))) + (EpaCommentsBalanced + [(L + (Anchor + { ZeroWidthSemi.hs:3:1-19 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- leading comments") + { ZeroWidthSemi.hs:1:22-26 }))] + [(L + (Anchor + { ZeroWidthSemi.hs:8:1-58 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- Trailing comment, should be in HsModule extension point") + { ZeroWidthSemi.hs:6:5 }))])) + (VirtualBraces + (1)) + (Nothing) + (Nothing)) + (Just + (L + (SrcSpanAnn (EpAnnNotUsed) { ZeroWidthSemi.hs:1:8-20 }) + {ModuleName: ZeroWidthSemi})) + (Nothing) + [] + [(L + (SrcSpanAnn (EpAnn + (Anchor + { ZeroWidthSemi.hs:6:1-5 } + (UnchangedAnchor)) + (AnnListItem + []) + (EpaComments + [(L + (Anchor + { ZeroWidthSemi.hs:5:1-19 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- Function comment") + { ZeroWidthSemi.hs:3:1-19 }))])) { ZeroWidthSemi.hs:6:1-5 }) + (ValD + (NoExtField) + (FunBind + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { ZeroWidthSemi.hs:6:1 }) + (Unqual + {OccName: a})) + (MG + (FromSource) + (L + (SrcSpanAnn (EpAnnNotUsed) { ZeroWidthSemi.hs:6:1-5 }) + [(L + (SrcSpanAnn (EpAnnNotUsed) { ZeroWidthSemi.hs:6:1-5 }) + (Match + (EpAnn + (Anchor + { ZeroWidthSemi.hs:6:1-5 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (FunRhs + (L + (SrcSpanAnn (EpAnnNotUsed) { ZeroWidthSemi.hs:6:1 }) + (Unqual + {OccName: a})) + (Prefix) + (NoSrcStrict)) + [] + (GRHSs + (EpaComments + []) + [(L + (SrcSpanAnn + (EpAnnNotUsed) + { ZeroWidthSemi.hs:6:3-5 }) + (GRHS + (EpAnn + (Anchor + { ZeroWidthSemi.hs:6:3-5 } + (UnchangedAnchor)) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { ZeroWidthSemi.hs:6:3 }))) + (EpaComments + [])) + [] + (L + (SrcSpanAnn (EpAnnNotUsed) { ZeroWidthSemi.hs:6:5 }) + (HsOverLit + (EpAnn + (Anchor + { ZeroWidthSemi.hs:6:5 } + (UnchangedAnchor)) + (NoEpAnns) + (EpaComments + [])) + (OverLit + (NoExtField) + (HsIntegral + (IL + (SourceText 0) + (False) + (0))))))))] + (EmptyLocalBinds + (NoExtField)))))])))))])) ===================================== testsuite/tests/ghc-api/exactprint/all.T ===================================== @@ -37,3 +37,4 @@ test('RmTypeSig2', ignore_stderr, makefile_test, ['RmTypeSig2']) test('AddHiding1', ignore_stderr, makefile_test, ['AddHiding1']) test('AddHiding2', ignore_stderr, makefile_test, ['AddHiding2']) test('Test20239', normal, compile_fail, ['-dsuppress-uniques -ddump-parsed-ast -dkeep-comments']) +test('ZeroWidthSemi', normal, compile, ['-dsuppress-uniques -ddump-parsed-ast -dkeep-comments']) ===================================== testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr ===================================== @@ -82,15 +82,7 @@ (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:13:3 + { DumpParsedAstComments.hs:9:1-20 }))])) { DumpParsedAstComments.hs:(11,1)-(13,3) }) (ValD (NoExtField) @@ -219,7 +211,15 @@ (AnnListItem []) (EpaComments - [])) { DumpParsedAstComments.hs:16:1-23 }) + [(L + (Anchor + { DumpParsedAstComments.hs:15:1-20 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- | Haddock comment") + { DumpParsedAstComments.hs:13:3 + }))])) { DumpParsedAstComments.hs:16:1-23 }) (ValD (NoExtField) (FunBind ===================================== testsuite/tests/parser/should_compile/T20718.stderr ===================================== @@ -55,7 +55,22 @@ (EpaLineComment "-- before 2") { T20718.hs:5:1-11 }))] - [])) + [(L + (Anchor + { T20718.hs:10:1-8 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- end 1") + { T20718.hs:8:5 })) + ,(L + (Anchor + { T20718.hs:11:1-8 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- end 2") + { T20718.hs:10:1-8 }))])) (VirtualBraces (1)) (Nothing) @@ -74,22 +89,7 @@ (AnnListItem []) (EpaComments - [(L - (Anchor - { T20718.hs:10:1-8 } - (UnchangedAnchor)) - (EpaComment - (EpaLineComment - "-- end 1") - { T20718.hs:8:5 })) - ,(L - (Anchor - { T20718.hs:11:1-8 } - (UnchangedAnchor)) - (EpaComment - (EpaLineComment - "-- end 2") - { T20718.hs:10:1-8 }))])) { T20718.hs:8:1-5 }) + [])) { T20718.hs:8:1-5 }) (ValD (NoExtField) (FunBind ===================================== testsuite/tests/printer/Test20297.stdout ===================================== @@ -50,14 +50,7 @@ (AnnListItem []) (EpaComments - [(L - (Anchor - { Test20297.hs:7:9-19 } - (UnchangedAnchor)) - (EpaComment - (EpaLineComment - "-- comment1") - { Test20297.hs:7:3-7 }))])) { Test20297.hs:(5,1)-(7,7) }) + [])) { Test20297.hs:(5,1)-(7,7) }) (ValD (NoExtField) (FunBind @@ -150,7 +143,14 @@ (AnnListItem []) (EpaComments - [])) { Test20297.hs:(9,1)-(11,26) }) + [(L + (Anchor + { Test20297.hs:7:9-19 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- comment1") + { Test20297.hs:7:3-7 }))])) { Test20297.hs:(9,1)-(11,26) }) (ValD (NoExtField) (FunBind View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/39eb4b4a60fc5b2f2bc42d90da1c0902e8f75320...ab60e583e92592d8b48703f9ec3db98e4efdb625 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/39eb4b4a60fc5b2f2bc42d90da1c0902e8f75320...ab60e583e92592d8b48703f9ec3db98e4efdb625 You're receiving 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 Jan 4 19:32:40 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 04 Jan 2023 14:32:40 -0500 Subject: [Git][ghc/ghc][master] 8 commits: compiler: Add -f[no-]split-sections flags Message-ID: <63b5d458cfd65_f192a526c01227ba@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 19 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/hadrian.cabal - hadrian/src/Flavour.hs - hadrian/src/Flavour/Type.hs - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Rules/Test.hs - hadrian/src/Settings/Builders/RunTest.hs - + hadrian/src/Settings/Builders/SplitSections.hs - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Flavours/Performance.hs - utils/check-exact/ExactPrint.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -500,7 +500,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: @@ -524,7 +524,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,24 +799,24 @@ 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) , disableValidate (standardBuildsWithConfig AArch64 (Linux Debian10) llvm) - , 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 ===================================== @@ -2046,7 +2046,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", @@ -2056,7 +2056,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": { @@ -2098,11 +2098,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" } }, @@ -2297,7 +2297,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", @@ -2307,7 +2307,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": { @@ -2349,18 +2349,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", @@ -2370,7 +2370,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": { @@ -2412,12 +2412,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" } }, @@ -2601,7 +2601,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", @@ -2611,7 +2611,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": { @@ -2653,11 +2653,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" } }, @@ -2908,7 +2908,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" @@ -2917,7 +2917,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": { @@ -2955,8 +2955,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", @@ -2964,11 +2964,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" @@ -2977,7 +2977,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": { @@ -3015,8 +3015,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", @@ -3024,7 +3024,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,14 +2192,10 @@ dynamic_flags_deps = [ , make_ord_flag defGhcFlag "split-objs" (NoArg $ addWarn "ignoring -split-objs") + -- N.B. We may someday deprecate this in favor of -fsplit-sections, + -- which has the benefit of also having a negating -fno-split-sections. , make_ord_flag defGhcFlag "split-sections" - (noArgM (\dflags -> do - if platformHasSubsectionsViaSymbols (targetPlatform dflags) - then do addWarn $ - "-split-sections is not useful on this platform " ++ - "since it always uses subsections via symbols. Ignoring." - return dflags - else return (gopt_set dflags Opt_SplitSections))) + (NoArg $ setGeneralFlag Opt_SplitSections) -------- ghc -M ----------------------------------------------------- , make_ord_flag defGhcFlag "dep-suffix" (hasArg addDepSuffix) @@ -3514,7 +3510,8 @@ fFlagsDeps = [ (addWarn "-compact-unwind is only implemented by the darwin platform. Ignoring.") return dflags)), flagSpec "show-error-context" Opt_ShowErrorContext, - flagSpec "cmm-thread-sanitizer" Opt_CmmThreadSanitizer + flagSpec "cmm-thread-sanitizer" Opt_CmmThreadSanitizer, + flagSpec "split-sections" Opt_SplitSections ] ++ fHoleFlags @@ -4800,6 +4797,13 @@ makeDynFlagsConsistent dflags warn = "-dynamic-too is ignored when using -dynamic" in loop dflags' warn + | gopt Opt_SplitSections dflags + , platformHasSubsectionsViaSymbols (targetPlatform dflags) + = 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 + -- Via-C backend only supports unregisterised ABI. Switch to a backend -- supporting it if possible. | backendUnregisterisedAbiOnly (backend dflags) && ===================================== docs/users_guide/phases.rst ===================================== @@ -909,10 +909,12 @@ for example). option for Apple's Linker (``-F`` already means something else for GHC). -.. ghc-flag:: -split-sections +.. ghc-flag:: -fsplit-sections + -split-sections :shortdesc: Split sections for link-time dead-code stripping :type: dynamic :category: linking + :reverse: -fno-split-sections Place each generated function or data item into its own section in the output file if the target supports arbitrary sections. The name of the ===================================== 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
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 @@ -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/hadrian.cabal ===================================== @@ -112,6 +112,7 @@ executable hadrian , Settings.Builders.Ld , Settings.Builders.Make , Settings.Builders.MergeObjects + , Settings.Builders.SplitSections , Settings.Builders.RunTest , Settings.Builders.Win32Tarballs , Settings.Builders.Xelatex ===================================== hadrian/src/Flavour.hs ===================================== @@ -5,7 +5,7 @@ module Flavour -- * Flavour transformers , flavourTransformers , addArgs - , splitSections, splitSectionsIf + , splitSections , enableThreadSanitizer , enableDebugInfo, enableTickyGhc , viaLlvmBackend @@ -37,7 +37,6 @@ import Text.Parsec.Char as P import Control.Monad.Except import UserSettings import Oracles.Flag -import Oracles.Setting flavourTransformers :: Map String (Flavour -> Flavour) @@ -46,6 +45,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 @@ -181,31 +181,13 @@ enableHaddock = ] -- | Transform the input 'Flavour' so as to build with --- @-split-sections@ whenever appropriate. You can --- select which package gets built with split sections --- by passing a suitable predicate. If the predicate holds --- for a given package, then @split-sections@ is used when --- building it. Note that this transformer doesn't do anything +-- @-split-sections@ whenever appropriate. +-- 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 - pkg <- getPackage - osx <- expr isOsxTarget - not osx ? -- osx doesn't support split sections - pkgPredicate pkg ? mconcat -- Only apply to these packages - [ builder (Ghc CompileHs) ? arg "-split-sections" - , builder MergeObjects ? ifM (expr isWinTarget) - (pure ["-t", "driver/utils/merge_sections_pe.ld"]) - (pure ["-t", "driver/utils/merge_sections.ld"]) - ] - --- | Like 'splitSectionsIf', but with a fixed predicate: use --- split sections for all packages but the GHC library. -splitSections :: Flavour -> Flavour -splitSections = splitSectionsIf (/=ghc) --- Disable section splitting for the GHC library. It takes too long and --- there is little benefit. +splitSections, noSplitSections :: Flavour -> Flavour +splitSections f = f { ghcSplitSections = True } +noSplitSections f = f { ghcSplitSections = False } -- | Build GHC and libraries with ThreadSanitizer support. You likely want to -- configure with @--disable-large-address-space@ when using this. ===================================== hadrian/src/Flavour/Type.hs ===================================== @@ -43,6 +43,8 @@ data Flavour = Flavour { -- | Build the GHC executable against the threaded runtime system. ghcThreaded :: Stage -- ^ stage of the /built/ compiler -> Bool, + + ghcSplitSections :: Bool, -- ^ Whether to enable split sections -- | Whether to build docs and which ones -- (haddocks, user manual, haddock manual) ghcDocs :: Action DocTargets } ===================================== 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/Builders/SplitSections.hs ===================================== @@ -0,0 +1,36 @@ +-- | Settings required when split-sections is enabled. +module Settings.Builders.SplitSections where + +import Expression +import Packages +import Settings +import Flavour.Type + +import Oracles.Setting + +-- | Does it make sense to enable or disable split sections? +splitSectionsArgs :: Args +splitSectionsArgs = do + pkg <- getPackage + osx <- expr isOsxTarget + notSt0 <- notStage0 + flav <- expr flavour + if ( ghcSplitSections flav + -- Flavour enables split-sections + && not osx + -- OS X doesn't support split sections + && notSt0 + -- Disable for stage 0 because we aren't going to ship + -- the resulting binaries and consequently there is no + -- reason to minimize size. + && (pkg /= ghc) + -- Disable section splitting for the GHC library. + -- It takes too long and there is little benefit. + ) then + ( mconcat + [ builder (Ghc CompileHs) ? arg "-fsplit-sections" + , builder MergeObjects ? ifM (expr isWinTarget) + (pure ["-t", "driver/utils/merge_sections_pe.ld"]) + (pure ["-t", "driver/utils/merge_sections.ld"]) + ] + ) else mempty ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -41,6 +41,7 @@ import Settings.Builders.Ar import Settings.Builders.Ld import Settings.Builders.Make import Settings.Builders.MergeObjects +import Settings.Builders.SplitSections import Settings.Builders.RunTest import Settings.Builders.Xelatex import Settings.Packages @@ -243,6 +244,7 @@ defaultFlavour = Flavour , ghcDebugged = const False , ghcThreaded = const True , ghcDebugAssertions = const False + , ghcSplitSections = False , ghcDocs = cmdDocsArgs } -- | Default logic for determining whether to build @@ -279,6 +281,7 @@ defaultBuilderArgs = mconcat , validateBuilderArgs , xelatexBuilderArgs , win32TarballsArgs + , splitSectionsArgs -- Generic builders from the Hadrian library: , builder (Sphinx HtmlMode ) ? Hadrian.Builder.Sphinx.args HtmlMode , builder (Sphinx LatexMode) ? Hadrian.Builder.Sphinx.args LatexMode ===================================== 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 ( @@ -2938,7 +2939,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/21bedd84f2cde6aa17d09c610a2a309f3e2a7f10...be9dd9b03479070ba6387c251541f4569392c4bb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/21bedd84f2cde6aa17d09c610a2a309f3e2a7f10...be9dd9b03479070ba6387c251541f4569392c4bb You're receiving 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 Jan 4 19:33:04 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 04 Jan 2023 14:33:04 -0500 Subject: [Git][ghc/ghc][master] sphinx: Use modern syntax for extlinks Message-ID: <63b5d47017ae4_f192a526c012780@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - 1 changed file: - docs/users_guide/ghc_config.py.in Changes: ===================================== docs/users_guide/ghc_config.py.in ===================================== @@ -1,6 +1,6 @@ extlinks = { - 'ghc-ticket': ('https://gitlab.haskell.org/ghc/ghc/issues/%s', '#'), - 'ghc-wiki': ('https://gitlab.haskell.org/ghc/ghc/wikis/%s', '#'), + 'ghc-ticket': ('https://gitlab.haskell.org/ghc/ghc/issues/%s', '%s'), + 'ghc-wiki': ('https://gitlab.haskell.org/ghc/ghc/wikis/%s', '#%s'), } libs_base_uri = '../libraries' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/00dc51060881df81258ba3b3bdf447294618a4de -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/00dc51060881df81258ba3b3bdf447294618a4de You're receiving 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 Jan 4 21:14:12 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Wed, 04 Jan 2023 16:14:12 -0500 Subject: [Git][ghc/ghc][wip/remove-rts-configure-hack] 12 commits: Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Message-ID: <63b5ec2434d40_f192a310829c14499b@gitlab.mail> John Ericson pushed to branch wip/remove-rts-configure-hack at Glasgow Haskell Compiler / GHC Commits: 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - cdfdfed2 by John Ericson at 2023-01-04T16:07:07-05:00 Remove RTS hack for configuring See the brand new Note [Undefined symbols in the RTS] for additional details. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Data/EnumSet.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.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 - docs/users_guide/ghc_config.py.in - docs/users_guide/phases.rst - hadrian/README.md - hadrian/doc/flavours.md - hadrian/doc/testsuite.md - hadrian/hadrian.cabal - hadrian/src/Flavour.hs - hadrian/src/Flavour/Type.hs - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Rules/Register.hs - hadrian/src/Rules/Test.hs - hadrian/src/Settings/Builders/RunTest.hs - + hadrian/src/Settings/Builders/SplitSections.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e9cc3e5ed021db499e760d3b78cf9d2410ee5798...cdfdfed2552c553f36c1328ca2e6f9cc105f942d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e9cc3e5ed021db499e760d3b78cf9d2410ee5798...cdfdfed2552c553f36c1328ca2e6f9cc105f942d You're receiving 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 Jan 4 21:49:52 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 04 Jan 2023 16:49:52 -0500 Subject: [Git][ghc/ghc][wip/mmtk-ben] Refactor marking of static objects Message-ID: <63b5f4801ca06_f192a5279c152877@gitlab.mail> Ben Gamari pushed to branch wip/mmtk-ben at Glasgow Haskell Compiler / GHC Commits: be34ab23 by Ben Gamari at 2023-01-04T16:49:34-05:00 Refactor marking of static objects - - - - - 1 changed file: - rts/mmtk/mmtk/src/active_plan.rs Changes: ===================================== rts/mmtk/mmtk/src/active_plan.rs ===================================== @@ -11,15 +11,44 @@ use crate::stg_closures::*; use crate::stg_info_table::*; -static mut STATIC_FLAG: bool = false; +enum StaticFlag { A, B } + +impl StaticFlag { + pub fn negate(self) -> self { + use StaticFlag::*; + match STATIC_FLAG { + A => B, + B => A + } + } +} + +/// The tag encoded in the low bits of CAF's `static_link` field. +/// See Note [STATIC_LINK fields]. +enum StaticTag { + NotVisited, // Tag value 0 + Visited(StaticFlag), // Tag values 1, 2 + NotACaf // Tag value 3 +} + +fn get_static_tag(r: const TaggedClosureRef) -> StaticTag { + match r.get_tag() { + 0 => NotVisited, + 1 => Visited(A), + 2 => Visited(B), + 3 => NotACaf, + } +} + +static mut STATIC_FLAG: StaticFlag = StaticFlag::A; pub fn bump_static_flag() { unsafe { - STATIC_FLAG = !STATIC_FLAG; + STATIC_FLAG = STATIC_FLAG.negate(); } } -fn get_static_flag() -> bool { +fn get_static_flag() -> StaticFlag { unsafe { STATIC_FLAG } @@ -77,9 +106,12 @@ impl ActivePlan for VMActivePlan { // Modelled after evacuate_static_object, returns true if this // is the first time the object has been visited in this GC. let mut evacuate_static = |static_link: &mut TaggedClosureRef| -> bool { - let cur_static_flag = if get_static_flag() { 2 } else { 1 }; - let prev_static_flag = if get_static_flag() { 1 } else { 2 }; - let object_visited: bool = (static_link.get_tag() | prev_static_flag) != 3; + let cur_static_flag = get_static_flag(); + let object_visited: bool = match get_static_tag(static_link) { + NotACaf => True, + NotVisited => False, + Visited(flag) => flag == cur_static_flag, + }; if !object_visited { // N.B. We don't need to maintain a list of static objects, therefore ZERO *static_link = TaggedClosureRef::from_address(Address::ZERO).set_tag(cur_static_flag); @@ -129,4 +161,4 @@ impl ActivePlan for VMActivePlan { pub fn enqueue_roots(queue: &mut Q, object: ObjectReference) { queue.enqueue(object); -} \ No newline at end of file +} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/be34ab239bd53fa9ec85482df742b0d0df70250a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/be34ab239bd53fa9ec85482df742b0d0df70250a You're receiving 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 Jan 4 22:29:28 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Wed, 04 Jan 2023 17:29:28 -0500 Subject: [Git][ghc/ghc][wip/rts-configure-0] 13 commits: Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Message-ID: <63b5fdc873c63_f192a527b0157553@gitlab.mail> John Ericson pushed to branch wip/rts-configure-0 at Glasgow Haskell Compiler / GHC Commits: 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - cdfdfed2 by John Ericson at 2023-01-04T16:07:07-05:00 Remove RTS hack for configuring See the brand new Note [Undefined symbols in the RTS] for additional details. - - - - - e3e616c5 by John Ericson at 2023-01-04T17:20:11-05:00 Give the RTS it's own configure script Currently it doesn't do much anything, we are just trying to introduce it without breaking the build. Later, we will move functionality from the top-level configure script over to it. We need to bump Cabal for https://github.com/haskell/cabal/pull/8649; to facilitate and existing hack of skipping some configure checks for the RTS we now need to skip just *part* not *all* of the "post configure" hook, as running the configure script (which we definitely want to do) is also implemented as part of the "post configure" hook. But doing this requires exposing functionality that wasn't exposed before. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - boot - compiler/GHC/Data/EnumSet.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.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 - docs/users_guide/ghc_config.py.in - docs/users_guide/phases.rst - hadrian/README.md - hadrian/doc/flavours.md - hadrian/doc/testsuite.md - hadrian/hadrian.cabal - hadrian/src/Base.hs - hadrian/src/Flavour.hs - hadrian/src/Flavour/Type.hs - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Lint.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d0a146a5914f62414b1b09d88741bf0da7f277d9...e3e616c51061a51333773e1600f2174373975597 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d0a146a5914f62414b1b09d88741bf0da7f277d9...e3e616c51061a51333773e1600f2174373975597 You're receiving 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 Jan 4 23:01:02 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 04 Jan 2023 18:01:02 -0500 Subject: [Git][ghc/ghc][wip/t22695] Only store Name in FunRhs rather than Id with knot-tied fields Message-ID: <63b6052e96b3b_f192a527101603b@gitlab.mail> Matthew Pickering pushed to branch wip/t22695 at Glasgow Haskell Compiler / GHC Commits: 3ec60ef6 by Matthew Pickering at 2023-01-04T23:00:47+00:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - 15 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Match.hs-boot - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/Language/Haskell/Syntax/Expr.hs - + testsuite/tests/ghci/scripts/T22695.script - + testsuite/tests/ghci/scripts/T22695.stderr - testsuite/tests/ghci/scripts/all.T - testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -2002,7 +2002,7 @@ matchSeparator ThPatSplice = panic "unused" matchSeparator ThPatQuote = panic "unused" matchSeparator PatSyn = panic "unused" -pprMatchContext :: (Outputable (IdP p), UnXRec p) +pprMatchContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContext ctxt | want_an ctxt = text "an" <+> pprMatchContextNoun ctxt @@ -2013,10 +2013,10 @@ pprMatchContext ctxt want_an (ArrowMatchCtxt KappaExpr) = True want_an _ = False -pprMatchContextNoun :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNoun :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNoun (FunRhs {mc_fun=fun}) = text "equation for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNoun CaseAlt = text "case alternative" pprMatchContextNoun (LamCaseAlt lc_variant) = lamCaseKeyword lc_variant <+> text "alternative" @@ -2032,10 +2032,10 @@ pprMatchContextNoun (StmtCtxt ctxt) = text "pattern binding in" $$ pprAStmtContext ctxt pprMatchContextNoun PatSyn = text "pattern synonym declaration" -pprMatchContextNouns :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNouns :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNouns (FunRhs {mc_fun=fun}) = text "equations for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNouns PatBindGuards = text "pattern binding guards" pprMatchContextNouns (ArrowMatchCtxt c) = pprArrowMatchContextNouns c pprMatchContextNouns (StmtCtxt ctxt) = text "pattern bindings in" @@ -2056,7 +2056,7 @@ pprArrowMatchContextNouns (ArrowLamCaseAlt lc_variant) = lamCaseKeyword lc_varia pprArrowMatchContextNouns ctxt = pprArrowMatchContextNoun ctxt <> char 's' ----------------- -pprAStmtContext, pprStmtContext :: (Outputable (IdP p), UnXRec p) +pprAStmtContext, pprStmtContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsStmtContext p -> SDoc pprAStmtContext (HsDoStmt flavour) = pprAHsDoFlavour flavour pprAStmtContext ctxt = text "a" <+> pprStmtContext ctxt ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -863,7 +863,7 @@ mkSimpleGeneratedFunBind loc fun pats expr emptyLocalBinds] -- | Make a prefix, non-strict function 'HsMatchContext' -mkPrefixFunRhs :: LIdP p -> HsMatchContext p +mkPrefixFunRhs :: LIdP (NoGhcTc p) -> HsMatchContext p mkPrefixFunRhs n = FunRhs { mc_fun = n , mc_fixity = Prefix , mc_strictness = NoSrcStrict } ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -957,7 +957,7 @@ instance HiePass p => ToHie (HsMatchContext (GhcPass p)) where name' :: LocatedN Name name' = case hiePass @p of HieRn -> name - HieTc -> fmap varName name + HieTc -> name toHie (StmtCtxt a) = toHie a toHie _ = pure [] ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -927,14 +927,10 @@ instance Diagnostic TcRnMessage where same_rec_group_msg = text "it is defined and used in the same recursive group" TcRnMatchesHaveDiffNumArgs argsContext (MatchArgMatches match1 bad_matches) -> mkSimpleDecorated $ - (vcat [ pprArgsContext argsContext <+> + (vcat [ pprMatchContextNouns argsContext <+> text "have different numbers of arguments" , nest 2 (ppr (getLocA match1)) , nest 2 (ppr (getLocA (NE.head bad_matches)))]) - where - pprArgsContext = \case - EquationArgs name -> (text "Equations for" <+>) . quotes $ ppr name - PatternArgs matchCtx -> pprMatchContextNouns matchCtx TcRnCannotBindScopedTyVarInPatSig sig_tvs -> mkSimpleDecorated $ hang (text "You cannot bind scoped type variable" ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2094,7 +2094,7 @@ data TcRnMessage where typecheck/should_fail/T20768_fail -} TcRnMatchesHaveDiffNumArgs - :: !MatchArgsContext + :: !(HsMatchContext GhcTc) -- ^ Pattern match specifics -> !MatchArgBadMatches -> TcRnMessage ===================================== compiler/GHC/Tc/Gen/Arrow.hs ===================================== @@ -172,7 +172,6 @@ tc_cmd env in_cmd@(HsCmdCase x scrut matches) (stk, res_ty) tc_cmd env cmd@(HsCmdLamCase x lc_variant match) cmd_ty = addErrCtxt (cmdCtxt cmd) do { let match_ctxt = ArrowLamCaseAlt lc_variant - ; checkPatCounts (ArrowMatchCtxt match_ctxt) match ; (wrap, match') <- tcCmdMatchLambda env match_ctxt match cmd_ty ; return (mkHsCmdWrap wrap (HsCmdLamCase x lc_variant match')) } ===================================== compiler/GHC/Tc/Gen/Bind.hs ===================================== @@ -624,7 +624,7 @@ tcPolyCheck prag_fn -- See Note [Relevant bindings and the binder stack] setSrcSpanA bind_loc $ - tcMatchesFun (L nm_loc mono_id) matches + tcMatchesFun (L nm_loc (idName mono_id)) matches (mkCheckExpType rho_ty) -- We make a funny AbsBinds, abstracting over nothing, @@ -1263,18 +1263,14 @@ tcMonoBinds is_rec sig_fn no_gen | NonRecursive <- is_rec -- ...binder isn't mentioned in RHS , Nothing <- sig_fn name -- ...with no type signature = setSrcSpanA b_loc $ - do { ((co_fn, matches'), mono_id, _) <- fixM $ \ ~(_, _, rhs_ty) -> - -- See Note [fixM for rhs_ty in tcMonoBinds] - do { mono_id <- newLetBndr no_gen name ManyTy rhs_ty - ; (matches', rhs_ty') - <- tcInfer $ \ exp_ty -> + do { ((co_fn, matches'), rhs_ty') + <- tcInfer $ \ exp_ty -> tcExtendBinderStack [TcIdBndr_ExpType name exp_ty NotTopLevel] $ -- We extend the error context even for a non-recursive -- function so that in type error messages we show the -- type of the thing whose rhs we are type checking - tcMatchesFun (L nm_loc mono_id) matches exp_ty - ; return (matches', mono_id, rhs_ty') - } + tcMatchesFun (L nm_loc name) matches exp_ty + ; mono_id <- newLetBndr no_gen name ManyTy rhs_ty' ; return (unitBag $ L b_loc $ FunBind { fun_id = L nm_loc mono_id, @@ -1388,19 +1384,6 @@ correctly elaborate 'id'. But we want to /infer/ q's higher rank type. There seems to be no way to do this. So currently we only switch to inference when we have no signature for any of the binders. -Note [fixM for rhs_ty in tcMonoBinds] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -In order to create mono_id we need rhs_ty but we don't have it yet, -we only get it from tcMatchesFun later (which needs mono_id to put -into HsMatchContext for pretty printing). To solve this, create -a thunk of rhs_ty with fixM that we fill in later. - -This is fine only because neither newLetBndr or tcMatchesFun look -at the varType field of the Id. tcMatchesFun only looks at idName -of mono_id. - -Also see #20415 for the bigger picture of why tcMatchesFun needs -mono_id in the first place. -} @@ -1528,7 +1511,7 @@ tcRhs (TcFunBind info@(MBI { mbi_sig = mb_sig, mbi_mono_id = mono_id }) = tcExtendIdBinderStackForRhs [info] $ tcExtendTyVarEnvForRhs mb_sig $ do { traceTc "tcRhs: fun bind" (ppr mono_id $$ ppr (idType mono_id)) - ; (co_fn, matches') <- tcMatchesFun (L (noAnnSrcSpan loc) mono_id) + ; (co_fn, matches') <- tcMatchesFun (L (noAnnSrcSpan loc) (idName mono_id)) matches (mkCheckExpType $ idType mono_id) ; return ( FunBind { fun_id = L (noAnnSrcSpan loc) mono_id , fun_matches = matches' ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -31,7 +31,6 @@ module GHC.Tc.Gen.Match , tcBody , tcDoStmt , tcGuardStmt - , checkPatCounts ) where @@ -93,12 +92,12 @@ is used in error messages. It checks that all the equations have the same number of arguments before using @tcMatches@ to do the work. -} -tcMatchesFun :: LocatedN Id -- MatchContext Id +tcMatchesFun :: LocatedN Name -- MatchContext Id -> MatchGroup GhcRn (LHsExpr GhcRn) -> ExpRhoType -- Expected type of function -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) -- Returns type of body -tcMatchesFun fun_id matches exp_ty +tcMatchesFun fun_name matches exp_ty = do { -- Check that they all have the same no of arguments -- Location is in the monad, set the caller so that -- any inter-equation error messages get some vaguely @@ -106,9 +105,7 @@ tcMatchesFun fun_id matches exp_ty -- ann-grabbing, because we don't always have annotations in -- hand when we call tcMatchesFun... traceTc "tcMatchesFun" (ppr fun_name $$ ppr exp_ty) - -- We can't easily call checkPatCounts here because fun_id can be an - -- unfilled thunk - ; checkArgCounts fun_name matches + ; checkArgCounts what matches ; matchExpectedFunTys herald ctxt arity exp_ty $ \ pat_tys rhs_ty -> -- NB: exp_type may be polymorphic, but @@ -122,17 +119,11 @@ tcMatchesFun fun_id matches exp_ty -- a multiplicity argument, and scale accordingly. tcMatches match_ctxt pat_tys rhs_ty matches } where - fun_name = idName (unLoc fun_id) arity = matchGroupArity matches - herald = ExpectedFunTyMatches (NameThing fun_name) matches + herald = ExpectedFunTyMatches (NameThing (unLoc fun_name)) matches ctxt = GenSigCtxt -- Was: FunSigCtxt fun_name True -- But that's wrong for f :: Int -> forall a. blah - what = FunRhs { mc_fun = fun_id, mc_fixity = Prefix, mc_strictness = strictness } - -- Careful: this fun_id could be an unfilled - -- thunk from fixM in tcMonoBinds, so we're - -- not allowed to look at it, except for - -- idName. - -- See Note [fixM for rhs_ty in tcMonoBinds] + what = FunRhs { mc_fun = fun_name, mc_fixity = Prefix, mc_strictness = strictness } match_ctxt = MC { mc_what = what, mc_body = tcBody } strictness | [L _ match] <- unLoc $ mg_alts matches @@ -164,8 +155,7 @@ tcMatchLambda :: ExpectedFunTyOrigin -- see Note [Herald for matchExpectedFunTys -> ExpRhoType -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) tcMatchLambda herald match_ctxt match res_ty - = do { checkPatCounts (mc_what match_ctxt) match - ; matchExpectedFunTys herald GenSigCtxt n_pats res_ty $ \ pat_tys rhs_ty -> do + = do { matchExpectedFunTys herald GenSigCtxt n_pats res_ty $ \ pat_tys rhs_ty -> do -- checking argument counts since this is also used for \cases tcMatches match_ctxt pat_tys rhs_ty match } where @@ -1136,28 +1126,16 @@ the variables they bind into scope, and typecheck the thing_inside. \subsection{Errors and contexts} * * ************************************************************************ - - at checkArgCounts@ takes a @[RenamedMatch]@ and decides whether the same -number of args are used in each equation. -} +-- | @checkArgCounts@ takes a @[RenamedMatch]@ and decides whether the same +-- number of args are used in each equation. checkArgCounts :: AnnoBody body - => Name -> MatchGroup GhcRn (LocatedA (body GhcRn)) -> TcM () -checkArgCounts = check_match_pats . EquationArgs - --- @checkPatCounts@ takes a @[RenamedMatch]@ and decides whether the same --- number of patterns are used in each alternative -checkPatCounts :: AnnoBody body - => HsMatchContext GhcTc -> MatchGroup GhcRn (LocatedA (body GhcRn)) - -> TcM () -checkPatCounts = check_match_pats . PatternArgs - -check_match_pats :: AnnoBody body - => MatchArgsContext -> MatchGroup GhcRn (LocatedA (body GhcRn)) - -> TcM () -check_match_pats _ (MG { mg_alts = L _ [] }) + => HsMatchContext GhcTc -> MatchGroup GhcRn (LocatedA (body GhcRn)) + -> TcM () +checkArgs _ (MG { mg_alts = L _ [] }) = return () -check_match_pats matchContext (MG { mg_alts = L _ (match1:matches) }) +checkArgCounts matchContext (MG { mg_alts = L _ (match1:matches) }) | Just bad_matches <- mb_bad_matches = failWithTc $ TcRnMatchesHaveDiffNumArgs matchContext $ MatchArgMatches match1 bad_matches ===================================== compiler/GHC/Tc/Gen/Match.hs-boot ===================================== @@ -5,13 +5,13 @@ import GHC.Tc.Utils.TcType( ExpSigmaType, ExpRhoType ) import GHC.Tc.Types ( TcM ) import GHC.Hs.Extension ( GhcRn, GhcTc ) import GHC.Parser.Annotation ( LocatedN ) -import GHC.Types.Id (Id) +import GHC.Types.Name (Name) tcGRHSsPat :: GRHSs GhcRn (LHsExpr GhcRn) -> ExpRhoType -> TcM (GRHSs GhcTc (LHsExpr GhcTc)) -tcMatchesFun :: LocatedN Id +tcMatchesFun :: LocatedN Name -> MatchGroup GhcRn (LHsExpr GhcRn) -> ExpSigmaType -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -838,7 +838,7 @@ tcPatSynMatcher (L loc ps_name) lpat prag_fn args body] , mg_ext = MatchGroupTc (map unrestricted [pat_ty, cont_ty, fail_ty]) res_ty Generated } - match = mkMatch (mkPrefixFunRhs (L loc patsyn_id)) [] + match = mkMatch (mkPrefixFunRhs (L loc (idName patsyn_id))) [] (mkHsLams (rr_tv:res_tv:univ_tvs) req_dicts body') (EmptyLocalBinds noExtField) ===================================== compiler/Language/Haskell/Syntax/Expr.hs ===================================== @@ -1533,7 +1533,9 @@ data HsMatchContext p = FunRhs -- ^ A pattern matching on an argument of a -- function binding - { mc_fun :: LIdP p -- ^ function binder of @f@ + { mc_fun :: LIdP (NoGhcTc p) -- ^ function binder of @f@ + -- See #20415 for a long discussion about + -- this field and why it uses NoGhcTc. , mc_fixity :: LexicalFixity -- ^ fixing of @f@ , mc_strictness :: SrcStrictness -- ^ was @f@ banged? -- See Note [FunBind vs PatBind] ===================================== testsuite/tests/ghci/scripts/T22695.script ===================================== @@ -0,0 +1 @@ +test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/T22695.stderr ===================================== @@ -0,0 +1,8 @@ + +:1:10: error: + • The constructor ‘Just’ should have 1 argument, but has been given none + • In the pattern: Just + In a stmt of a pattern guard for + an equation for ‘test’: + Just <- x + In an equation for ‘test’: test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -370,3 +370,4 @@ test('T21110', [extra_files(['T21110A.hs'])], ghci_script, test('T17830', [filter_stdout_lines(r'======.*')], ghci_script, ['T17830.script']) test('T21294a', normal, ghci_script, ['T21294a.script']) test('T21507', normal, ghci_script, ['T21507.script']) +test('T22695', normal, ghci_script, ['T22695.script']) ===================================== testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr ===================================== @@ -1560,7 +1560,7 @@ (FunRhs (L (SrcSpanAnn (EpAnnNotUsed) { DumpTypecheckedAst.hs:19:1-4 }) - {Var: main}) + {Name: main}) (Prefix) (NoSrcStrict)) [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3ec60ef6842cc2d3965e2652980f9b589a0ca4ba -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3ec60ef6842cc2d3965e2652980f9b589a0ca4ba You're receiving 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 Jan 4 23:38:29 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 04 Jan 2023 18:38:29 -0500 Subject: [Git][ghc/ghc][wip/t22599] debugging Message-ID: <63b60df57bd41_f192a527241674d7@gitlab.mail> Matthew Pickering pushed to branch wip/t22599 at Glasgow Haskell Compiler / GHC Commits: ecf3f5b5 by Matthew Pickering at 2023-01-04T23:38:20+00:00 debugging - - - - - 2 changed files: - .gitlab/ci.sh - + a.cpp Changes: ===================================== .gitlab/ci.sh ===================================== @@ -213,6 +213,10 @@ function set_toolchain_paths() { x86_64-darwin|aarch64-darwin) ;; *) fail "unknown NIX_SYSTEM" ;; esac + clang++ -v a.cpp + clang++ -v a.o -o a + clang -v a.o c++ -lc++abi + nix-build .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh cat toolchain.sh fi ===================================== a.cpp ===================================== @@ -0,0 +1,5 @@ +#include +int main(int argc, char** argv) { + std::cout << "hello world\n"; + return 0; +} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ecf3f5b569630f895982b088b27f9261f22ea4b8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ecf3f5b569630f895982b088b27f9261f22ea4b8 You're receiving 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 Jan 5 00:00:58 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 04 Jan 2023 19:00:58 -0500 Subject: [Git][ghc/ghc][wip/t22599] debugging Message-ID: <63b6133af48e_f192a526c01683e3@gitlab.mail> Matthew Pickering pushed to branch wip/t22599 at Glasgow Haskell Compiler / GHC Commits: 553f5053 by Matthew Pickering at 2023-01-05T00:00:48+00:00 debugging - - - - - 1 changed file: - .gitlab/ci.sh Changes: ===================================== .gitlab/ci.sh ===================================== @@ -213,9 +213,9 @@ function set_toolchain_paths() { x86_64-darwin|aarch64-darwin) ;; *) fail "unknown NIX_SYSTEM" ;; esac - clang++ -v a.cpp + clang++ -v a.cpp -o a.o clang++ -v a.o -o a - clang -v a.o c++ -lc++abi + clang -v a.o c++ -lc++abi -o a nix-build .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh cat toolchain.sh View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/553f5053997197f32d5aa4750066c6731e5faba7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/553f5053997197f32d5aa4750066c6731e5faba7 You're receiving 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 Jan 5 08:14:18 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Thu, 05 Jan 2023 03:14:18 -0500 Subject: [Git][ghc/ghc][wip/int-index/tok-at-app-kind] 139 commits: Document TH splices' interaction with INCOHERENT instances Message-ID: <63b686da8762_f192a5931d04214682@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/tok-at-app-kind 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 - - - - - 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 - - - - - 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]. - - - - - 2eb0fb87 by Matthew Pickering at 2022-12-15T03:54:39-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 - - - - - 552b7908 by Ben Gamari at 2022-12-15T03:55:15-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. - - - - - 933d61a4 by Simon Peyton Jones at 2022-12-15T03:55:51-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. - - - - - 03ed0b95 by Ryan Scott at 2022-12-15T03:56:26-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. - - - - - ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/ThreadPaused: Ordering fixes - - - - - 914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00 eventlog: Silence spurious data race - - - - - fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts: Use fences instead of explicit barriers - - - - - 2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - 70999283 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 98689f77 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - 86f20258 by Ben Gamari at 2022-12-16T16:12:45-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. - - - - - f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate access to capabilities array - - - - - 7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate sched_state - - - - - 1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Style fix - - - - - 82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00 compiler: Use release store in eager blackholing - - - - - eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Fix ordering of makeStableName - - - - - ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Note race with wakeBlockingQueue - - - - - 5acf33dd by Bodigrim at 2022-12-16T16:13:22-05:00 Bump submodule directory to 1.3.8.0 and hpc to HEAD - - - - - 0dd95421 by Bodigrim at 2022-12-16T16:13:22-05:00 Accept allocations increase on Windows This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips between lists and ByteArray. See #22625 for discussion. Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T10547 T12150 T12227 T12234 T12425 T13035 T13253 T13253-spj T13701 T13719 T15703 T16875 T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T21839r T5837 T6048 T9198 T9961 TcPlugin_RewritePerf hard_hole_fits - - - - - ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00 testsuite: Mark T9405 as fragile instead of broken on Windows It's starting to pass again, and the unexpected pass blocks CI. - - - - - 1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: remove obsolete commented code in wasm NCG It was just a temporary hack to workaround a bug in the relooper, that bug has been fixed long before the wasm backend is merged. - - - - - e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm Also removes some unreachable code here. - - - - - 1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: change fallback function signature to Cmm function signature in wasm NCG In the wasm NCG, when handling a `CLabel` of undefined function without knowing its function signature, we used to fallback to `() -> ()` which is accepted by `wasm-ld`. This patch changes it to the signature of Cmm functions, which equally works, but would be required when we emit tail call instructions. - - - - - 8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add optional tail-call support in wasm NCG When the `-mtail-call` clang flag is passed at configure time, wasm tail-call extension is enabled, and the wasm NCG will emit `return_call`/`return_call_indirect` instructions to take advantage of it and avoid the `StgRun` trampoline overhead. Closes #22461. - - - - - d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00 base: add missing autoconf checks for waitpid/umask These are not present in wasi-libc. Required for fixing #22589 - - - - - da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00 compiler: make .wasm the default executable extension on wasm32 Following convention as in other wasm toolchains. Fixes #22594. - - - - - ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00 ci: support hello.wasm in ci.sh cross testing logic - - - - - 6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00 Correct `exitWith` Haddocks The `IOError`-specific `catch` in the Prelude is long gone. - - - - - b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-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. - - - - - 761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00 rts/libdw: Silence uninitialized usage warnings As noted in #22538, previously some GCC versions warned that various locals in Libdw.c may be used uninitialized. Although this wasn't strictly true (since they were initialized in an inline assembler block) we fix this by providing explicit empty initializers. Fixes #22538 - - - - - 5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00 testsuite: Mark T16392 as fragile on windows See #22649 - - - - - 703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00 Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`. - - - - - 9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05: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 - - - - - 7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Drop uses of AC_PROG_CC_C99 As noted in #22566, this macro is deprecated as of autoconf-2.70 `AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself. Closes #22566. - - - - - 36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Use AS_HELP_STRING instead of AC_HELP_STRING The latter has been deprecated. See #22566. - - - - - befe6ff8 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: fix various usages of head and tail - - - - - 666d0ba7 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: avoid head and tail in parseCallEscape and around - - - - - 5d96fd50 by Bodigrim at 2022-12-20T21:16:37-05:00 Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty - - - - - 3ce2ab94 by Bodigrim at 2022-12-21T06:17:56-05:00 Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian - - - - - 954de93a by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule haskeline to HEAD (to allow transformers-0.6) - - - - - cefbeec3 by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule transformers to 0.6.0.4 - - - - - b4730b62 by Bodigrim at 2022-12-21T06:17:56-05:00 Fix tests T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations Metric Increase: T13253 - - - - - 0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05: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. - - - - - df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00 rts: explicitly store return value of ccall checkClosure to prevent type error (#22617) - - - - - e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix shadowing lacuna in OccurAnal Issue #22623 demonstrated another lacuna in the implementation of wrinkle (BS3) in Note [The binder-swap substitution] in the occurrence analyser. I was failing to add TyVar lambda binders using addInScope/addOneInScope and that led to a totally bogus binder-swap transformation. Very easy to fix. - - - - - 3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix an assertion check in addToEqualCtList The old assertion saw that a constraint ct could rewrite itself (of course it can) and complained (stupid). Fixes #22645 - - - - - ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00 configure: Bump version to 9.6 - - - - - fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00 base: Bump version to 4.18 Requires various submodule bumps. - - - - - 93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00 ghc-boot: Fix bootstrapping - - - - - fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00 Bump GHC version to 9.7 - - - - - 914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05: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. - - - - - 32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00 hadrian bindist: Install manpages to share/man/man1/ghc.1 When the installation makefile was copied over the manpages were no longer installed in the correct place. Now we install it into share/man/man1/ghc.1 as the make build system did. Fixes #22371 - - - - - b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00 rts: Drop paths from configure from cabal file A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them. - - - - - b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00 Bump libffi-tarballs submodule We will now use libffi-3.4.4. - - - - - 3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00 EPA: Make EOF position part of AnnsModule Closes #20951 Closes #19697 - - - - - 99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00 JS: fix support for -outputdir (#22641) The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug. - - - - - 02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00 Refactor mkRuntimeError This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions. - - - - - 35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00 base: Fix event manager shutdown race on non-Linux platforms During shutdown it's possible that we will attempt to use a closed fd to wakeup another capability's event manager. On the Linux eventfd path we were careful to handle this. However on the non-Linux path we failed to do so. Fix this. - - - - - 317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00 Fix unifier bug: failing to decompose over-saturated type family This simple patch fixes #22647 - - - - - 14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00 rts/m32: Fix sanity checking Previously we would attempt to clear pages which were marked as read-only. Fix this. - - - - - 16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00 ci: Move wasm pipelines into nightly rather than master See #22664 for the changes which need to be made to bring one of these back to the validate pipeline. - - - - - 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-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). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Bodigrim at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - ae126613 by Vladislav Zavialov at 2023-01-05T11:14:07+03:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info/Build.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.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Wasm.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 - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4c9bc4fdfed32033a2cd2717099cc59ffb193af7...ae126613f28805b239783b122be6b751fd82bbc9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4c9bc4fdfed32033a2cd2717099cc59ffb193af7...ae126613f28805b239783b122be6b751fd82bbc9 You're receiving 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 Jan 5 09:13:21 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 05 Jan 2023 04:13:21 -0500 Subject: [Git][ghc/ghc][wip/t22599] testing Message-ID: <63b694b173767_f192a310829c2211b@gitlab.mail> Matthew Pickering pushed to branch wip/t22599 at Glasgow Haskell Compiler / GHC Commits: b5c10e9e by Matthew Pickering at 2023-01-05T09:13:10+00:00 testing - - - - - 1 changed file: - .gitlab/ci.sh Changes: ===================================== .gitlab/ci.sh ===================================== @@ -213,11 +213,17 @@ function set_toolchain_paths() { x86_64-darwin|aarch64-darwin) ;; *) fail "unknown NIX_SYSTEM" ;; esac - clang++ -v a.cpp -o a.o - clang++ -v a.o -o a - clang -v a.o c++ -lc++abi -o a - nix-build .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh + if [ "$NIX_SYSTEM" -eq "aarch64-darwin" ]; + then ARCH="arm64"; + else ARCH="x86_64"; + fi + + arch -arm64 clang++ -v a.cpp -o a.o + arch -arm64 clang++ -v a.o -o a + arch -arm64 clang -v a.o c++ -lc++abi -o a + + arch "-$ARCH" nix-build .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh cat toolchain.sh fi source toolchain.sh ;; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b5c10e9ec0fafea199a53c543107ba8ed391d2e9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b5c10e9ec0fafea199a53c543107ba8ed391d2e9 You're receiving 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 Jan 5 09:17:30 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 05 Jan 2023 04:17:30 -0500 Subject: [Git][ghc/ghc][wip/T22662] 15 commits: Drop support for kind constraints. Message-ID: <63b695aad5bf5_f192a52760221655@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22662 at Glasgow Haskell Compiler / GHC Commits: 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Bodigrim at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - f160919c by Simon Peyton Jones at 2023-01-05T09:17:53+00:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/EnumSet.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/DocString.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/Utils/Unify.hs-boot - compiler/GHC/Tc/Validity.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Types/FieldLabel.hs - compiler/GHC/Types/Name.hs-boot The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/145644b361a9e5621009d9bd4e43b1f8450a224e...f160919c8772a85d8884acc89a748bec17c5641f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/145644b361a9e5621009d9bd4e43b1f8450a224e...f160919c8772a85d8884acc89a748bec17c5641f You're receiving 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 Jan 5 09:19:56 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 05 Jan 2023 04:19:56 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/centos7-revert Message-ID: <63b6963c30a8b_f192a526c02259b8@gitlab.mail> Matthew Pickering pushed new branch wip/centos7-revert at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/centos7-revert You're receiving 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 Jan 5 09:33:12 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 05 Jan 2023 04:33:12 -0500 Subject: [Git][ghc/ghc][wip/t22695] Only store Name in FunRhs rather than Id with knot-tied fields Message-ID: <63b699587f67c_f192a527b02304e6@gitlab.mail> Matthew Pickering pushed to branch wip/t22695 at Glasgow Haskell Compiler / GHC Commits: 0ea1c3da by Matthew Pickering at 2023-01-05T09:32:56+00:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - 15 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Match.hs-boot - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/Language/Haskell/Syntax/Expr.hs - + testsuite/tests/ghci/scripts/T22695.script - + testsuite/tests/ghci/scripts/T22695.stderr - testsuite/tests/ghci/scripts/all.T - testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -2002,7 +2002,7 @@ matchSeparator ThPatSplice = panic "unused" matchSeparator ThPatQuote = panic "unused" matchSeparator PatSyn = panic "unused" -pprMatchContext :: (Outputable (IdP p), UnXRec p) +pprMatchContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContext ctxt | want_an ctxt = text "an" <+> pprMatchContextNoun ctxt @@ -2013,10 +2013,10 @@ pprMatchContext ctxt want_an (ArrowMatchCtxt KappaExpr) = True want_an _ = False -pprMatchContextNoun :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNoun :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNoun (FunRhs {mc_fun=fun}) = text "equation for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNoun CaseAlt = text "case alternative" pprMatchContextNoun (LamCaseAlt lc_variant) = lamCaseKeyword lc_variant <+> text "alternative" @@ -2032,10 +2032,10 @@ pprMatchContextNoun (StmtCtxt ctxt) = text "pattern binding in" $$ pprAStmtContext ctxt pprMatchContextNoun PatSyn = text "pattern synonym declaration" -pprMatchContextNouns :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNouns :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNouns (FunRhs {mc_fun=fun}) = text "equations for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNouns PatBindGuards = text "pattern binding guards" pprMatchContextNouns (ArrowMatchCtxt c) = pprArrowMatchContextNouns c pprMatchContextNouns (StmtCtxt ctxt) = text "pattern bindings in" @@ -2056,7 +2056,7 @@ pprArrowMatchContextNouns (ArrowLamCaseAlt lc_variant) = lamCaseKeyword lc_varia pprArrowMatchContextNouns ctxt = pprArrowMatchContextNoun ctxt <> char 's' ----------------- -pprAStmtContext, pprStmtContext :: (Outputable (IdP p), UnXRec p) +pprAStmtContext, pprStmtContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsStmtContext p -> SDoc pprAStmtContext (HsDoStmt flavour) = pprAHsDoFlavour flavour pprAStmtContext ctxt = text "a" <+> pprStmtContext ctxt ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -863,7 +863,7 @@ mkSimpleGeneratedFunBind loc fun pats expr emptyLocalBinds] -- | Make a prefix, non-strict function 'HsMatchContext' -mkPrefixFunRhs :: LIdP p -> HsMatchContext p +mkPrefixFunRhs :: LIdP (NoGhcTc p) -> HsMatchContext p mkPrefixFunRhs n = FunRhs { mc_fun = n , mc_fixity = Prefix , mc_strictness = NoSrcStrict } ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -957,7 +957,7 @@ instance HiePass p => ToHie (HsMatchContext (GhcPass p)) where name' :: LocatedN Name name' = case hiePass @p of HieRn -> name - HieTc -> fmap varName name + HieTc -> name toHie (StmtCtxt a) = toHie a toHie _ = pure [] ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -927,14 +927,10 @@ instance Diagnostic TcRnMessage where same_rec_group_msg = text "it is defined and used in the same recursive group" TcRnMatchesHaveDiffNumArgs argsContext (MatchArgMatches match1 bad_matches) -> mkSimpleDecorated $ - (vcat [ pprArgsContext argsContext <+> + (vcat [ pprMatchContextNouns argsContext <+> text "have different numbers of arguments" , nest 2 (ppr (getLocA match1)) , nest 2 (ppr (getLocA (NE.head bad_matches)))]) - where - pprArgsContext = \case - EquationArgs name -> (text "Equations for" <+>) . quotes $ ppr name - PatternArgs matchCtx -> pprMatchContextNouns matchCtx TcRnCannotBindScopedTyVarInPatSig sig_tvs -> mkSimpleDecorated $ hang (text "You cannot bind scoped type variable" ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2094,7 +2094,7 @@ data TcRnMessage where typecheck/should_fail/T20768_fail -} TcRnMatchesHaveDiffNumArgs - :: !MatchArgsContext + :: !(HsMatchContext GhcTc) -- ^ Pattern match specifics -> !MatchArgBadMatches -> TcRnMessage ===================================== compiler/GHC/Tc/Gen/Arrow.hs ===================================== @@ -172,7 +172,7 @@ tc_cmd env in_cmd@(HsCmdCase x scrut matches) (stk, res_ty) tc_cmd env cmd@(HsCmdLamCase x lc_variant match) cmd_ty = addErrCtxt (cmdCtxt cmd) do { let match_ctxt = ArrowLamCaseAlt lc_variant - ; checkPatCounts (ArrowMatchCtxt match_ctxt) match + ; checkArgCounts (ArrowMatchCtxt match_ctxt) match ; (wrap, match') <- tcCmdMatchLambda env match_ctxt match cmd_ty ; return (mkHsCmdWrap wrap (HsCmdLamCase x lc_variant match')) } ===================================== compiler/GHC/Tc/Gen/Bind.hs ===================================== @@ -624,7 +624,7 @@ tcPolyCheck prag_fn -- See Note [Relevant bindings and the binder stack] setSrcSpanA bind_loc $ - tcMatchesFun (L nm_loc mono_id) matches + tcMatchesFun (L nm_loc (idName mono_id)) matches (mkCheckExpType rho_ty) -- We make a funny AbsBinds, abstracting over nothing, @@ -1263,18 +1263,14 @@ tcMonoBinds is_rec sig_fn no_gen | NonRecursive <- is_rec -- ...binder isn't mentioned in RHS , Nothing <- sig_fn name -- ...with no type signature = setSrcSpanA b_loc $ - do { ((co_fn, matches'), mono_id, _) <- fixM $ \ ~(_, _, rhs_ty) -> - -- See Note [fixM for rhs_ty in tcMonoBinds] - do { mono_id <- newLetBndr no_gen name ManyTy rhs_ty - ; (matches', rhs_ty') - <- tcInfer $ \ exp_ty -> + do { ((co_fn, matches'), rhs_ty') + <- tcInfer $ \ exp_ty -> tcExtendBinderStack [TcIdBndr_ExpType name exp_ty NotTopLevel] $ -- We extend the error context even for a non-recursive -- function so that in type error messages we show the -- type of the thing whose rhs we are type checking - tcMatchesFun (L nm_loc mono_id) matches exp_ty - ; return (matches', mono_id, rhs_ty') - } + tcMatchesFun (L nm_loc name) matches exp_ty + ; mono_id <- newLetBndr no_gen name ManyTy rhs_ty' ; return (unitBag $ L b_loc $ FunBind { fun_id = L nm_loc mono_id, @@ -1388,19 +1384,6 @@ correctly elaborate 'id'. But we want to /infer/ q's higher rank type. There seems to be no way to do this. So currently we only switch to inference when we have no signature for any of the binders. -Note [fixM for rhs_ty in tcMonoBinds] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -In order to create mono_id we need rhs_ty but we don't have it yet, -we only get it from tcMatchesFun later (which needs mono_id to put -into HsMatchContext for pretty printing). To solve this, create -a thunk of rhs_ty with fixM that we fill in later. - -This is fine only because neither newLetBndr or tcMatchesFun look -at the varType field of the Id. tcMatchesFun only looks at idName -of mono_id. - -Also see #20415 for the bigger picture of why tcMatchesFun needs -mono_id in the first place. -} @@ -1528,7 +1511,7 @@ tcRhs (TcFunBind info@(MBI { mbi_sig = mb_sig, mbi_mono_id = mono_id }) = tcExtendIdBinderStackForRhs [info] $ tcExtendTyVarEnvForRhs mb_sig $ do { traceTc "tcRhs: fun bind" (ppr mono_id $$ ppr (idType mono_id)) - ; (co_fn, matches') <- tcMatchesFun (L (noAnnSrcSpan loc) mono_id) + ; (co_fn, matches') <- tcMatchesFun (L (noAnnSrcSpan loc) (idName mono_id)) matches (mkCheckExpType $ idType mono_id) ; return ( FunBind { fun_id = L (noAnnSrcSpan loc) mono_id , fun_matches = matches' ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -31,7 +31,7 @@ module GHC.Tc.Gen.Match , tcBody , tcDoStmt , tcGuardStmt - , checkPatCounts + , checkArgCounts ) where @@ -93,12 +93,12 @@ is used in error messages. It checks that all the equations have the same number of arguments before using @tcMatches@ to do the work. -} -tcMatchesFun :: LocatedN Id -- MatchContext Id +tcMatchesFun :: LocatedN Name -- MatchContext Id -> MatchGroup GhcRn (LHsExpr GhcRn) -> ExpRhoType -- Expected type of function -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) -- Returns type of body -tcMatchesFun fun_id matches exp_ty +tcMatchesFun fun_name matches exp_ty = do { -- Check that they all have the same no of arguments -- Location is in the monad, set the caller so that -- any inter-equation error messages get some vaguely @@ -106,9 +106,7 @@ tcMatchesFun fun_id matches exp_ty -- ann-grabbing, because we don't always have annotations in -- hand when we call tcMatchesFun... traceTc "tcMatchesFun" (ppr fun_name $$ ppr exp_ty) - -- We can't easily call checkPatCounts here because fun_id can be an - -- unfilled thunk - ; checkArgCounts fun_name matches + ; checkArgCounts what matches ; matchExpectedFunTys herald ctxt arity exp_ty $ \ pat_tys rhs_ty -> -- NB: exp_type may be polymorphic, but @@ -122,17 +120,11 @@ tcMatchesFun fun_id matches exp_ty -- a multiplicity argument, and scale accordingly. tcMatches match_ctxt pat_tys rhs_ty matches } where - fun_name = idName (unLoc fun_id) arity = matchGroupArity matches - herald = ExpectedFunTyMatches (NameThing fun_name) matches + herald = ExpectedFunTyMatches (NameThing (unLoc fun_name)) matches ctxt = GenSigCtxt -- Was: FunSigCtxt fun_name True -- But that's wrong for f :: Int -> forall a. blah - what = FunRhs { mc_fun = fun_id, mc_fixity = Prefix, mc_strictness = strictness } - -- Careful: this fun_id could be an unfilled - -- thunk from fixM in tcMonoBinds, so we're - -- not allowed to look at it, except for - -- idName. - -- See Note [fixM for rhs_ty in tcMonoBinds] + what = FunRhs { mc_fun = fun_name, mc_fixity = Prefix, mc_strictness = strictness } match_ctxt = MC { mc_what = what, mc_body = tcBody } strictness | [L _ match] <- unLoc $ mg_alts matches @@ -164,7 +156,7 @@ tcMatchLambda :: ExpectedFunTyOrigin -- see Note [Herald for matchExpectedFunTys -> ExpRhoType -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) tcMatchLambda herald match_ctxt match res_ty - = do { checkPatCounts (mc_what match_ctxt) match + = do { checkArgCounts (mc_what match_ctxt) match ; matchExpectedFunTys herald GenSigCtxt n_pats res_ty $ \ pat_tys rhs_ty -> do -- checking argument counts since this is also used for \cases tcMatches match_ctxt pat_tys rhs_ty match } @@ -1136,28 +1128,16 @@ the variables they bind into scope, and typecheck the thing_inside. \subsection{Errors and contexts} * * ************************************************************************ - - at checkArgCounts@ takes a @[RenamedMatch]@ and decides whether the same -number of args are used in each equation. -} +-- | @checkArgCounts@ takes a @[RenamedMatch]@ and decides whether the same +-- number of args are used in each equation. checkArgCounts :: AnnoBody body - => Name -> MatchGroup GhcRn (LocatedA (body GhcRn)) -> TcM () -checkArgCounts = check_match_pats . EquationArgs - --- @checkPatCounts@ takes a @[RenamedMatch]@ and decides whether the same --- number of patterns are used in each alternative -checkPatCounts :: AnnoBody body - => HsMatchContext GhcTc -> MatchGroup GhcRn (LocatedA (body GhcRn)) - -> TcM () -checkPatCounts = check_match_pats . PatternArgs - -check_match_pats :: AnnoBody body - => MatchArgsContext -> MatchGroup GhcRn (LocatedA (body GhcRn)) - -> TcM () -check_match_pats _ (MG { mg_alts = L _ [] }) + => HsMatchContext GhcTc -> MatchGroup GhcRn (LocatedA (body GhcRn)) + -> TcM () +checkArgCounts _ (MG { mg_alts = L _ [] }) = return () -check_match_pats matchContext (MG { mg_alts = L _ (match1:matches) }) +checkArgCounts matchContext (MG { mg_alts = L _ (match1:matches) }) | Just bad_matches <- mb_bad_matches = failWithTc $ TcRnMatchesHaveDiffNumArgs matchContext $ MatchArgMatches match1 bad_matches ===================================== compiler/GHC/Tc/Gen/Match.hs-boot ===================================== @@ -5,13 +5,13 @@ import GHC.Tc.Utils.TcType( ExpSigmaType, ExpRhoType ) import GHC.Tc.Types ( TcM ) import GHC.Hs.Extension ( GhcRn, GhcTc ) import GHC.Parser.Annotation ( LocatedN ) -import GHC.Types.Id (Id) +import GHC.Types.Name (Name) tcGRHSsPat :: GRHSs GhcRn (LHsExpr GhcRn) -> ExpRhoType -> TcM (GRHSs GhcTc (LHsExpr GhcTc)) -tcMatchesFun :: LocatedN Id +tcMatchesFun :: LocatedN Name -> MatchGroup GhcRn (LHsExpr GhcRn) -> ExpSigmaType -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -838,7 +838,7 @@ tcPatSynMatcher (L loc ps_name) lpat prag_fn args body] , mg_ext = MatchGroupTc (map unrestricted [pat_ty, cont_ty, fail_ty]) res_ty Generated } - match = mkMatch (mkPrefixFunRhs (L loc patsyn_id)) [] + match = mkMatch (mkPrefixFunRhs (L loc (idName patsyn_id))) [] (mkHsLams (rr_tv:res_tv:univ_tvs) req_dicts body') (EmptyLocalBinds noExtField) ===================================== compiler/Language/Haskell/Syntax/Expr.hs ===================================== @@ -1533,7 +1533,10 @@ data HsMatchContext p = FunRhs -- ^ A pattern matching on an argument of a -- function binding - { mc_fun :: LIdP p -- ^ function binder of @f@ + { mc_fun :: LIdP (NoGhcTc p) -- ^ function binder of @f@ + -- See Note [mc_fun field of FunRhs] + -- See #20415 for a long discussion about + -- this field and why it uses NoGhcTc. , mc_fixity :: LexicalFixity -- ^ fixing of @f@ , mc_strictness :: SrcStrictness -- ^ was @f@ banged? -- See Note [FunBind vs PatBind] @@ -1560,6 +1563,21 @@ data HsMatchContext p | ThPatQuote -- ^A Template Haskell pattern quotation [p| (a,b) |] | PatSyn -- ^A pattern synonym declaration +{- +Note [mc_fun field of FunRhs] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The mc_fun field of FunRhs has type `LIdP (NoGhcTc p)`, which means it will be +a `RdrName` in pass `GhcPs`, a `Name` in `GhcRn`, and (importantly) still a +`Name` in `GhcTc` -- not an `Id`. See Note [NoGhcTc] in GHC.Hs.Extension. + +Why a `Name` in the typechecker phase? Because: +* A `Name` is all we need, as it turns out. +* Using an `Id` involves knot-tying in the monad, which led to #22695. + +See #20415 for a long discussion. + +-} + isPatSynCtxt :: HsMatchContext p -> Bool isPatSynCtxt ctxt = case ctxt of ===================================== testsuite/tests/ghci/scripts/T22695.script ===================================== @@ -0,0 +1 @@ +test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/T22695.stderr ===================================== @@ -0,0 +1,8 @@ + +:1:10: error: + • The constructor ‘Just’ should have 1 argument, but has been given none + • In the pattern: Just + In a stmt of a pattern guard for + an equation for ‘test’: + Just <- x + In an equation for ‘test’: test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -370,3 +370,4 @@ test('T21110', [extra_files(['T21110A.hs'])], ghci_script, test('T17830', [filter_stdout_lines(r'======.*')], ghci_script, ['T17830.script']) test('T21294a', normal, ghci_script, ['T21294a.script']) test('T21507', normal, ghci_script, ['T21507.script']) +test('T22695', normal, ghci_script, ['T22695.script']) ===================================== testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr ===================================== @@ -1560,7 +1560,7 @@ (FunRhs (L (SrcSpanAnn (EpAnnNotUsed) { DumpTypecheckedAst.hs:19:1-4 }) - {Var: main}) + {Name: main}) (Prefix) (NoSrcStrict)) [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0ea1c3da1cceef4280a483e6a3522e36b3ef638b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0ea1c3da1cceef4280a483e6a3522e36b3ef638b You're receiving 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 Jan 5 09:36:01 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 05 Jan 2023 04:36:01 -0500 Subject: [Git][ghc/ghc][wip/rts-configure-0] Add rts/configure to source dist Message-ID: <63b69a0121839_f192a527b0230877@gitlab.mail> Matthew Pickering pushed to branch wip/rts-configure-0 at Glasgow Haskell Compiler / GHC Commits: 59e112cd by Matthew Pickering at 2023-01-05T09:35:51+00:00 Add rts/configure to source dist - - - - - 1 changed file: - hadrian/src/Rules/SourceDist.hs Changes: ===================================== hadrian/src/Rules/SourceDist.hs ===================================== @@ -142,7 +142,8 @@ prepareTree dest = do moveFile (dest -/- "boot") (dest -/- "boot.source") bootFiles = - [ pkgPath process -/- "include" -/- "HsProcessConfig.h.in" + [ pkgPath rts -/- "configure" + , pkgPath process -/- "include" -/- "HsProcessConfig.h.in" , pkgPath process -/- "configure" , pkgPath ghcBignum -/- "configure" , pkgPath base -/- "configure" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/59e112cddbdda5e38f32df3f954f83d2a37ac783 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/59e112cddbdda5e38f32df3f954f83d2a37ac783 You're receiving 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 Jan 5 10:09:13 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 05 Jan 2023 05:09:13 -0500 Subject: [Git][ghc/ghc][wip/T22662] Make FloatIn robust to shadowing Message-ID: <63b6a1c9308c8_f192a15ac0e5824036f@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22662 at Glasgow Haskell Compiler / GHC Commits: 0bb5cbf5 by Simon Peyton Jones at 2023-01-05T10:09:34+00:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - 3 changed files: - compiler/GHC/Core/Opt/FloatIn.hs - + testsuite/tests/simplCore/should_compile/T22662.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/FloatIn.hs ===================================== @@ -35,9 +35,12 @@ import GHC.Types.Var import GHC.Types.Var.Set import GHC.Utils.Misc -import GHC.Utils.Panic import GHC.Utils.Panic.Plain +import GHC.Utils.Outputable + +import Data.List ( mapAccumL ) + {- Top-level interface function, @floatInwards at . Note that we do not actually float any bindings downwards from the top-level. @@ -124,7 +127,7 @@ the closure for a is not built. ************************************************************************ -} -type FreeVarSet = DIdSet +type FreeVarSet = DVarSet type BoundVarSet = DIdSet data FloatInBind = FB BoundVarSet FreeVarSet FloatBind @@ -132,11 +135,17 @@ data FloatInBind = FB BoundVarSet FreeVarSet FloatBind -- of recursive bindings, the set doesn't include the bound -- variables. -type FloatInBinds = [FloatInBind] - -- In reverse dependency order (innermost binder first) +type FloatInBinds = [FloatInBind] -- In normal dependency order + -- (outermost binder first) +type RevFloatInBinds = [FloatInBind] -- In reverse dependency order + -- (innermost binder first) + +instance Outputable FloatInBind where + ppr (FB bvs fvs _) = text "FB" <> braces (sep [ text "bndrs =" <+> ppr bvs + , text "fvs =" <+> ppr fvs ]) fiExpr :: Platform - -> FloatInBinds -- Binds we're trying to drop + -> RevFloatInBinds -- Binds we're trying to drop -- as far "inwards" as possible -> CoreExprWithFVs -- Input expr -> CoreExpr -- Result @@ -147,13 +156,12 @@ fiExpr _ to_drop (_, AnnType ty) = assert (null to_drop) $ Type ty fiExpr _ to_drop (_, AnnVar v) = wrapFloats to_drop (Var v) fiExpr _ to_drop (_, AnnCoercion co) = wrapFloats to_drop (Coercion co) fiExpr platform to_drop (_, AnnCast expr (co_ann, co)) - = wrapFloats (drop_here ++ co_drop) $ + = wrapFloats drop_here $ Cast (fiExpr platform e_drop expr) co where - [drop_here, e_drop, co_drop] - = sepBindsByDropPoint platform False - [freeVarsOf expr, freeVarsOfAnn co_ann] - to_drop + (drop_here, [e_drop]) + = sepBindsByDropPoint platform False to_drop + (freeVarsOfAnn co_ann) [freeVarsOf expr] {- Applications: we do float inside applications, mainly because we @@ -162,7 +170,7 @@ pull out any silly ones. -} fiExpr platform to_drop ann_expr@(_,AnnApp {}) - = wrapFloats drop_here $ wrapFloats extra_drop $ + = wrapFloats drop_here $ mkTicks ticks $ mkApps (fiExpr platform fun_drop ann_fun) (zipWithEqual "fiExpr" (fiExpr platform) arg_drops ann_args) @@ -170,21 +178,19 @@ fiExpr platform to_drop ann_expr@(_,AnnApp {}) -- length ann_args = length arg_fvs = length arg_drops where (ann_fun, ann_args, ticks) = collectAnnArgsTicks tickishFloatable ann_expr - fun_ty = exprType (deAnnotate ann_fun) fun_fvs = freeVarsOf ann_fun - arg_fvs = map freeVarsOf ann_args - (drop_here : extra_drop : fun_drop : arg_drops) - = sepBindsByDropPoint platform False - (extra_fvs : fun_fvs : arg_fvs) - to_drop + (drop_here, fun_drop : arg_drops) + = sepBindsByDropPoint platform False to_drop + here_fvs (fun_fvs : arg_fvs) + -- Shortcut behaviour: if to_drop is empty, -- sepBindsByDropPoint returns a suitable bunch of empty -- lists without evaluating extra_fvs, and hence without -- peering into each argument - (_, extra_fvs) = foldl' add_arg (fun_ty, extra_fvs0) ann_args - extra_fvs0 = case ann_fun of + (here_fvs, arg_fvs) = mapAccumL add_arg here_fvs0 ann_args + here_fvs0 = case ann_fun of (_, AnnVar _) -> fun_fvs _ -> emptyDVarSet -- Don't float the binding for f into f x y z; see Note [Join points] @@ -192,14 +198,11 @@ fiExpr platform to_drop ann_expr@(_,AnnApp {}) -- join point, floating it in isn't especially harmful but it's -- useless since the simplifier will immediately float it back out.) - add_arg :: (Type,FreeVarSet) -> CoreExprWithFVs -> (Type,FreeVarSet) - add_arg (fun_ty, extra_fvs) (_, AnnType ty) - = (piResultTy fun_ty ty, extra_fvs) - add_arg (fun_ty, extra_fvs) (arg_fvs, arg) - | noFloatIntoArg arg - = (funResultTy fun_ty, extra_fvs `unionDVarSet` arg_fvs) - | otherwise - = (funResultTy fun_ty, extra_fvs) + add_arg :: FreeVarSet -> CoreExprWithFVs -> (FreeVarSet,FreeVarSet) + -- We can't float into some arguments, so put them into the here_fvs + add_arg here_fvs (arg_fvs, arg) + | noFloatIntoArg arg = (here_fvs `unionDVarSet` arg_fvs, emptyDVarSet) + | otherwise = (here_fvs, arg_fvs) {- Note [Dead bindings] ~~~~~~~~~~~~~~~~~~~~~~~ @@ -272,7 +275,6 @@ it's non-recursive, so we float only into non-recursive join points.) Urk! if all are tyvars, and we don't float in, we may miss an opportunity to float inside a nested case branch - Note [Floating coercions] ~~~~~~~~~~~~~~~~~~~~~~~~~ We could, in principle, have a coercion binding like @@ -292,6 +294,36 @@ of the types of all the drop points involved. If any of the floaters bind a coercion variable mentioned in any of the types, that binder must be dropped right away. +Note [Shadowing and name capture] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we have + let x = y+1 in + case p of + (y:ys) -> ...x... + [] -> blah +It is obviously bogus for FloatIn to transform to + case p of + (y:ys) -> ...(let x = y+1 in x)... + [] -> blah +because the y is captured. This doesn't happen much, because shadowing is +rare, but it did happen in #22662. + +One solution would be to clone as we go. But a simpler one is this: + + at a binding site (like that for (y:ys) above), abandon float-in for + any floating bindings that mention the binders (y, ys in this case) + +We achieve that by calling sepBindsByDropPoint with the binders in +the "used-here" set: + +* In fiExpr (AnnLam ...). For the body there is no need to delete + the lambda-binders from the body_fvs, because any bindings that + mention these binders will be dropped here anyway. + +* In fiExpr (AnnCase ...). Remember to include the case_bndr in the + binders. Again, no need to delete the alt binders from the rhs + free vars, beause any bindings mentioning them will be dropped + here unconditionally. -} fiExpr platform to_drop lam@(_, AnnLam _ _) @@ -300,10 +332,17 @@ fiExpr platform to_drop lam@(_, AnnLam _ _) = wrapFloats to_drop (mkLams bndrs (fiExpr platform [] body)) | otherwise -- Float inside - = mkLams bndrs (fiExpr platform to_drop body) + = wrapFloats drop_here $ + mkLams bndrs (fiExpr platform body_drop body) where (bndrs, body) = collectAnnBndrs lam + body_fvs = freeVarsOf body + + -- Why sepBindsByDropPoint? Because of potential capture + -- See Note [Shadowing and name capture] + (drop_here, [body_drop]) = sepBindsByDropPoint platform False to_drop + (mkDVarSet bndrs) [body_fvs] {- We don't float lets inwards past an SCC. @@ -443,16 +482,16 @@ fiExpr platform to_drop (_, AnnCase scrut case_bndr _ [AnnAlt con alt_bndrs rhs] = wrapFloats shared_binds $ fiExpr platform (case_float : rhs_binds) rhs where - case_float = FB (mkDVarSet (case_bndr : alt_bndrs)) scrut_fvs + case_float = FB all_bndrs scrut_fvs (FloatCase scrut' case_bndr con alt_bndrs) scrut' = fiExpr platform scrut_binds scrut - rhs_fvs = freeVarsOf rhs `delDVarSetList` (case_bndr : alt_bndrs) - scrut_fvs = freeVarsOf scrut + rhs_fvs = freeVarsOf rhs -- No need to delete alt_bndrs + scrut_fvs = freeVarsOf scrut -- See Note [Shadowing and name capture] + all_bndrs = mkDVarSet alt_bndrs `extendDVarSet` case_bndr - [shared_binds, scrut_binds, rhs_binds] - = sepBindsByDropPoint platform False - [scrut_fvs, rhs_fvs] - to_drop + (shared_binds, [scrut_binds, rhs_binds]) + = sepBindsByDropPoint platform False to_drop + all_bndrs [scrut_fvs, rhs_fvs] fiExpr platform to_drop (_, AnnCase scrut case_bndr ty alts) = wrapFloats drop_here1 $ @@ -462,39 +501,43 @@ fiExpr platform to_drop (_, AnnCase scrut case_bndr ty alts) -- use zipWithEqual, we should have length alts_drops_s = length alts where -- Float into the scrut and alts-considered-together just like App - [drop_here1, scrut_drops, alts_drops] - = sepBindsByDropPoint platform False - [scrut_fvs, all_alts_fvs] - to_drop + (drop_here1, [scrut_drops, alts_drops]) + = sepBindsByDropPoint platform False to_drop + all_alt_bndrs [scrut_fvs, all_alt_fvs] + -- all_alt_bndrs: see Note [Shadowing and name capture] -- Float into the alts with the is_case flag set - (drop_here2 : alts_drops_s) - | [ _ ] <- alts = [] : [alts_drops] - | otherwise = sepBindsByDropPoint platform True alts_fvs alts_drops - - scrut_fvs = freeVarsOf scrut - alts_fvs = map alt_fvs alts - all_alts_fvs = unionDVarSets alts_fvs - alt_fvs (AnnAlt _con args rhs) - = foldl' delDVarSet (freeVarsOf rhs) (case_bndr:args) - -- Delete case_bndr and args from free vars of rhs - -- to get free vars of alt + (drop_here2, alts_drops_s) + = sepBindsByDropPoint platform True alts_drops emptyDVarSet alts_fvs + + scrut_fvs = freeVarsOf scrut + + all_alt_bndrs = foldr (unionDVarSet . ann_alt_bndrs) (unitDVarSet case_bndr) alts + ann_alt_bndrs (AnnAlt _ bndrs _) = mkDVarSet bndrs + + alts_fvs :: [DVarSet] + alts_fvs = [freeVarsOf rhs | AnnAlt _ _ rhs <- alts] + -- No need to delete binders + -- See Note [Shadowing and name capture] + + all_alt_fvs :: DVarSet + all_alt_fvs = foldr unionDVarSet (unitDVarSet case_bndr) alts_fvs fi_alt to_drop (AnnAlt con args rhs) = Alt con args (fiExpr platform to_drop rhs) ------------------ fiBind :: Platform - -> FloatInBinds -- Binds we're trying to drop - -- as far "inwards" as possible - -> CoreBindWithFVs -- Input binding - -> DVarSet -- Free in scope of binding - -> ( FloatInBinds -- Land these before - , FloatInBind -- The binding itself - , FloatInBinds) -- Land these after + -> RevFloatInBinds -- Binds we're trying to drop + -- as far "inwards" as possible + -> CoreBindWithFVs -- Input binding + -> DVarSet -- Free in scope of binding + -> ( RevFloatInBinds -- Land these before + , FloatInBind -- The binding itself + , RevFloatInBinds) -- Land these after fiBind platform to_drop (AnnNonRec id ann_rhs@(rhs_fvs, rhs)) body_fvs - = ( extra_binds ++ shared_binds -- Land these before - -- See Note [extra_fvs (1)] and Note [extra_fvs (2)] + = ( shared_binds -- Land these before + -- See Note [extra_fvs (1)] and Note [extra_fvs (2)] , FB (unitDVarSet id) rhs_fvs' -- The new binding itself (FloatLet (NonRec id rhs')) , body_binds ) -- Land these after @@ -512,10 +555,9 @@ fiBind platform to_drop (AnnNonRec id ann_rhs@(rhs_fvs, rhs)) body_fvs -- We *can't* float into ok-for-speculation unlifted RHSs -- But do float into join points - [shared_binds, extra_binds, rhs_binds, body_binds] - = sepBindsByDropPoint platform False - [extra_fvs, rhs_fvs, body_fvs2] - to_drop + (shared_binds, [rhs_binds, body_binds]) + = sepBindsByDropPoint platform False to_drop + extra_fvs [rhs_fvs, body_fvs2] -- Push rhs_binds into the right hand side of the binding rhs' = fiRhs platform rhs_binds id ann_rhs @@ -523,7 +565,7 @@ fiBind platform to_drop (AnnNonRec id ann_rhs@(rhs_fvs, rhs)) body_fvs -- Don't forget the rule_fvs; the binding mentions them! fiBind platform to_drop (AnnRec bindings) body_fvs - = ( extra_binds ++ shared_binds + = ( shared_binds , FB (mkDVarSet ids) rhs_fvs' (FloatLet (Rec (fi_bind rhss_binds bindings))) , body_binds ) @@ -537,17 +579,16 @@ fiBind platform to_drop (AnnRec bindings) body_fvs unionDVarSets [ rhs_fvs | (bndr, (rhs_fvs, rhs)) <- bindings , noFloatIntoRhs Recursive bndr rhs ] - (shared_binds:extra_binds:body_binds:rhss_binds) - = sepBindsByDropPoint platform False - (extra_fvs:body_fvs:rhss_fvs) - to_drop + (shared_binds, body_binds:rhss_binds) + = sepBindsByDropPoint platform False to_drop + extra_fvs (body_fvs:rhss_fvs) rhs_fvs' = unionDVarSets rhss_fvs `unionDVarSet` unionDVarSets (map floatedBindsFVs rhss_binds) `unionDVarSet` rule_fvs -- Don't forget the rule variables! -- Push rhs_binds into the right hand side of the binding - fi_bind :: [FloatInBinds] -- one per "drop pt" conjured w/ fvs_of_rhss + fi_bind :: [RevFloatInBinds] -- One per "drop pt" conjured w/ fvs_of_rhss -> [(Id, CoreExprWithFVs)] -> [(Id, CoreExpr)] @@ -556,7 +597,7 @@ fiBind platform to_drop (AnnRec bindings) body_fvs | ((binder, rhs), to_drop) <- zipEqual "fi_bind" pairs to_drops ] ------------------ -fiRhs :: Platform -> FloatInBinds -> CoreBndr -> CoreExprWithFVs -> CoreExpr +fiRhs :: Platform -> RevFloatInBinds -> CoreBndr -> CoreExprWithFVs -> CoreExpr fiRhs platform to_drop bndr rhs | Just join_arity <- isJoinId_maybe bndr , let (bndrs, body) = collectNAnnBndrs join_arity rhs @@ -656,68 +697,84 @@ point. We have to maintain the order on these drop-point-related lists. -} --- pprFIB :: FloatInBinds -> SDoc +-- pprFIB :: RevFloatInBinds -> SDoc -- pprFIB fibs = text "FIB:" <+> ppr [b | FB _ _ b <- fibs] sepBindsByDropPoint :: Platform - -> Bool -- True <=> is case expression - -> [FreeVarSet] -- One set of FVs per drop point - -- Always at least two long! - -> FloatInBinds -- Candidate floaters - -> [FloatInBinds] -- FIRST one is bindings which must not be floated - -- inside any drop point; the rest correspond - -- one-to-one with the input list of FV sets + -> Bool -- True <=> is case expression + -> RevFloatInBinds -- Candidate floaters + -> FreeVarSet -- here_fvs: if these vars are free in a binding, + -- don't float that binding inside any drop point + -> [FreeVarSet] -- fork_fvs: one set of FVs per drop point + -> ( RevFloatInBinds -- Bindings which must not be floated inside + , [RevFloatInBinds] ) -- Corresponds 1-1 with the input list of FV sets -- Every input floater is returned somewhere in the result; -- none are dropped, not even ones which don't seem to be -- free in *any* of the drop-point fvs. Why? Because, for example, -- a binding (let x = E in B) might have a specialised version of -- x (say x') stored inside x, but x' isn't free in E or B. +-- +-- The here_fvs argument is used for two things: +-- * Avoid shadowing bugs: see Note [Shadowing and name capture] +-- * Drop some of the bindings at the top, e.g. of an application type DropBox = (FreeVarSet, FloatInBinds) -sepBindsByDropPoint platform is_case drop_pts floaters +dropBoxFloats :: DropBox -> RevFloatInBinds +dropBoxFloats (_, floats) = reverse floats + +usedInDropBox :: DIdSet -> DropBox -> Bool +usedInDropBox bndrs (db_fvs, _) = db_fvs `intersectsDVarSet` bndrs + +initDropBox :: DVarSet -> DropBox +initDropBox fvs = (fvs, []) + +sepBindsByDropPoint platform is_case floaters here_fvs fork_fvs | null floaters -- Shortcut common case - = [] : [[] | _ <- drop_pts] + = ([], [[] | _ <- fork_fvs]) | otherwise - = assert (drop_pts `lengthAtLeast` 2) $ - go floaters (map (\fvs -> (fvs, [])) (emptyDVarSet : drop_pts)) + = go floaters (initDropBox here_fvs) (map initDropBox fork_fvs) where - n_alts = length drop_pts + n_alts = length fork_fvs - go :: FloatInBinds -> [DropBox] -> [FloatInBinds] - -- The *first* one in the argument list is the drop_here set - -- The FloatInBinds in the lists are in the reverse of - -- the normal FloatInBinds order; that is, they are the right way round! + go :: RevFloatInBinds -> DropBox -> [DropBox] + -> (RevFloatInBinds, [RevFloatInBinds]) + -- The *first* one in the pair is the drop_here set - go [] drop_boxes = map (reverse . snd) drop_boxes + go [] here_box fork_boxes + = (dropBoxFloats here_box, map dropBoxFloats fork_boxes) - go (bind_w_fvs@(FB bndrs bind_fvs bind) : binds) drop_boxes@(here_box : fork_boxes) - = go binds new_boxes + go (bind_w_fvs@(FB bndrs bind_fvs bind) : binds) here_box fork_boxes + | drop_here = go binds (insert here_box) fork_boxes + | otherwise = go binds here_box new_fork_boxes where -- "here" means the group of bindings dropped at the top of the fork - (used_here : used_in_flags) = [ fvs `intersectsDVarSet` bndrs - | (fvs, _) <- drop_boxes] + used_here = bndrs `usedInDropBox` here_box + used_in_flags = case fork_boxes of + [] -> [] + [_] -> [True] -- Push all bindings into a single branch + -- No need to look at its free vars + _ -> map (bndrs `usedInDropBox`) fork_boxes + -- Short-cut for the singleton case; + -- used for lambdas and singleton cases drop_here = used_here || cant_push n_used_alts = count id used_in_flags -- returns number of Trues in list. cant_push - | is_case = n_used_alts == n_alts -- Used in all, don't push - -- Remember n_alts > 1 + | is_case = (n_alts > 1 && n_used_alts == n_alts) + -- Used in all, muliple branches, don't push || (n_used_alts > 1 && not (floatIsDupable platform bind)) -- floatIsDupable: see Note [Duplicating floats] | otherwise = floatIsCase bind || n_used_alts > 1 -- floatIsCase: see Note [Floating primops] - new_boxes | drop_here = (insert here_box : fork_boxes) - | otherwise = (here_box : new_fork_boxes) - new_fork_boxes = zipWithEqual "FloatIn.sepBinds" insert_maybe fork_boxes used_in_flags @@ -727,8 +784,6 @@ sepBindsByDropPoint platform is_case drop_pts floaters insert_maybe box True = insert box insert_maybe box False = box - go _ _ = panic "sepBindsByDropPoint/go" - {- Note [Duplicating floats] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -745,14 +800,14 @@ If the thing is used in all RHSs there is nothing gained, so we don't duplicate then. -} -floatedBindsFVs :: FloatInBinds -> FreeVarSet +floatedBindsFVs :: RevFloatInBinds -> FreeVarSet floatedBindsFVs binds = mapUnionDVarSet fbFVs binds fbFVs :: FloatInBind -> DVarSet fbFVs (FB _ fvs _) = fvs -wrapFloats :: FloatInBinds -> CoreExpr -> CoreExpr --- Remember FloatInBinds is in *reverse* dependency order +wrapFloats :: RevFloatInBinds -> CoreExpr -> CoreExpr +-- Remember RevFloatInBinds is in *reverse* dependency order wrapFloats [] e = e wrapFloats (FB _ _ fl : bs) e = wrapFloats bs (wrapFloat fl e) ===================================== testsuite/tests/simplCore/should_compile/T22662.hs ===================================== @@ -0,0 +1,6 @@ +module T22662 where + +import Data.Set + +foo x = sequence_ [ f y | y <- x ] + where f _ = return (fromList [0]) ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -461,3 +461,4 @@ 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, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) +test('T22622', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0bb5cbf5a56d1e6b16475b4dd47e0de358209990 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0bb5cbf5a56d1e6b16475b4dd47e0de358209990 You're receiving 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 Jan 5 10:38:25 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 05 Jan 2023 05:38:25 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: sphinx: Use modern syntax for extlinks Message-ID: <63b6a8a190812_f192a52710244699@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - bf658971 by Krzysztof Gogolewski at 2023-01-05T05:38:18-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 6e8e6ea1 by Alan Zimmerman at 2023-01-05T05:38:19-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/HsToCore/ListComp.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/Parser.y - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/Stg/BcPrep.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Layout.hs - compiler/GHC/StgToJS/Deps.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Utils/Zonk.hs - compiler/Language/Haskell/Syntax/Decls.hs - docs/users_guide/exts/poly_kinds.rst - docs/users_guide/exts/unicode_syntax.rst - docs/users_guide/ghc_config.py.in - libraries/base/GHC/ST.hs - testsuite/tests/ghc-api/exactprint/RmDecl4.expected.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/afe7820203ad101fb527295ce01bde77509d1693...6e8e6ea141312ea9463d7c8e23ee2d8c6ee4f922 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/afe7820203ad101fb527295ce01bde77509d1693...6e8e6ea141312ea9463d7c8e23ee2d8c6ee4f922 You're receiving 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 Jan 5 12:18:52 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 05 Jan 2023 07:18:52 -0500 Subject: [Git][ghc/ghc][wip/andreask/spec-pragma] 4 commits: Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Message-ID: <63b6c02c63cd9_f192a527242548aa@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/spec-pragma at Glasgow Haskell Compiler / GHC Commits: 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 247601e3 by Andreas Klebinger at 2023-01-04T16:37:27+01:00 Allow combination of NOINLINE/INLINEABLE. We do this by also tracking INLINEABLE outside of the Unfolding data type as it's own flag. In the proccess of this I made a few other smaller changes. * Allow NOINLINE bindings to specialise with -fspecialise-aggressively. Fixes #21036 * Made rule source a proper type instead of Bool. ------------------------- Metric Decrease: T14766 T18304 Metric Increase: T10359 T13386 T15263 ------------------------- - - - - - c8d01802 by Andreas Klebinger at 2023-01-05T13:17:38+01:00 Fix test outputs - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/EnumSet.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/DocString.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Avail.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2d467d96c0f8e02dd0543aadbb5b58e1d92ffa81...c8d018028486e426010fb02e609cdc691499c213 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2d467d96c0f8e02dd0543aadbb5b58e1d92ffa81...c8d018028486e426010fb02e609cdc691499c213 You're receiving 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 Jan 5 12:40:46 2023 From: gitlab at gitlab.haskell.org (aaa (@project_1_bot2)) Date: Thu, 05 Jan 2023 07:40:46 -0500 Subject: [Git][ghc/ghc][wip/t22599] debugging Message-ID: <63b6c54e4a50_f192a527242573c8@gitlab.mail> aaa pushed to branch wip/t22599 at Glasgow Haskell Compiler / GHC Commits: 3cb69bd6 by GHC GitLab CI at 2023-01-05T20:34:34+08:00 debugging - - - - - 2 changed files: - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix Changes: ===================================== .gitlab/ci.sh ===================================== @@ -214,15 +214,17 @@ function set_toolchain_paths() { *) fail "unknown NIX_SYSTEM" ;; esac - if [ "$NIX_SYSTEM" -eq "aarch64-darwin" ]; + if [ "$NIX_SYSTEM" = "aarch64-darwin" ]; then ARCH="arm64"; else ARCH="x86_64"; fi arch -arm64 clang++ -v a.cpp -o a.o - arch -arm64 clang++ -v a.o -o a - arch -arm64 clang -v a.o c++ -lc++abi -o a +# arch -arm64 clang++ -v a.o -o a + # arch -arm64 clang -v a.o c++ -lc++abi -o a + echo $ARCH + echo $NIX_SYSTEM arch "-$ARCH" nix-build .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh cat toolchain.sh fi ===================================== .gitlab/darwin/toolchain.nix ===================================== @@ -31,12 +31,16 @@ let "CC=/usr/bin/clang" "CLANG=/usr/bin/clang" "LLC=${llvm}/bin/llc" - "OPT=${llvm}/bin/opt" + "OPT=${llvm}/bin/opt " "CONF_CC_OPTS_STAGE2=--target=${targetTriple}" "CONF_CXX_OPTS_STAGE2=--target=${targetTriple}" "CONF_GCC_LINKER_OPTS_STAGE2=--target=${targetTriple}" ]; - buildPhase = "true"; + buildPhase = "true"; + postUnpackPhase = '' + /usr/bin/clang -v + + ''; # N.B. Work around #20253. nativeBuildInputs = [ pkgs.gnused ]; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3cb69bd6722e59a530293f46143b09928a22a85e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3cb69bd6722e59a530293f46143b09928a22a85e You're receiving 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 Jan 5 12:54:27 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 05 Jan 2023 07:54:27 -0500 Subject: [Git][ghc/ghc][wip/T20666] 10 commits: compiler: Add -f[no-]split-sections flags Message-ID: <63b6c8838afd8_f192a310829c263615@gitlab.mail> Simon Peyton Jones pushed to branch wip/T20666 at Glasgow Haskell Compiler / GHC Commits: 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - cd57ec2d by Richard Eisenberg at 2023-01-05T12:54:40+00:00 Refactor the treatment of loopy superclass dicts This patch completely re-engineers how we deal with loopy superclass dictionaries in instance declarations. It fixes #20666. The highlights are * Recognise that the loopy-superclass business should use precisely the Paterson conditions. This is much much nicer. See Note [Recursive superclasses] in GHC.Tc.TyCl.Instance * With that in mind, define "Paterson-smaller" in Note [Paterson conditions] in GHC.Tc.Validity, and the new data type `PatersonSize` in GHC.Tc.Utils.TcType, along with functions to compute and compare PatsonSizes * Use the new PatersonSize stuff when solving superclass constraints See Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance * In GHC.Tc.Solver.Monad.lookupInInerts, add a missing call to prohibitedSuperClassSolve. This was the original cause of #20666. * Treat (TypeError "stuff") as having PatersonSize zero. See Note [Paterson size for type family applications] in GHC.Tc.Utils.TcType. * Some refactoring way in which redundant constraints are reported; we don't want to complain about the extra, apparently-redundant constraints that we must add to an instance decl because of the loopy-superclass thing. I moved some work from GHC.Tc.Errors to GHC.Tc.Solver. * Add a new section to the user manual to describe the loopy superclass issue and what rules it follows. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Infer.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/InertSet.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types/Constraint.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/Tc/Validity.hs - docs/users_guide/exts/instances.rst - docs/users_guide/ghc_config.py.in - docs/users_guide/phases.rst - hadrian/README.md - hadrian/doc/flavours.md - hadrian/doc/testsuite.md The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0b030883233c58c90db3fbe27d1290a80aa3592a...cd57ec2d180f45cc49f78dd6d5497ec0fe22e6d2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0b030883233c58c90db3fbe27d1290a80aa3592a...cd57ec2d180f45cc49f78dd6d5497ec0fe22e6d2 You're receiving 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 Jan 5 12:58:06 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 05 Jan 2023 07:58:06 -0500 Subject: [Git][ghc/ghc][wip/T22662] Make FloatIn robust to shadowing Message-ID: <63b6c95ed1c7b_f192a5279c264443@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22662 at Glasgow Haskell Compiler / GHC Commits: 4e78c3bf by Simon Peyton Jones at 2023-01-05T12:58:14+00:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - 3 changed files: - compiler/GHC/Core/Opt/FloatIn.hs - + testsuite/tests/simplCore/should_compile/T22662.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/FloatIn.hs ===================================== @@ -35,9 +35,12 @@ import GHC.Types.Var import GHC.Types.Var.Set import GHC.Utils.Misc -import GHC.Utils.Panic import GHC.Utils.Panic.Plain +import GHC.Utils.Outputable + +import Data.List ( mapAccumL ) + {- Top-level interface function, @floatInwards at . Note that we do not actually float any bindings downwards from the top-level. @@ -124,7 +127,7 @@ the closure for a is not built. ************************************************************************ -} -type FreeVarSet = DIdSet +type FreeVarSet = DVarSet type BoundVarSet = DIdSet data FloatInBind = FB BoundVarSet FreeVarSet FloatBind @@ -132,11 +135,17 @@ data FloatInBind = FB BoundVarSet FreeVarSet FloatBind -- of recursive bindings, the set doesn't include the bound -- variables. -type FloatInBinds = [FloatInBind] - -- In reverse dependency order (innermost binder first) +type FloatInBinds = [FloatInBind] -- In normal dependency order + -- (outermost binder first) +type RevFloatInBinds = [FloatInBind] -- In reverse dependency order + -- (innermost binder first) + +instance Outputable FloatInBind where + ppr (FB bvs fvs _) = text "FB" <> braces (sep [ text "bndrs =" <+> ppr bvs + , text "fvs =" <+> ppr fvs ]) fiExpr :: Platform - -> FloatInBinds -- Binds we're trying to drop + -> RevFloatInBinds -- Binds we're trying to drop -- as far "inwards" as possible -> CoreExprWithFVs -- Input expr -> CoreExpr -- Result @@ -147,13 +156,12 @@ fiExpr _ to_drop (_, AnnType ty) = assert (null to_drop) $ Type ty fiExpr _ to_drop (_, AnnVar v) = wrapFloats to_drop (Var v) fiExpr _ to_drop (_, AnnCoercion co) = wrapFloats to_drop (Coercion co) fiExpr platform to_drop (_, AnnCast expr (co_ann, co)) - = wrapFloats (drop_here ++ co_drop) $ + = wrapFloats drop_here $ Cast (fiExpr platform e_drop expr) co where - [drop_here, e_drop, co_drop] - = sepBindsByDropPoint platform False - [freeVarsOf expr, freeVarsOfAnn co_ann] - to_drop + (drop_here, [e_drop]) + = sepBindsByDropPoint platform False to_drop + (freeVarsOfAnn co_ann) [freeVarsOf expr] {- Applications: we do float inside applications, mainly because we @@ -162,7 +170,7 @@ pull out any silly ones. -} fiExpr platform to_drop ann_expr@(_,AnnApp {}) - = wrapFloats drop_here $ wrapFloats extra_drop $ + = wrapFloats drop_here $ mkTicks ticks $ mkApps (fiExpr platform fun_drop ann_fun) (zipWithEqual "fiExpr" (fiExpr platform) arg_drops ann_args) @@ -170,21 +178,19 @@ fiExpr platform to_drop ann_expr@(_,AnnApp {}) -- length ann_args = length arg_fvs = length arg_drops where (ann_fun, ann_args, ticks) = collectAnnArgsTicks tickishFloatable ann_expr - fun_ty = exprType (deAnnotate ann_fun) fun_fvs = freeVarsOf ann_fun - arg_fvs = map freeVarsOf ann_args - (drop_here : extra_drop : fun_drop : arg_drops) - = sepBindsByDropPoint platform False - (extra_fvs : fun_fvs : arg_fvs) - to_drop + (drop_here, fun_drop : arg_drops) + = sepBindsByDropPoint platform False to_drop + here_fvs (fun_fvs : arg_fvs) + -- Shortcut behaviour: if to_drop is empty, -- sepBindsByDropPoint returns a suitable bunch of empty -- lists without evaluating extra_fvs, and hence without -- peering into each argument - (_, extra_fvs) = foldl' add_arg (fun_ty, extra_fvs0) ann_args - extra_fvs0 = case ann_fun of + (here_fvs, arg_fvs) = mapAccumL add_arg here_fvs0 ann_args + here_fvs0 = case ann_fun of (_, AnnVar _) -> fun_fvs _ -> emptyDVarSet -- Don't float the binding for f into f x y z; see Note [Join points] @@ -192,14 +198,11 @@ fiExpr platform to_drop ann_expr@(_,AnnApp {}) -- join point, floating it in isn't especially harmful but it's -- useless since the simplifier will immediately float it back out.) - add_arg :: (Type,FreeVarSet) -> CoreExprWithFVs -> (Type,FreeVarSet) - add_arg (fun_ty, extra_fvs) (_, AnnType ty) - = (piResultTy fun_ty ty, extra_fvs) - add_arg (fun_ty, extra_fvs) (arg_fvs, arg) - | noFloatIntoArg arg - = (funResultTy fun_ty, extra_fvs `unionDVarSet` arg_fvs) - | otherwise - = (funResultTy fun_ty, extra_fvs) + add_arg :: FreeVarSet -> CoreExprWithFVs -> (FreeVarSet,FreeVarSet) + -- We can't float into some arguments, so put them into the here_fvs + add_arg here_fvs (arg_fvs, arg) + | noFloatIntoArg arg = (here_fvs `unionDVarSet` arg_fvs, emptyDVarSet) + | otherwise = (here_fvs, arg_fvs) {- Note [Dead bindings] ~~~~~~~~~~~~~~~~~~~~~~~ @@ -272,7 +275,6 @@ it's non-recursive, so we float only into non-recursive join points.) Urk! if all are tyvars, and we don't float in, we may miss an opportunity to float inside a nested case branch - Note [Floating coercions] ~~~~~~~~~~~~~~~~~~~~~~~~~ We could, in principle, have a coercion binding like @@ -292,6 +294,36 @@ of the types of all the drop points involved. If any of the floaters bind a coercion variable mentioned in any of the types, that binder must be dropped right away. +Note [Shadowing and name capture] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we have + let x = y+1 in + case p of + (y:ys) -> ...x... + [] -> blah +It is obviously bogus for FloatIn to transform to + case p of + (y:ys) -> ...(let x = y+1 in x)... + [] -> blah +because the y is captured. This doesn't happen much, because shadowing is +rare, but it did happen in #22662. + +One solution would be to clone as we go. But a simpler one is this: + + at a binding site (like that for (y:ys) above), abandon float-in for + any floating bindings that mention the binders (y, ys in this case) + +We achieve that by calling sepBindsByDropPoint with the binders in +the "used-here" set: + +* In fiExpr (AnnLam ...). For the body there is no need to delete + the lambda-binders from the body_fvs, because any bindings that + mention these binders will be dropped here anyway. + +* In fiExpr (AnnCase ...). Remember to include the case_bndr in the + binders. Again, no need to delete the alt binders from the rhs + free vars, beause any bindings mentioning them will be dropped + here unconditionally. -} fiExpr platform to_drop lam@(_, AnnLam _ _) @@ -300,10 +332,17 @@ fiExpr platform to_drop lam@(_, AnnLam _ _) = wrapFloats to_drop (mkLams bndrs (fiExpr platform [] body)) | otherwise -- Float inside - = mkLams bndrs (fiExpr platform to_drop body) + = wrapFloats drop_here $ + mkLams bndrs (fiExpr platform body_drop body) where (bndrs, body) = collectAnnBndrs lam + body_fvs = freeVarsOf body + + -- Why sepBindsByDropPoint? Because of potential capture + -- See Note [Shadowing and name capture] + (drop_here, [body_drop]) = sepBindsByDropPoint platform False to_drop + (mkDVarSet bndrs) [body_fvs] {- We don't float lets inwards past an SCC. @@ -443,16 +482,16 @@ fiExpr platform to_drop (_, AnnCase scrut case_bndr _ [AnnAlt con alt_bndrs rhs] = wrapFloats shared_binds $ fiExpr platform (case_float : rhs_binds) rhs where - case_float = FB (mkDVarSet (case_bndr : alt_bndrs)) scrut_fvs + case_float = FB all_bndrs scrut_fvs (FloatCase scrut' case_bndr con alt_bndrs) scrut' = fiExpr platform scrut_binds scrut - rhs_fvs = freeVarsOf rhs `delDVarSetList` (case_bndr : alt_bndrs) - scrut_fvs = freeVarsOf scrut + rhs_fvs = freeVarsOf rhs -- No need to delete alt_bndrs + scrut_fvs = freeVarsOf scrut -- See Note [Shadowing and name capture] + all_bndrs = mkDVarSet alt_bndrs `extendDVarSet` case_bndr - [shared_binds, scrut_binds, rhs_binds] - = sepBindsByDropPoint platform False - [scrut_fvs, rhs_fvs] - to_drop + (shared_binds, [scrut_binds, rhs_binds]) + = sepBindsByDropPoint platform False to_drop + all_bndrs [scrut_fvs, rhs_fvs] fiExpr platform to_drop (_, AnnCase scrut case_bndr ty alts) = wrapFloats drop_here1 $ @@ -462,39 +501,43 @@ fiExpr platform to_drop (_, AnnCase scrut case_bndr ty alts) -- use zipWithEqual, we should have length alts_drops_s = length alts where -- Float into the scrut and alts-considered-together just like App - [drop_here1, scrut_drops, alts_drops] - = sepBindsByDropPoint platform False - [scrut_fvs, all_alts_fvs] - to_drop + (drop_here1, [scrut_drops, alts_drops]) + = sepBindsByDropPoint platform False to_drop + all_alt_bndrs [scrut_fvs, all_alt_fvs] + -- all_alt_bndrs: see Note [Shadowing and name capture] -- Float into the alts with the is_case flag set - (drop_here2 : alts_drops_s) - | [ _ ] <- alts = [] : [alts_drops] - | otherwise = sepBindsByDropPoint platform True alts_fvs alts_drops - - scrut_fvs = freeVarsOf scrut - alts_fvs = map alt_fvs alts - all_alts_fvs = unionDVarSets alts_fvs - alt_fvs (AnnAlt _con args rhs) - = foldl' delDVarSet (freeVarsOf rhs) (case_bndr:args) - -- Delete case_bndr and args from free vars of rhs - -- to get free vars of alt + (drop_here2, alts_drops_s) + = sepBindsByDropPoint platform True alts_drops emptyDVarSet alts_fvs + + scrut_fvs = freeVarsOf scrut + + all_alt_bndrs = foldr (unionDVarSet . ann_alt_bndrs) (unitDVarSet case_bndr) alts + ann_alt_bndrs (AnnAlt _ bndrs _) = mkDVarSet bndrs + + alts_fvs :: [DVarSet] + alts_fvs = [freeVarsOf rhs | AnnAlt _ _ rhs <- alts] + -- No need to delete binders + -- See Note [Shadowing and name capture] + + all_alt_fvs :: DVarSet + all_alt_fvs = foldr unionDVarSet (unitDVarSet case_bndr) alts_fvs fi_alt to_drop (AnnAlt con args rhs) = Alt con args (fiExpr platform to_drop rhs) ------------------ fiBind :: Platform - -> FloatInBinds -- Binds we're trying to drop - -- as far "inwards" as possible - -> CoreBindWithFVs -- Input binding - -> DVarSet -- Free in scope of binding - -> ( FloatInBinds -- Land these before - , FloatInBind -- The binding itself - , FloatInBinds) -- Land these after + -> RevFloatInBinds -- Binds we're trying to drop + -- as far "inwards" as possible + -> CoreBindWithFVs -- Input binding + -> DVarSet -- Free in scope of binding + -> ( RevFloatInBinds -- Land these before + , FloatInBind -- The binding itself + , RevFloatInBinds) -- Land these after fiBind platform to_drop (AnnNonRec id ann_rhs@(rhs_fvs, rhs)) body_fvs - = ( extra_binds ++ shared_binds -- Land these before - -- See Note [extra_fvs (1)] and Note [extra_fvs (2)] + = ( shared_binds -- Land these before + -- See Note [extra_fvs (1)] and Note [extra_fvs (2)] , FB (unitDVarSet id) rhs_fvs' -- The new binding itself (FloatLet (NonRec id rhs')) , body_binds ) -- Land these after @@ -512,10 +555,9 @@ fiBind platform to_drop (AnnNonRec id ann_rhs@(rhs_fvs, rhs)) body_fvs -- We *can't* float into ok-for-speculation unlifted RHSs -- But do float into join points - [shared_binds, extra_binds, rhs_binds, body_binds] - = sepBindsByDropPoint platform False - [extra_fvs, rhs_fvs, body_fvs2] - to_drop + (shared_binds, [rhs_binds, body_binds]) + = sepBindsByDropPoint platform False to_drop + extra_fvs [rhs_fvs, body_fvs2] -- Push rhs_binds into the right hand side of the binding rhs' = fiRhs platform rhs_binds id ann_rhs @@ -523,7 +565,7 @@ fiBind platform to_drop (AnnNonRec id ann_rhs@(rhs_fvs, rhs)) body_fvs -- Don't forget the rule_fvs; the binding mentions them! fiBind platform to_drop (AnnRec bindings) body_fvs - = ( extra_binds ++ shared_binds + = ( shared_binds , FB (mkDVarSet ids) rhs_fvs' (FloatLet (Rec (fi_bind rhss_binds bindings))) , body_binds ) @@ -537,17 +579,16 @@ fiBind platform to_drop (AnnRec bindings) body_fvs unionDVarSets [ rhs_fvs | (bndr, (rhs_fvs, rhs)) <- bindings , noFloatIntoRhs Recursive bndr rhs ] - (shared_binds:extra_binds:body_binds:rhss_binds) - = sepBindsByDropPoint platform False - (extra_fvs:body_fvs:rhss_fvs) - to_drop + (shared_binds, body_binds:rhss_binds) + = sepBindsByDropPoint platform False to_drop + extra_fvs (body_fvs:rhss_fvs) rhs_fvs' = unionDVarSets rhss_fvs `unionDVarSet` unionDVarSets (map floatedBindsFVs rhss_binds) `unionDVarSet` rule_fvs -- Don't forget the rule variables! -- Push rhs_binds into the right hand side of the binding - fi_bind :: [FloatInBinds] -- one per "drop pt" conjured w/ fvs_of_rhss + fi_bind :: [RevFloatInBinds] -- One per "drop pt" conjured w/ fvs_of_rhss -> [(Id, CoreExprWithFVs)] -> [(Id, CoreExpr)] @@ -556,7 +597,7 @@ fiBind platform to_drop (AnnRec bindings) body_fvs | ((binder, rhs), to_drop) <- zipEqual "fi_bind" pairs to_drops ] ------------------ -fiRhs :: Platform -> FloatInBinds -> CoreBndr -> CoreExprWithFVs -> CoreExpr +fiRhs :: Platform -> RevFloatInBinds -> CoreBndr -> CoreExprWithFVs -> CoreExpr fiRhs platform to_drop bndr rhs | Just join_arity <- isJoinId_maybe bndr , let (bndrs, body) = collectNAnnBndrs join_arity rhs @@ -656,68 +697,84 @@ point. We have to maintain the order on these drop-point-related lists. -} --- pprFIB :: FloatInBinds -> SDoc +-- pprFIB :: RevFloatInBinds -> SDoc -- pprFIB fibs = text "FIB:" <+> ppr [b | FB _ _ b <- fibs] sepBindsByDropPoint :: Platform - -> Bool -- True <=> is case expression - -> [FreeVarSet] -- One set of FVs per drop point - -- Always at least two long! - -> FloatInBinds -- Candidate floaters - -> [FloatInBinds] -- FIRST one is bindings which must not be floated - -- inside any drop point; the rest correspond - -- one-to-one with the input list of FV sets + -> Bool -- True <=> is case expression + -> RevFloatInBinds -- Candidate floaters + -> FreeVarSet -- here_fvs: if these vars are free in a binding, + -- don't float that binding inside any drop point + -> [FreeVarSet] -- fork_fvs: one set of FVs per drop point + -> ( RevFloatInBinds -- Bindings which must not be floated inside + , [RevFloatInBinds] ) -- Corresponds 1-1 with the input list of FV sets -- Every input floater is returned somewhere in the result; -- none are dropped, not even ones which don't seem to be -- free in *any* of the drop-point fvs. Why? Because, for example, -- a binding (let x = E in B) might have a specialised version of -- x (say x') stored inside x, but x' isn't free in E or B. +-- +-- The here_fvs argument is used for two things: +-- * Avoid shadowing bugs: see Note [Shadowing and name capture] +-- * Drop some of the bindings at the top, e.g. of an application type DropBox = (FreeVarSet, FloatInBinds) -sepBindsByDropPoint platform is_case drop_pts floaters +dropBoxFloats :: DropBox -> RevFloatInBinds +dropBoxFloats (_, floats) = reverse floats + +usedInDropBox :: DIdSet -> DropBox -> Bool +usedInDropBox bndrs (db_fvs, _) = db_fvs `intersectsDVarSet` bndrs + +initDropBox :: DVarSet -> DropBox +initDropBox fvs = (fvs, []) + +sepBindsByDropPoint platform is_case floaters here_fvs fork_fvs | null floaters -- Shortcut common case - = [] : [[] | _ <- drop_pts] + = ([], [[] | _ <- fork_fvs]) | otherwise - = assert (drop_pts `lengthAtLeast` 2) $ - go floaters (map (\fvs -> (fvs, [])) (emptyDVarSet : drop_pts)) + = go floaters (initDropBox here_fvs) (map initDropBox fork_fvs) where - n_alts = length drop_pts + n_alts = length fork_fvs - go :: FloatInBinds -> [DropBox] -> [FloatInBinds] - -- The *first* one in the argument list is the drop_here set - -- The FloatInBinds in the lists are in the reverse of - -- the normal FloatInBinds order; that is, they are the right way round! + go :: RevFloatInBinds -> DropBox -> [DropBox] + -> (RevFloatInBinds, [RevFloatInBinds]) + -- The *first* one in the pair is the drop_here set - go [] drop_boxes = map (reverse . snd) drop_boxes + go [] here_box fork_boxes + = (dropBoxFloats here_box, map dropBoxFloats fork_boxes) - go (bind_w_fvs@(FB bndrs bind_fvs bind) : binds) drop_boxes@(here_box : fork_boxes) - = go binds new_boxes + go (bind_w_fvs@(FB bndrs bind_fvs bind) : binds) here_box fork_boxes + | drop_here = go binds (insert here_box) fork_boxes + | otherwise = go binds here_box new_fork_boxes where -- "here" means the group of bindings dropped at the top of the fork - (used_here : used_in_flags) = [ fvs `intersectsDVarSet` bndrs - | (fvs, _) <- drop_boxes] + used_here = bndrs `usedInDropBox` here_box + used_in_flags = case fork_boxes of + [] -> [] + [_] -> [True] -- Push all bindings into a single branch + -- No need to look at its free vars + _ -> map (bndrs `usedInDropBox`) fork_boxes + -- Short-cut for the singleton case; + -- used for lambdas and singleton cases drop_here = used_here || cant_push n_used_alts = count id used_in_flags -- returns number of Trues in list. cant_push - | is_case = n_used_alts == n_alts -- Used in all, don't push - -- Remember n_alts > 1 + | is_case = (n_alts > 1 && n_used_alts == n_alts) + -- Used in all, muliple branches, don't push || (n_used_alts > 1 && not (floatIsDupable platform bind)) -- floatIsDupable: see Note [Duplicating floats] | otherwise = floatIsCase bind || n_used_alts > 1 -- floatIsCase: see Note [Floating primops] - new_boxes | drop_here = (insert here_box : fork_boxes) - | otherwise = (here_box : new_fork_boxes) - new_fork_boxes = zipWithEqual "FloatIn.sepBinds" insert_maybe fork_boxes used_in_flags @@ -727,8 +784,6 @@ sepBindsByDropPoint platform is_case drop_pts floaters insert_maybe box True = insert box insert_maybe box False = box - go _ _ = panic "sepBindsByDropPoint/go" - {- Note [Duplicating floats] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -745,14 +800,14 @@ If the thing is used in all RHSs there is nothing gained, so we don't duplicate then. -} -floatedBindsFVs :: FloatInBinds -> FreeVarSet +floatedBindsFVs :: RevFloatInBinds -> FreeVarSet floatedBindsFVs binds = mapUnionDVarSet fbFVs binds fbFVs :: FloatInBind -> DVarSet fbFVs (FB _ fvs _) = fvs -wrapFloats :: FloatInBinds -> CoreExpr -> CoreExpr --- Remember FloatInBinds is in *reverse* dependency order +wrapFloats :: RevFloatInBinds -> CoreExpr -> CoreExpr +-- Remember RevFloatInBinds is in *reverse* dependency order wrapFloats [] e = e wrapFloats (FB _ _ fl : bs) e = wrapFloats bs (wrapFloat fl e) ===================================== testsuite/tests/simplCore/should_compile/T22662.hs ===================================== @@ -0,0 +1,6 @@ +module T22662 where + +import Data.Set + +foo x = sequence_ [ f y | y <- x ] + where f _ = return (fromList [0]) ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -461,3 +461,4 @@ 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, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) +test('T22662', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4e78c3bfffd105d1d14579598668a1415d1457eb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4e78c3bfffd105d1d14579598668a1415d1457eb You're receiving 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 Jan 5 13:56:47 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 05 Jan 2023 08:56:47 -0500 Subject: [Git][ghc/ghc][wip/t22695] 12 commits: Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Message-ID: <63b6d71f2c2e6_f192a527242730ad@gitlab.mail> Matthew Pickering pushed to branch wip/t22695 at Glasgow Haskell Compiler / GHC Commits: 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - 8d69ac94 by Matthew Pickering at 2023-01-05T13:56:38+00:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Data/EnumSet.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/DocString.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Match.hs-boot - compiler/GHC/Tc/TyCl/PatSyn.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 - compiler/Language/Haskell/Syntax/Expr.hs - docs/users_guide/ghc_config.py.in - docs/users_guide/phases.rst - hadrian/README.md The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0ea1c3da1cceef4280a483e6a3522e36b3ef638b...8d69ac94e8527768118513112a982d6f0cf147c1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0ea1c3da1cceef4280a483e6a3522e36b3ef638b...8d69ac94e8527768118513112a982d6f0cf147c1 You're receiving 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 Jan 5 15:23:14 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 05 Jan 2023 10:23:14 -0500 Subject: [Git][ghc/ghc][wip/T22404] Wibbles Message-ID: <63b6eb62e1fbd_f192a1978bf902933af@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22404 at Glasgow Haskell Compiler / GHC Commits: 7a037e68 by Simon Peyton Jones at 2023-01-05T15:23:35+00:00 Wibbles - - - - - 1 changed file: - compiler/GHC/Core/Opt/OccurAnal.hs Changes: ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -753,11 +753,14 @@ occAnalBind !env lvl ire (NonRec bndr rhs) thing_inside combine = WithUsageDetails (bind_uds `andUDs` body_uds) (combine binds' body') where + -- Analyse the body WithUsageDetails body_uds (tagged_bndr, body') = addInScope env [bndr] $ \env -> let WithUsageDetails usage res = thing_inside env tagged_bndr = tagNonRecBinder lvl usage bndr in WithUsageDetails usage (tagged_bndr, res) + + -- Analyse the binding itself WithUsageDetails bind_uds binds' = occAnalNonRecIdBind env ire tagged_bndr rhs @@ -2236,10 +2239,7 @@ occAnal env (Case scrut bndr ty alts) in WithUsageDetails total_usage (Case scrut' tagged_bndr ty alts') where do_alts :: OccEnv -> [CoreAlt] -> WithUsageDetails [CoreAlt] - do_alts _ [] = WithUsageDetails emptyDetails [] - do_alts env [alt] = WithUsageDetails uds [alt'] - where - WithUsageDetails uds alt' = do_alt env alt + do_alts _ [] = WithUsageDetails emptyDetails [] do_alts env (alt:alts) = WithUsageDetails (uds1 `orUDs` uds2) (alt':alts') where WithUsageDetails uds1 alt' = do_alt env alt @@ -2257,7 +2257,8 @@ occAnal env (Let bind body) , mb_join@(Just {}) <- isJoinId_maybe bndr , not (isStableUnfolding (realIdUnfolding bndr)) , not (idHasRules bndr) - = let WithUsageDetails rhs_usage rhs' = occAnalRhs env NonRecursive mb_join rhs + = -- This is where we extend occ_join_points! + let WithUsageDetails rhs_usage rhs' = occAnalRhs env NonRecursive mb_join rhs in addInScope env [bndr] $ \ body_env -> let body_env1 = body_env { occ_join_points = extendVarEnv (occ_join_points env) bndr rhs_usage } @@ -2289,7 +2290,7 @@ occAnalArgs !env fun args !one_shots {- Applications are dealt with specially because we want the "build hack" to work. -g + Note [Arguments of let-bound constructors] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider @@ -2584,21 +2585,30 @@ isRhsEnv (OccEnv { occ_encl = cxt }) = case cxt of addInScope :: OccEnv -> [Var] -> (OccEnv -> WithUsageDetails a) -> WithUsageDetails a -- Needed for all Vars not just Ids --- See Note [The binder-swap substitution] (BS3) -addInScope env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = bs_rng_vars - , occ_join_points = join_points }) bndrs thing_inside - - | any (`elemVarSet` bs_rng_vars) bndrs - = fix_up_uds $ - thing_inside (env1 { occ_bs_env = emptyVarEnv, occ_bs_rng = emptyVarSet }) - - | otherwise - = fix_up_uds $ - thing_inside (env1 { occ_bs_env = swap_env `delVarEnvList` bndrs }) +addInScope env@(OccEnv { occ_join_points = join_points }) bndrs thing_inside + = fix_up_uds $ thing_inside $ drop_shadowed_swaps $ drop_shadowed_joins env where - env1 | isEmptyVarEnv bad_joins = env - | otherwise = env { occ_join_points = good_joins } + drop_shadowed_swaps :: OccEnv -> OccEnv + -- See Note [The binder-swap substitution] (BS3) + drop_shadowed_swaps env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = bs_rng_vars }) + | any (`elemVarSet` bs_rng_vars) bndrs + = env { occ_bs_env = emptyVarEnv, occ_bs_rng = emptyVarSet } + | otherwise + = env { occ_bs_env = swap_env `delVarEnvList` bndrs } + + drop_shadowed_joins :: OccEnv -> OccEnv + -- See Note [Occurrence analysis for join points] + drop_shadowed_joins env + | isEmptyVarEnv bad_joins + , not (any (`elemVarEnv` join_points) bndrs) + = env -- Non-allocating short cut; common case + | otherwise = env { occ_join_points = good_joins `delVarEnvList` bndrs} + where + + fix_up_uds :: WithUsageDetails a -> WithUsageDetails a + -- Add usage info for (a) CoVars used in the types of bndrs + -- and (b) occ_join_points that we cannot push inwards because of shadowing fix_up_uds (WithUsageDetails uds res) = with_joins `seq` WithUsageDetails with_joins res @@ -2612,6 +2622,7 @@ addInScope env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = bs_rng_vars bad_join_rhs :: UsageDetails -> Bool bad_join_rhs (UD { ud_env = rhs_usage }) = any (`elemVarEnv` rhs_usage) bndrs + -------------------- transClosureFV :: VarEnv VarSet -> VarEnv VarSet -- If (f,g), (g,h) are in the input, then (f,h) is in the output @@ -3032,9 +3043,10 @@ info then simply means setting the corresponding zapped set to the whole 'OccInfoEnv', a fast O(1) operation. -} -type OccInfoEnv = IdEnv OccInfo -- A finite map from ids to their usage - -- INVARIANT: never IAmDead - -- Deadness is signalled by not being in the map at all +type OccInfoEnv = IdEnv OccInfo -- A finite map from an expression's + -- free variables to their usage + -- INVARIANT: never IAmDead + -- Deadness is signalled by not being in the map at all type ZappedSet = OccInfoEnv -- Values are ignored View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7a037e68cd4ada7c76581f7ba2bc62b435de0a89 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7a037e68cd4ada7c76581f7ba2bc62b435de0a89 You're receiving 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 Jan 5 15:48:58 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 05 Jan 2023 10:48:58 -0500 Subject: [Git][ghc/ghc][master] Misc cleanup Message-ID: <63b6f16aa628d_f192a310829c30416@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 28 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/HsToCore/ListComp.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/Stg/BcPrep.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Layout.hs - compiler/GHC/StgToJS/Deps.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Utils/Zonk.hs - compiler/Language/Haskell/Syntax/Decls.hs - docs/users_guide/exts/poly_kinds.rst - docs/users_guide/exts/unicode_syntax.rst - libraries/base/GHC/ST.hs - testsuite/tests/linters/notes.stdout Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -2498,19 +2498,6 @@ typeCharTypeRepKey = mkPreludeMiscIdUnique 509 typeRepIdKey = mkPreludeMiscIdUnique 510 mkTrFunKey = mkPreludeMiscIdUnique 511 --- Representations for primitive types -trTYPEKey - , trTYPE'PtrRepLiftedKey - , trRuntimeRepKey - , tr'PtrRepLiftedKey - , trLiftedRepKey - :: Unique -trTYPEKey = mkPreludeMiscIdUnique 512 -trTYPE'PtrRepLiftedKey = mkPreludeMiscIdUnique 513 -trRuntimeRepKey = mkPreludeMiscIdUnique 514 -tr'PtrRepLiftedKey = mkPreludeMiscIdUnique 515 -trLiftedRepKey = mkPreludeMiscIdUnique 516 - -- KindReps for common cases starKindRepKey, starArrStarKindRepKey, starArrStarArrStarKindRepKey, constraintKindRepKey :: Unique starKindRepKey = mkPreludeMiscIdUnique 520 @@ -2523,9 +2510,6 @@ toDynIdKey :: Unique toDynIdKey = mkPreludeMiscIdUnique 530 -bitIntegerIdKey :: Unique -bitIntegerIdKey = mkPreludeMiscIdUnique 550 - heqSCSelIdKey, eqSCSelIdKey, coercibleSCSelIdKey :: Unique eqSCSelIdKey = mkPreludeMiscIdUnique 551 heqSCSelIdKey = mkPreludeMiscIdUnique 552 ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -903,7 +903,7 @@ mkConstraintTupleStr 1 = "Solo%" -- See Note [One-tuples] mkConstraintTupleStr ar = "(%" ++ commas ar ++ "%)" commas :: Arity -> String -commas ar = take (ar-1) (repeat ',') +commas ar = replicate (ar-1) ',' cTupleTyCon :: Arity -> TyCon cTupleTyCon i ===================================== compiler/GHC/Builtin/Types/Literals.hs ===================================== @@ -479,8 +479,7 @@ axConsSymbolDef = axUnconsSymbolDef = mkUnAxiom "UnconsSymbolDef" typeUnconsSymbolTyCon isStrLitTy $ - \str -> Just $ - mkPromotedMaybeTy charSymbolPairKind (fmap reifyCharSymbolPairTy (unconsFS str)) + \str -> Just $ computeUncons str axCharToNatDef = mkUnAxiom "CharToNatDef" typeCharToNatTyCon isCharLitTy $ @@ -784,14 +783,15 @@ matchFamConsSymbol [s,t] mbY = isStrLitTy t matchFamConsSymbol _ = Nothing -reifyCharSymbolPairTy :: (Char, FastString) -> Type -reifyCharSymbolPairTy (c, s) = charSymbolPair (mkCharLitTy c) (mkStrLitTy s) +computeUncons :: FastString -> Type +computeUncons str = mkPromotedMaybeTy charSymbolPairKind (fmap reifyCharSymbolPairTy (unconsFS str)) + where reifyCharSymbolPairTy :: (Char, FastString) -> Type + reifyCharSymbolPairTy (c, s) = charSymbolPair (mkCharLitTy c) (mkStrLitTy s) matchFamUnconsSymbol :: [Type] -> Maybe (CoAxiomRule, [Type], Type) matchFamUnconsSymbol [s] | Just x <- mbX = - Just (axUnconsSymbolDef, [s] - , mkPromotedMaybeTy charSymbolPairKind (fmap reifyCharSymbolPairTy (unconsFS x))) + Just (axUnconsSymbolDef, [s], computeUncons x) where mbX = isStrLitTy s matchFamUnconsSymbol _ = Nothing ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -3743,7 +3743,7 @@ pseudoop "proxy#" representation. } pseudoop "seq" - a -> b -> b + a -> p -> p { The value of @'seq' a b@ is bottom if @a@ is bottom, and otherwise equal to @b at . In other words, it evaluates the first argument @a@ to weak head normal form (WHNF). 'seq' is usually @@ -3761,7 +3761,7 @@ pseudoop "seq" -- change this, do update 'ghcPrimIface' in 'GHC.Iface.Load'. pseudoop "unsafeCoerce#" - a -> b + o -> p { The function 'unsafeCoerce#' allows you to side-step the typechecker entirely. That is, it allows you to coerce any type into any other type. If you use this function, you had better get it right, otherwise segmentation faults await. It is generally ===================================== compiler/GHC/Core/Coercion.hs-boot ===================================== @@ -45,8 +45,6 @@ coVarRole :: CoVar -> Role mkCoercionType :: Role -> Type -> Type -> Type -data LiftingContext -liftCoSubst :: HasDebugCallStack => Role -> LiftingContext -> Type -> Coercion seqCo :: Coercion -> () coercionKind :: Coercion -> Pair Type ===================================== compiler/GHC/Core/Ppr.hs ===================================== @@ -159,9 +159,9 @@ ppr_binding ann (val_bdr, expr) -- So refer to printing j = e = pp_normal_bind where - (bndrs, body) = collectBinders expr - lhs_bndrs = take join_arity bndrs - rhs = mkLams (drop join_arity bndrs) body + (bndrs, body) = collectBinders expr + (lhs_bndrs, rest) = splitAt join_arity bndrs + rhs = mkLams rest body pprParendExpr expr = ppr_expr parens expr pprCoreExpr expr = ppr_expr noParens expr ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -781,7 +781,7 @@ isBoxedRuntimeRep_maybe rep -- | Check whether a type of kind 'RuntimeRep' is lifted, unlifted, or unknown. -- --- `isLiftedRuntimeRep rr` returns: +-- `runtimeRepLevity_maybe rr` returns: -- -- * `Just Lifted` if `rr` is `LiftedRep :: RuntimeRep` -- * `Just Unlifted` if `rr` is definitely unlifted, e.g. `IntRep` @@ -1028,7 +1028,7 @@ invariant: use it. Note [Decomposing fat arrow c=>t] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Can we unify (a b) with (Eq a => ty)? If we do so, we end up with -a partial application like ((=>) Eq a) which doesn't make sense in +a partial application like ((=>) (Eq a)) which doesn't make sense in source Haskell. In contrast, we *can* unify (a b) with (t1 -> t2). Here's an example (#9858) of how you might do it: i :: (Typeable a, Typeable b) => Proxy (a b) -> TypeRep ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -141,8 +141,7 @@ exprType (Lam binder expr) = mkLamType binder (exprType expr) exprType e@(App _ _) = case collectArgs e of (fun, args) -> applyTypeToArgs (pprCoreExpr e) (exprType fun) args - -exprType other = pprPanic "exprType" (pprCoreExpr other) +exprType (Type ty) = pprPanic "exprType" (ppr ty) coreAltType :: CoreAlt -> Type -- ^ Returns the type of the alternatives right hand side ===================================== compiler/GHC/HsToCore/Arrows.hs ===================================== @@ -647,7 +647,7 @@ dsCmd ids local_vars stack_ty res_ty (XCmd (HsWrap wrap cmd)) env_ids = do core_wrap <- dsHsWrapper wrap return (core_wrap core_cmd, env_ids') -dsCmd _ _ _ _ c _ = pprPanic "dsCmd" (ppr c) +dsCmd _ _ _ _ c@(HsCmdLam {}) _ = pprPanic "dsCmd" (ppr c) -- D; ys |-a c : stk --> t (ys <= xs) -- --------------------- ===================================== compiler/GHC/HsToCore/Binds.hs ===================================== @@ -307,7 +307,7 @@ dsAbsBinds dflags tyvars dicts exports ; let mk_bind (ABE { abe_wrap = wrap , abe_poly = global , abe_mono = local, abe_prags = spec_prags }) - -- See Note [AbsBinds wrappers] in "GHC.Hs.Binds" + -- See Note [ABExport wrapper] in "GHC.Hs.Binds" = do { tup_id <- newSysLocalDs ManyTy tup_ty ; core_wrap <- dsHsWrapper wrap ; let rhs = core_wrap $ mkLams tyvars $ mkLams dicts $ ===================================== compiler/GHC/HsToCore/Foreign/JavaScript.hs ===================================== @@ -177,14 +177,14 @@ mkFExportJSBits platform c_nm maybe_target arg_htys res_hty is_IO_res_ty _cconv text "h$foreignExport" <> parens ( ftext c_nm <> comma <> - strlit (unitIdString (moduleUnitId m)) <> comma <> - strlit (moduleNameString (moduleName m)) <> comma <> - strlit (unpackFS c_nm) <> comma <> - strlit type_string + strlit (unitIdFS (moduleUnitId m)) <> comma <> + strlit (moduleNameFS (moduleName m)) <> comma <> + strlit c_nm <> comma <> + strlit (mkFastString type_string) ) <> semi _ -> empty - strlit xs = docToSDoc (pprStringLit (mkFastString xs)) + strlit xs = docToSDoc (pprStringLit xs) -- the target which will form the root of what we ask rts_evalIO to run the_cfun @@ -382,16 +382,16 @@ dsJsCall fn_id co (CCall (CCallSpec target cconv safety)) _mDeclHeader = do mkHObj :: Type -> SDoc -mkHObj t = text "h$rts_mk" <> text (showFFIType t) +mkHObj t = text "h$rts_mk" <> showFFIType t unpackHObj :: Type -> SDoc -unpackHObj t = text "h$rts_get" <> text (showFFIType t) +unpackHObj t = text "h$rts_get" <> showFFIType t showStgType :: Type -> SDoc -showStgType t = text "Hs" <> text (showFFIType t) +showStgType t = text "Hs" <> showFFIType t -showFFIType :: Type -> String -showFFIType t = getOccString (getName (typeTyCon t)) +showFFIType :: Type -> SDoc +showFFIType t = ftext (occNameFS (getOccName (typeTyCon t))) typeTyCon :: Type -> TyCon typeTyCon ty @@ -639,7 +639,7 @@ jsResultWrapper result_ty | Just (tc,_) <- maybe_tc_app, tc `hasKey` boolTyConKey = do -- result_id <- newSysLocalDs boolTy ccall_uniq <- newUnique - let forceBool e = mkJsCall ccall_uniq "$r = !(!$1)" [e] boolTy + let forceBool e = mkJsCall ccall_uniq (fsLit "$r = !(!$1)") [e] boolTy return (Just intPrimTy, \e -> forceBool e) @@ -674,10 +674,10 @@ jsResultWrapper result_ty maybe_tc_app = splitTyConApp_maybe result_ty -- low-level primitive JavaScript call: -mkJsCall :: Unique -> String -> [CoreExpr] -> Type -> CoreExpr +mkJsCall :: Unique -> FastString -> [CoreExpr] -> Type -> CoreExpr mkJsCall u tgt args t = mkFCall u ccall args t where ccall = CCall $ CCallSpec - (StaticTarget NoSourceText (mkFastString tgt) (Just primUnit) True) + (StaticTarget NoSourceText tgt (Just primUnit) True) JavaScriptCallConv PlayRisky ===================================== compiler/GHC/HsToCore/ListComp.hs ===================================== @@ -584,8 +584,8 @@ dsMcStmt (ParStmt bind_ty blocks mzip_op bind_op) stmts_rest = do { exp <- dsInnerMonadComp stmts bndrs return_op ; return (exp, mkBigCoreVarTupTy bndrs) } -dsMcStmt stmt _ = pprPanic "dsMcStmt: unexpected stmt" (ppr stmt) - +dsMcStmt stmt@(ApplicativeStmt {}) _ = pprPanic "dsMcStmt: unexpected stmt" (ppr stmt) +dsMcStmt stmt@(RecStmt {}) _ = pprPanic "dsMcStmt: unexpected stmt" (ppr stmt) matchTuple :: [Id] -> CoreExpr -> DsM CoreExpr -- (matchTuple [a,b,c] body) ===================================== compiler/GHC/HsToCore/Pmc/Desugar.hs ===================================== @@ -48,7 +48,7 @@ import GHC.Data.Maybe import qualified GHC.LanguageExtensions as LangExt import GHC.Utils.Monad (concatMapM) import GHC.Types.SourceText (FractionalLit(..)) -import Control.Monad (zipWithM) +import Control.Monad (zipWithM, replicateM) import Data.List (elemIndex) import Data.List.NonEmpty ( NonEmpty(..) ) import qualified Data.List.NonEmpty as NE @@ -92,7 +92,7 @@ mkPmLitGrds x (PmLit _ (PmLitString s)) = do -- 'GHC.HsToCore.Pmc.Solver.addRefutableAltCon', but it's so much simpler -- here. See Note [Representation of Strings in TmState] in -- GHC.HsToCore.Pmc.Solver - vars <- traverse mkPmId (take (lengthFS s) (repeat charTy)) + vars <- replicateM (lengthFS s) (mkPmId charTy) let mk_char_lit y c = mkPmLitGrds y (PmLit charTy (PmLitChar c)) char_grdss <- zipWithM mk_char_lit vars (unpackFS s) mkListGrds x (zip vars char_grdss) ===================================== compiler/GHC/Rename/Bind.hs ===================================== @@ -529,7 +529,7 @@ rnBind sig_fn (PatSynBind x bind) = do { (bind', name, fvs) <- rnPatSynBind sig_fn bind ; return (PatSynBind x bind', name, fvs) } -rnBind _ b = pprPanic "rnBind" (ppr b) +rnBind _ b@(VarBind {}) = pprPanic "rnBind" (ppr b) -- See Note [Pattern bindings that bind no variables] isOkNoBindPattern :: LPat GhcRn -> Bool ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -501,6 +501,8 @@ rnExpr (RecordUpd { rupd_expr = expr, rupd_flds = rbinds }) , plusFVs [fv_getField, fv_setField, fv_e, fv_us] ) } +rnExpr (HsRecSel x _) = dataConCantHappen x + rnExpr (ExprWithTySig _ expr pty) = do { (pty', fvTy) <- rnHsSigWcType ExprWithTySigCtx pty ; (expr', fvExpr) <- bindSigTyVarsFV (hsWcScopedTvs pty') $ @@ -588,9 +590,6 @@ rnExpr (HsProc x pat body) { (body',fvBody) <- rnCmdTop body ; return (HsProc x pat' body', fvBody) } -rnExpr other = pprPanic "rnExpr: unexpected expression" (ppr other) - -- HsWrap - {- ************************************************************************ * * ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -773,7 +773,7 @@ rnHsRecFields ctxt mk_arg (HsRecFields { rec_flds = flds, rec_dotdot = dotdot }) mb_con = case ctxt of HsRecFieldCon con -> Just con HsRecFieldPat con -> Just con - _ {- update -} -> Nothing + HsRecFieldUpd -> Nothing rn_fld :: Bool -> Maybe Name -> LHsRecField GhcPs (LocatedA arg) -> RnM (LHsRecField GhcRn (LocatedA arg)) ===================================== compiler/GHC/Runtime/Heap/Inspect.hs ===================================== @@ -478,22 +478,6 @@ repPrim t = rep where | t == int64PrimTyCon = text $ show (build x :: Int64) | t == word64PrimTyCon = text $ show (build x :: Word64) | t == addrPrimTyCon = text $ show (nullPtr `plusPtr` build x) - | t == stablePtrPrimTyCon = text "" - | t == stableNamePrimTyCon = text "" - | t == statePrimTyCon = text "" - | t == proxyPrimTyCon = text "" - | t == realWorldTyCon = text "" - | t == threadIdPrimTyCon = text "" - | t == weakPrimTyCon = text "" - | t == arrayPrimTyCon = text "" - | t == smallArrayPrimTyCon = text "" - | t == byteArrayPrimTyCon = text "" - | t == mutableArrayPrimTyCon = text "" - | t == smallMutableArrayPrimTyCon = text "" - | t == mutableByteArrayPrimTyCon = text "" - | t == mutVarPrimTyCon = text "" - | t == mVarPrimTyCon = text "" - | t == tVarPrimTyCon = text "" | otherwise = char '<' <> ppr t <> char '>' where build ww = unsafePerformIO $ withArray ww (peek . castPtr) -- This ^^^ relies on the representation of Haskell heap values being ===================================== compiler/GHC/Stg/BcPrep.hs ===================================== @@ -128,7 +128,7 @@ bcPrep us bnds = evalState (mapM bcPrepTopLvl bnds) (BcPrepM_State us) isNNLJoinPoint :: Id -> Bool isNNLJoinPoint x = isJoinId x && mightBeUnliftedType (idType x) --- Update an Id's type to take a Void# argument. +-- Update an Id's type to take a (# #) argument. -- Precondition: the Id is a not-necessarily-lifted join point. -- See Note [Not-necessarily-lifted join points] protectNNLJoinPointId :: Id -> Id @@ -200,7 +200,7 @@ Here is an example. Suppose we have Our plan is to behave is if the code was f = \(r :: RuntimeRep) (a :: TYPE r) (x :: T). - let j :: (Void# -> a) + let j :: ((# #) -> a) j = \ _ -> error @r @a "bloop" in case x of A -> j void# ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -271,7 +271,7 @@ argBits :: Platform -> [ArgRep] -> [Bool] argBits _ [] = [] argBits platform (rep : args) | isFollowableArg rep = False : argBits platform args - | otherwise = take (argRepSizeW platform rep) (repeat True) ++ argBits platform args + | otherwise = replicate (argRepSizeW platform rep) True ++ argBits platform args non_void :: [ArgRep] -> [ArgRep] non_void = filter nv @@ -1818,8 +1818,7 @@ mkMultiBranch maybe_ncons raw_ways = do mkTree vals range_lo range_hi = let n = length vals `div` 2 - vals_lo = take n vals - vals_hi = drop n vals + (vals_lo, vals_hi) = splitAt n vals v_mid = fst (head vals_hi) in do label_geq <- getLabelBc ===================================== compiler/GHC/StgToCmm/Layout.hs ===================================== @@ -554,7 +554,7 @@ mkArgDescr platform args argBits :: Platform -> [ArgRep] -> [Bool] -- True for non-ptr, False for ptr argBits _ [] = [] argBits platform (P : args) = False : argBits platform args -argBits platform (arg : args) = take (argRepSizeW platform arg) (repeat True) +argBits platform (arg : args) = replicate (argRepSizeW platform arg) True ++ argBits platform args ---------------------- ===================================== compiler/GHC/StgToJS/Deps.hs ===================================== @@ -153,7 +153,7 @@ genDependencyData mod units = do lookupOtherFun od@(OtherSymb m idTxt) = case M.lookup od unitOtherExports of Just n -> return (Right n) - Nothing | m == mod -> panic ("genDependencyData.lookupOtherFun: unknown local other id: " ++ unpackFS idTxt) + Nothing | m == mod -> pprPanic "genDependencyData.lookupOtherFun: unknown local other id:" (ftext idTxt) Nothing -> Left <$> (maybe (lookupExternalFun Nothing od) return =<< gets (M.lookup od . ddcOther)) ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -962,7 +962,7 @@ typedSpliceCtxtDoc n splice spliceResultDoc :: LHsExpr GhcTc -> SDoc spliceResultDoc expr = sep [ text "In the result of the splice:" - , nest 2 (char '$' <> ppr expr) + , nest 2 (text "$$" <> ppr expr) , text "To see what the splice expanded to, use -ddump-splices"] stubNestedSplice :: HsExpr GhcTc ===================================== compiler/GHC/Tc/Utils/Zonk.hs ===================================== @@ -785,7 +785,7 @@ zonkExpr env (HsUntypedBracket hsb_tc body) zonkExpr env (HsTypedSplice s _) = runTopSplice s >>= zonkExpr env -zonkExpr _ e@(HsUntypedSplice _ _) = pprPanic "zonkExpr: HsUntypedSplice" (ppr e) +zonkExpr _ (HsUntypedSplice x _) = dataConCantHappen x zonkExpr _ (OpApp x _ _ _) = dataConCantHappen x @@ -899,7 +899,11 @@ zonkExpr env (XExpr (ConLikeTc con tvs tys)) -- The tvs come straight from the data-con, and so are strictly redundant -- See Wrinkles of Note [Typechecking data constructors] in GHC.Tc.Gen.Head -zonkExpr _ expr = pprPanic "zonkExpr" (ppr expr) +zonkExpr _ (RecordUpd x _ _) = dataConCantHappen x +zonkExpr _ (HsGetField x _ _) = dataConCantHappen x +zonkExpr _ (HsProjection x _) = dataConCantHappen x +zonkExpr _ e@(XExpr (HsTick {})) = pprPanic "zonkExpr" (ppr e) +zonkExpr _ e@(XExpr (HsBinTick {})) = pprPanic "zonkExpr" (ppr e) ------------------------------------------------------------------------- {- ===================================== compiler/Language/Haskell/Syntax/Decls.hs ===================================== @@ -580,7 +580,8 @@ declaration before checking all of the others, supporting polymorphic recursion. See https://gitlab.haskell.org/ghc/ghc/wikis/ghc-kinds/kind-inference#proposed-new-strategy and #9200 for lots of discussion of how we got here. -The detection of CUSKs is enabled by the -XCUSKs extension, switched on by default. +The detection of CUSKs is enabled by the -XCUSKs extension, switched off by default +in GHC2021 and on in Haskell98/2010. Under -XNoCUSKs, all declarations are treated as if they have no CUSK. See https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0036-kind-signatures.rst ===================================== docs/users_guide/exts/poly_kinds.rst ===================================== @@ -372,8 +372,9 @@ According to the rules above ``X`` has a CUSK. Yet, the kind of ``k`` is undeter It is thus quantified over, giving ``X`` the kind ``forall k1 (k :: k1). Proxy k -> Type``. The detection of CUSKs is enabled by the :extension:`CUSKs` flag, which is -switched on by default. This extension is scheduled for deprecation to be -replaced with :extension:`StandaloneKindSignatures`. +switched off by default in GHC2021 and on in Haskell98 and Haskell2010. +This extension is scheduled for deprecation to be replaced +with :extension:`StandaloneKindSignatures`. .. index:: single: standalone kind signature ===================================== docs/users_guide/exts/unicode_syntax.rst ===================================== @@ -47,5 +47,7 @@ sequences. The following alternatives are provided: +--------------+---------------+-------------+-----------------------------------------+ | ``|]`` | ⟧ | 0x27E7 | MATHEMATICAL RIGHT WHITE SQUARE BRACKET | +--------------+---------------+-------------+-----------------------------------------+ +| ``%1->`` | ⊸ | 0x22B8 | MULTIMAP | ++--------------+---------------+-------------+-----------------------------------------+ ===================================== libraries/base/GHC/ST.hs ===================================== @@ -131,4 +131,4 @@ instance Show (ST s a) where -- computation is inaccessible to the rest of the program. runST :: (forall s. ST s a) -> a runST (ST st_rep) = case runRW# st_rep of (# _, a #) -> a --- See Note [Definition of runRW#] in GHC.Magic +-- See Note [runRW magic] in GHC.CoreToStg.Prep ===================================== testsuite/tests/linters/notes.stdout ===================================== @@ -13,7 +13,6 @@ ref compiler/GHC/Hs/Expr.hs:1704:87: Note [Lifecycle of a splice] ref compiler/GHC/Hs/Expr.hs:1740:7: Note [Pending Splices] ref compiler/GHC/Hs/Extension.hs:144:5: Note [Strict argument type constraints] ref compiler/GHC/Hs/Pat.hs:143:74: Note [Lifecycle of a splice] -ref compiler/GHC/HsToCore/Binds.hs:312:33: Note [AbsBinds wrappers] ref compiler/GHC/HsToCore/Pmc/Solver.hs:854:20: Note [COMPLETE sets on data families] ref compiler/GHC/HsToCore/Quote.hs:1460:7: Note [How brackets and nested splices are handled] ref compiler/GHC/Rename/Pat.hs:888:29: Note [Disambiguating record fields] @@ -51,7 +50,6 @@ ref compiler/Language/Haskell/Syntax/Pat.hs:336:12: Note [Disambiguating ref configure.ac:212:10: Note [Linking ghc-bin against threaded stage0 RTS] ref docs/core-spec/core-spec.mng:177:6: Note [TyBinders] ref hadrian/src/Expression.hs:130:30: Note [Linking ghc-bin against threaded stage0 RTS] -ref libraries/base/GHC/ST.hs:134:7: Note [Definition of runRW#] ref linters/lint-notes/Notes.hs:32:29: Note [" <> T.unpack x <> "] ref linters/lint-notes/Notes.hs:69:22: Note [...] ref testsuite/config/ghc:243:10: Note [WayFlags] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/541aedcd9023445b8e914d595ae8dcf2e799d618 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/541aedcd9023445b8e914d595ae8dcf2e799d618 You're receiving 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 Jan 5 15:49:29 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 05 Jan 2023 10:49:29 -0500 Subject: [Git][ghc/ghc][master] EPA: Do not collect comments from end of file Message-ID: <63b6f189c034e_f192a527b0308135@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 9 changed files: - compiler/GHC/Parser.y - testsuite/tests/ghc-api/exactprint/RmDecl4.expected.hs - testsuite/tests/ghc-api/exactprint/Test20239.stderr - + testsuite/tests/ghc-api/exactprint/ZeroWidthSemi.hs - + testsuite/tests/ghc-api/exactprint/ZeroWidthSemi.stderr - testsuite/tests/ghc-api/exactprint/all.T - testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr - testsuite/tests/parser/should_compile/T20718.stderr - testsuite/tests/printer/Test20297.stdout Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -1076,8 +1076,10 @@ qcname :: { LocatedN RdrName } -- Variable or type constructor -- One or more semicolons semis1 :: { Located [TrailingAnn] } -semis1 : semis1 ';' { sLL $1 $> $ if isZeroWidthSpan (gl $2) then (unLoc $1) else (AddSemiAnn (glAA $2) : (unLoc $1)) } - | ';' { sL1 $1 $ msemi $1 } +semis1 : semis1 ';' { if isZeroWidthSpan (gl $2) then (sL1 $1 $ unLoc $1) else (sLL $1 $> $ AddSemiAnn (glAA $2) : (unLoc $1)) } + | ';' { case msemi $1 of + [] -> noLoc [] + ms -> sL1 $1 $ ms } -- Zero or more semicolons semis :: { [TrailingAnn] } ===================================== testsuite/tests/ghc-api/exactprint/RmDecl4.expected.hs ===================================== @@ -7,5 +7,4 @@ ff y = y + zz + xx zz = 1 - -- EOF ===================================== testsuite/tests/ghc-api/exactprint/Test20239.stderr ===================================== @@ -24,7 +24,14 @@ { Test20239.hs:7:34-63 }))) (EpaCommentsBalanced [] - [])) + [(L + (Anchor + { Test20239.hs:7:34-63 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- ^ Run any arbitrary IO code") + { Test20239.hs:6:86 }))])) (VirtualBraces (1)) (Nothing) @@ -50,15 +57,7 @@ (EpaComment (EpaLineComment "-- | Leading Haddock Comment") - { Test20239.hs:1:18-22 })) - ,(L - (Anchor - { Test20239.hs:7:34-63 } - (UnchangedAnchor)) - (EpaComment - (EpaLineComment - "-- ^ Run any arbitrary IO code") - { Test20239.hs:6:86 }))])) { Test20239.hs:(4,1)-(6,86) }) + { Test20239.hs:1:18-22 }))])) { Test20239.hs:(4,1)-(6,86) }) (InstD (NoExtField) (DataFamInstD ===================================== testsuite/tests/ghc-api/exactprint/ZeroWidthSemi.hs ===================================== @@ -0,0 +1,8 @@ +module ZeroWidthSemi where + +-- leading comments + +-- Function comment +a = 0 + +-- Trailing comment, should be in HsModule extension point ===================================== testsuite/tests/ghc-api/exactprint/ZeroWidthSemi.stderr ===================================== @@ -0,0 +1,134 @@ + +==================== Parser AST ==================== + +(L + { ZeroWidthSemi.hs:1:1 } + (HsModule + (XModulePs + (EpAnn + (Anchor + { ZeroWidthSemi.hs:1:1 } + (UnchangedAnchor)) + (AnnsModule + [(AddEpAnn AnnModule (EpaSpan { ZeroWidthSemi.hs:1:1-6 })) + ,(AddEpAnn AnnWhere (EpaSpan { ZeroWidthSemi.hs:1:22-26 }))] + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + []) + (Just + ((,) + { ZeroWidthSemi.hs:9:1 } + { ZeroWidthSemi.hs:8:1-58 }))) + (EpaCommentsBalanced + [(L + (Anchor + { ZeroWidthSemi.hs:3:1-19 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- leading comments") + { ZeroWidthSemi.hs:1:22-26 }))] + [(L + (Anchor + { ZeroWidthSemi.hs:8:1-58 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- Trailing comment, should be in HsModule extension point") + { ZeroWidthSemi.hs:6:5 }))])) + (VirtualBraces + (1)) + (Nothing) + (Nothing)) + (Just + (L + (SrcSpanAnn (EpAnnNotUsed) { ZeroWidthSemi.hs:1:8-20 }) + {ModuleName: ZeroWidthSemi})) + (Nothing) + [] + [(L + (SrcSpanAnn (EpAnn + (Anchor + { ZeroWidthSemi.hs:6:1-5 } + (UnchangedAnchor)) + (AnnListItem + []) + (EpaComments + [(L + (Anchor + { ZeroWidthSemi.hs:5:1-19 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- Function comment") + { ZeroWidthSemi.hs:3:1-19 }))])) { ZeroWidthSemi.hs:6:1-5 }) + (ValD + (NoExtField) + (FunBind + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { ZeroWidthSemi.hs:6:1 }) + (Unqual + {OccName: a})) + (MG + (FromSource) + (L + (SrcSpanAnn (EpAnnNotUsed) { ZeroWidthSemi.hs:6:1-5 }) + [(L + (SrcSpanAnn (EpAnnNotUsed) { ZeroWidthSemi.hs:6:1-5 }) + (Match + (EpAnn + (Anchor + { ZeroWidthSemi.hs:6:1-5 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (FunRhs + (L + (SrcSpanAnn (EpAnnNotUsed) { ZeroWidthSemi.hs:6:1 }) + (Unqual + {OccName: a})) + (Prefix) + (NoSrcStrict)) + [] + (GRHSs + (EpaComments + []) + [(L + (SrcSpanAnn + (EpAnnNotUsed) + { ZeroWidthSemi.hs:6:3-5 }) + (GRHS + (EpAnn + (Anchor + { ZeroWidthSemi.hs:6:3-5 } + (UnchangedAnchor)) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { ZeroWidthSemi.hs:6:3 }))) + (EpaComments + [])) + [] + (L + (SrcSpanAnn (EpAnnNotUsed) { ZeroWidthSemi.hs:6:5 }) + (HsOverLit + (EpAnn + (Anchor + { ZeroWidthSemi.hs:6:5 } + (UnchangedAnchor)) + (NoEpAnns) + (EpaComments + [])) + (OverLit + (NoExtField) + (HsIntegral + (IL + (SourceText 0) + (False) + (0))))))))] + (EmptyLocalBinds + (NoExtField)))))])))))])) ===================================== testsuite/tests/ghc-api/exactprint/all.T ===================================== @@ -37,3 +37,4 @@ test('RmTypeSig2', ignore_stderr, makefile_test, ['RmTypeSig2']) test('AddHiding1', ignore_stderr, makefile_test, ['AddHiding1']) test('AddHiding2', ignore_stderr, makefile_test, ['AddHiding2']) test('Test20239', normal, compile_fail, ['-dsuppress-uniques -ddump-parsed-ast -dkeep-comments']) +test('ZeroWidthSemi', normal, compile, ['-dsuppress-uniques -ddump-parsed-ast -dkeep-comments']) ===================================== testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr ===================================== @@ -82,15 +82,7 @@ (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:13:3 + { DumpParsedAstComments.hs:9:1-20 }))])) { DumpParsedAstComments.hs:(11,1)-(13,3) }) (ValD (NoExtField) @@ -219,7 +211,15 @@ (AnnListItem []) (EpaComments - [])) { DumpParsedAstComments.hs:16:1-23 }) + [(L + (Anchor + { DumpParsedAstComments.hs:15:1-20 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- | Haddock comment") + { DumpParsedAstComments.hs:13:3 + }))])) { DumpParsedAstComments.hs:16:1-23 }) (ValD (NoExtField) (FunBind ===================================== testsuite/tests/parser/should_compile/T20718.stderr ===================================== @@ -55,7 +55,22 @@ (EpaLineComment "-- before 2") { T20718.hs:5:1-11 }))] - [])) + [(L + (Anchor + { T20718.hs:10:1-8 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- end 1") + { T20718.hs:8:5 })) + ,(L + (Anchor + { T20718.hs:11:1-8 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- end 2") + { T20718.hs:10:1-8 }))])) (VirtualBraces (1)) (Nothing) @@ -74,22 +89,7 @@ (AnnListItem []) (EpaComments - [(L - (Anchor - { T20718.hs:10:1-8 } - (UnchangedAnchor)) - (EpaComment - (EpaLineComment - "-- end 1") - { T20718.hs:8:5 })) - ,(L - (Anchor - { T20718.hs:11:1-8 } - (UnchangedAnchor)) - (EpaComment - (EpaLineComment - "-- end 2") - { T20718.hs:10:1-8 }))])) { T20718.hs:8:1-5 }) + [])) { T20718.hs:8:1-5 }) (ValD (NoExtField) (FunBind ===================================== testsuite/tests/printer/Test20297.stdout ===================================== @@ -50,14 +50,7 @@ (AnnListItem []) (EpaComments - [(L - (Anchor - { Test20297.hs:7:9-19 } - (UnchangedAnchor)) - (EpaComment - (EpaLineComment - "-- comment1") - { Test20297.hs:7:3-7 }))])) { Test20297.hs:(5,1)-(7,7) }) + [])) { Test20297.hs:(5,1)-(7,7) }) (ValD (NoExtField) (FunBind @@ -150,7 +143,14 @@ (AnnListItem []) (EpaComments - [])) { Test20297.hs:(9,1)-(11,26) }) + [(L + (Anchor + { Test20297.hs:7:9-19 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- comment1") + { Test20297.hs:7:3-7 }))])) { Test20297.hs:(9,1)-(11,26) }) (ValD (NoExtField) (FunBind View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/22bb89989fc0a907ef6b8f6ae99aa8907f67e438 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/22bb89989fc0a907ef6b8f6ae99aa8907f67e438 You're receiving 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 Jan 5 17:00:19 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 05 Jan 2023 12:00:19 -0500 Subject: [Git][ghc/ghc][wip/andreask/spec-pragma] Allow combination of NOINLINE/INLINEABLE. Message-ID: <63b70223cd101_f192a52724318074@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/spec-pragma at Glasgow Haskell Compiler / GHC Commits: 3f827d1c by Andreas Klebinger at 2023-01-05T17:59:05+01:00 Allow combination of NOINLINE/INLINEABLE. We do this by also tracking INLINEABLE outside of the Unfolding data type as it's own flag. In the proccess of this I made a few other smaller changes. * Allow NOINLINE bindings to specialise with -fspecialise-aggressively. Fixes #21036 * Made rule source a proper type instead of Bool. ------------------------- Metric Decrease: T14766 T18304 Metric Increase: T10359 T13386 T15263 ------------------------- - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Id.hs - compiler/GHC/Types/Id/Info.hs - compiler/GHC/Utils/Outputable.hs - docs/users_guide/exts/pragmas.rst - testsuite/tests/simplCore/should_compile/T15445.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3f827d1c0600c30332be112188e7f32631ceb49f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3f827d1c0600c30332be112188e7f32631ceb49f You're receiving 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 Jan 5 17:20:20 2023 From: gitlab at gitlab.haskell.org (aaa (@project_1_bot2)) Date: Thu, 05 Jan 2023 12:20:20 -0500 Subject: [Git][ghc/ghc][wip/t22599] hack Message-ID: <63b706d4c4ff1_f192a1978bf903259c3@gitlab.mail> aaa pushed to branch wip/t22599 at Glasgow Haskell Compiler / GHC Commits: 5e9a750c by GHC GitLab CI at 2023-01-06T01:20:09+08:00 hack - - - - - 2 changed files: - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix Changes: ===================================== .gitlab/ci.sh ===================================== @@ -219,13 +219,16 @@ function set_toolchain_paths() { else ARCH="x86_64"; fi - arch -arm64 clang++ -v a.cpp -o a.o -# arch -arm64 clang++ -v a.o -o a - # arch -arm64 clang -v a.o c++ -lc++abi -o a +# arch -arm64 clang++ -v -c a.cpp -o a.o +# lipo -info a.o + +# arch -arm64 clang++ --target=aarch64-darwin -v a.o -o a +# arch -arm64 clang -v a.o -lc++ -lc++abi -o a +# clang -v a.o -lc++ -lc++abi -o a echo $ARCH echo $NIX_SYSTEM - arch "-$ARCH" nix-build .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh + nix-build .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh cat toolchain.sh fi source toolchain.sh ;; ===================================== .gitlab/darwin/toolchain.nix ===================================== @@ -37,8 +37,9 @@ let "CONF_GCC_LINKER_OPTS_STAGE2=--target=${targetTriple}" ]; buildPhase = "true"; - postUnpackPhase = '' - /usr/bin/clang -v + preConfigure = '' + sed "s/\"\$CC\" -o actest actest.o \''${1} 2>\/dev\/null/true/i" configure + cat configure ''; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e9a750c7cf584f80b7c2b4a4f0c1673cad96c31 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e9a750c7cf584f80b7c2b4a4f0c1673cad96c31 You're receiving 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 Jan 5 17:34:38 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 05 Jan 2023 12:34:38 -0500 Subject: [Git][ghc/ghc][wip/T22404] Wibbles Message-ID: <63b70a2e2ec2b_f192a1a78b3a0328123@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22404 at Glasgow Haskell Compiler / GHC Commits: cce16400 by Simon Peyton Jones at 2023-01-05T17:34:56+00:00 Wibbles - - - - - 1 changed file: - compiler/GHC/Core/Opt/OccurAnal.hs Changes: ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -780,9 +780,10 @@ occAnalNonRecIdBind !env imp_rule_edges tagged_bndr rhs is_join_point = isJust mb_join_arity --------- Right hand side --------- - env1 | is_join_point = env -- See Note [Join point RHSs] - | certainly_inline = env -- See Note [Cascading inlines] - | otherwise = rhsCtxt env + env1 = setRhsCtxt rhs_ctxt env + rhs_ctxt | certainly_inline = OccVanilla -- See Note [Cascading inlines] + | is_join_point = OccVanilla -- See Note [Join point RHSs] + | otherwise = OccRhs -- See Note [Sources of one-shot information] rhs_env = env1 { occ_one_shots = argOneShots dmd } @@ -1436,7 +1437,7 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) -- Do not use occAnalRhs because we don't yet know the final -- answer for mb_join_arity; instead, do the occAnalLam call from -- occAnalRhs, and postpone adjustRhsUsage until occAnalRec - rhs_env = rhsCtxt env + rhs_env = setRhsCtxt OccRhs env (WithUsageDetails rhs_uds rhs') = occAnalLam rhs_env rhs --------- Unfolding --------- @@ -1858,7 +1859,7 @@ occAnalLam env (Lam bndr body) -- For casts, keep going in the same lambda-group -- See Note [Occurrence analysis for lambda binders] occAnalLam env (Cast expr co) - = let (WithUsageDetails usage expr') = occAnalLam env expr + = let WithUsageDetails usage expr' = occAnalLam env expr -- usage1: see Note [Gather occurrences of coercion variables] usage1 = addManyOccs usage (coVarsOfCo co) @@ -2055,7 +2056,7 @@ a big deal. Note [Cascading inlines] ~~~~~~~~~~~~~~~~~~~~~~~~ -By default we use an rhsCtxt for the RHS of a binding. This tells the +By default we use an OccRhs for the RHS of a binding. This tells the occ anal n that it's looking at an RHS, which has an effect in occAnalApp. In particular, for constructor applications, it makes the arguments appear to have NoOccInfo, so that we don't inline into @@ -2076,7 +2077,7 @@ Result: multiple simplifier iterations. Sigh. So, when analysing the RHS of x3 we notice that x3 will itself definitely inline the next time round, and so we analyse x3's rhs in -an ordinary context, not rhsCtxt. Hence the "certainly_inline" stuff. +an OccVanilla context, not OccRhs. Hence the "certainly_inline" stuff. Annoyingly, we have to approximate GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally. If (a) the RHS is expandable (see isExpandableApp in occAnalApp), and @@ -2569,8 +2570,8 @@ scrutCtxt !env alts -- non-default alternative. That in turn influences -- pre/postInlineUnconditionally. Grep for "occ_int_cxt"! -rhsCtxt :: OccEnv -> OccEnv -rhsCtxt !env = env { occ_encl = OccRhs, occ_one_shots = [] } +setRhsCtxt :: OccEncl -> OccEnv -> OccEnv +setRhsCtxt ctxt !env = env { occ_encl = ctxt, occ_one_shots = [] } valArgCtxt :: OccEnv -> [OneShots] -> (OccEnv, [OneShots]) valArgCtxt !env [] @@ -2599,19 +2600,13 @@ addInScope env@(OccEnv { occ_join_points = join_points }) bndrs thing_inside drop_shadowed_joins :: OccEnv -> OccEnv -- See Note [Occurrence analysis for join points] - drop_shadowed_joins env - | isEmptyVarEnv bad_joins - , not (any (`elemVarEnv` join_points) bndrs) - = env -- Non-allocating short cut; common case - | otherwise = env { occ_join_points = good_joins `delVarEnvList` bndrs} - where + drop_shadowed_joins env = env { occ_join_points = good_joins `delVarEnvList` bndrs} fix_up_uds :: WithUsageDetails a -> WithUsageDetails a -- Add usage info for (a) CoVars used in the types of bndrs -- and (b) occ_join_points that we cannot push inwards because of shadowing fix_up_uds (WithUsageDetails uds res) - = with_joins `seq` - WithUsageDetails with_joins res + = WithUsageDetails with_joins res where trimmed_uds = uds `delDetails` bndrs with_co_var_occs = trimmed_uds `addManyOccs` coVarOccs bndrs View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cce16400259b52721f264b4b7dbb2d6b0e817dc4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cce16400259b52721f264b4b7dbb2d6b0e817dc4 You're receiving 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 Jan 5 21:21:51 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 05 Jan 2023 16:21:51 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Misc cleanup Message-ID: <63b73f6f4f73f_f192a199a1e243491c5@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - ed2d8275 by Vladislav Zavialov at 2023-01-05T16:21:45-05:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - 5748992a by Matthew Pickering at 2023-01-05T16:21:45-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/HsToCore/ListComp.hs - compiler/GHC/HsToCore/Pmc/Desugar.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/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/Stg/BcPrep.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Layout.hs - compiler/GHC/StgToJS/Deps.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6e8e6ea141312ea9463d7c8e23ee2d8c6ee4f922...5748992a7480bb500eac10dde648c0c2fa760a43 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6e8e6ea141312ea9463d7c8e23ee2d8c6ee4f922...5748992a7480bb500eac10dde648c0c2fa760a43 You're receiving 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 Jan 6 01:45:16 2023 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Thu, 05 Jan 2023 20:45:16 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] 479 commits: Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) Message-ID: <63b77d2c749f8_f192a23f10bf838476e@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall 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. - - - - - 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 - - - - - 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]. - - - - - 2eb0fb87 by Matthew Pickering at 2022-12-15T03:54:39-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 - - - - - 552b7908 by Ben Gamari at 2022-12-15T03:55:15-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. - - - - - 933d61a4 by Simon Peyton Jones at 2022-12-15T03:55:51-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. - - - - - 03ed0b95 by Ryan Scott at 2022-12-15T03:56:26-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. - - - - - ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/ThreadPaused: Ordering fixes - - - - - 914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00 eventlog: Silence spurious data race - - - - - fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts: Use fences instead of explicit barriers - - - - - 2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - 70999283 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 98689f77 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - 86f20258 by Ben Gamari at 2022-12-16T16:12:45-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. - - - - - f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate access to capabilities array - - - - - 7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate sched_state - - - - - 1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Style fix - - - - - 82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00 compiler: Use release store in eager blackholing - - - - - eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Fix ordering of makeStableName - - - - - ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Note race with wakeBlockingQueue - - - - - 5acf33dd by Bodigrim at 2022-12-16T16:13:22-05:00 Bump submodule directory to 1.3.8.0 and hpc to HEAD - - - - - 0dd95421 by Bodigrim at 2022-12-16T16:13:22-05:00 Accept allocations increase on Windows This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips between lists and ByteArray. See #22625 for discussion. Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T10547 T12150 T12227 T12234 T12425 T13035 T13253 T13253-spj T13701 T13719 T15703 T16875 T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T21839r T5837 T6048 T9198 T9961 TcPlugin_RewritePerf hard_hole_fits - - - - - ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00 testsuite: Mark T9405 as fragile instead of broken on Windows It's starting to pass again, and the unexpected pass blocks CI. - - - - - 1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: remove obsolete commented code in wasm NCG It was just a temporary hack to workaround a bug in the relooper, that bug has been fixed long before the wasm backend is merged. - - - - - e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm Also removes some unreachable code here. - - - - - 1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: change fallback function signature to Cmm function signature in wasm NCG In the wasm NCG, when handling a `CLabel` of undefined function without knowing its function signature, we used to fallback to `() -> ()` which is accepted by `wasm-ld`. This patch changes it to the signature of Cmm functions, which equally works, but would be required when we emit tail call instructions. - - - - - 8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add optional tail-call support in wasm NCG When the `-mtail-call` clang flag is passed at configure time, wasm tail-call extension is enabled, and the wasm NCG will emit `return_call`/`return_call_indirect` instructions to take advantage of it and avoid the `StgRun` trampoline overhead. Closes #22461. - - - - - d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00 base: add missing autoconf checks for waitpid/umask These are not present in wasi-libc. Required for fixing #22589 - - - - - da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00 compiler: make .wasm the default executable extension on wasm32 Following convention as in other wasm toolchains. Fixes #22594. - - - - - ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00 ci: support hello.wasm in ci.sh cross testing logic - - - - - 6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00 Correct `exitWith` Haddocks The `IOError`-specific `catch` in the Prelude is long gone. - - - - - b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-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. - - - - - 761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00 rts/libdw: Silence uninitialized usage warnings As noted in #22538, previously some GCC versions warned that various locals in Libdw.c may be used uninitialized. Although this wasn't strictly true (since they were initialized in an inline assembler block) we fix this by providing explicit empty initializers. Fixes #22538 - - - - - 5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00 testsuite: Mark T16392 as fragile on windows See #22649 - - - - - 703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00 Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`. - - - - - 9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05: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 - - - - - 7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Drop uses of AC_PROG_CC_C99 As noted in #22566, this macro is deprecated as of autoconf-2.70 `AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself. Closes #22566. - - - - - 36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Use AS_HELP_STRING instead of AC_HELP_STRING The latter has been deprecated. See #22566. - - - - - befe6ff8 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: fix various usages of head and tail - - - - - 666d0ba7 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: avoid head and tail in parseCallEscape and around - - - - - 5d96fd50 by Bodigrim at 2022-12-20T21:16:37-05:00 Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty - - - - - 3ce2ab94 by Bodigrim at 2022-12-21T06:17:56-05:00 Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian - - - - - 954de93a by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule haskeline to HEAD (to allow transformers-0.6) - - - - - cefbeec3 by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule transformers to 0.6.0.4 - - - - - b4730b62 by Bodigrim at 2022-12-21T06:17:56-05:00 Fix tests T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations Metric Increase: T13253 - - - - - 0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05: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. - - - - - df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00 rts: explicitly store return value of ccall checkClosure to prevent type error (#22617) - - - - - e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix shadowing lacuna in OccurAnal Issue #22623 demonstrated another lacuna in the implementation of wrinkle (BS3) in Note [The binder-swap substitution] in the occurrence analyser. I was failing to add TyVar lambda binders using addInScope/addOneInScope and that led to a totally bogus binder-swap transformation. Very easy to fix. - - - - - 3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix an assertion check in addToEqualCtList The old assertion saw that a constraint ct could rewrite itself (of course it can) and complained (stupid). Fixes #22645 - - - - - ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00 configure: Bump version to 9.6 - - - - - fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00 base: Bump version to 4.18 Requires various submodule bumps. - - - - - 93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00 ghc-boot: Fix bootstrapping - - - - - fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00 Bump GHC version to 9.7 - - - - - 914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05: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. - - - - - 32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00 hadrian bindist: Install manpages to share/man/man1/ghc.1 When the installation makefile was copied over the manpages were no longer installed in the correct place. Now we install it into share/man/man1/ghc.1 as the make build system did. Fixes #22371 - - - - - b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00 rts: Drop paths from configure from cabal file A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them. - - - - - b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00 Bump libffi-tarballs submodule We will now use libffi-3.4.4. - - - - - 3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00 EPA: Make EOF position part of AnnsModule Closes #20951 Closes #19697 - - - - - 99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00 JS: fix support for -outputdir (#22641) The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug. - - - - - 02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00 Refactor mkRuntimeError This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions. - - - - - 35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00 base: Fix event manager shutdown race on non-Linux platforms During shutdown it's possible that we will attempt to use a closed fd to wakeup another capability's event manager. On the Linux eventfd path we were careful to handle this. However on the non-Linux path we failed to do so. Fix this. - - - - - 317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00 Fix unifier bug: failing to decompose over-saturated type family This simple patch fixes #22647 - - - - - 14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00 rts/m32: Fix sanity checking Previously we would attempt to clear pages which were marked as read-only. Fix this. - - - - - 16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00 ci: Move wasm pipelines into nightly rather than master See #22664 for the changes which need to be made to bring one of these back to the validate pipeline. - - - - - 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-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). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Bodigrim at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - 541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 033b4c77 by Luite Stegeman at 2023-01-06T10:43:02+09:00 Add PrimCallConv suppport to GHCi - - - - - b5600941 by Luite Stegeman at 2023-01-06T10:43:02+09:00 make bytecode assembler assertion failures more descriptive - - - - - 16 changed files: - .editorconfig - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - + .gitlab/hello.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - 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 The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/66466845060d02dbf9202241b7bf878d8d931060...b560094198b113cb34a028178a6d86987858b936 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/66466845060d02dbf9202241b7bf878d8d931060...b560094198b113cb34a028178a6d86987858b936 You're receiving 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 Jan 6 04:02:17 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 05 Jan 2023 23:02:17 -0500 Subject: [Git][ghc/ghc][master] HsToken in TypeArg (#19623) Message-ID: <63b79d49dee37_f192a221df7003909f3@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05: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 ===================================== @@ -1389,7 +1389,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 ===================================== @@ -2199,7 +2199,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 ===================================== @@ -693,12 +693,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 @@ -1929,7 +1929,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) @@ -1698,7 +1698,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 @@ -1890,10 +1890,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 ===================================== @@ -656,7 +656,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 @@ -716,7 +719,7 @@ (L (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:18:19-26 }) (HsAppKindTy - { DumpParsedAst.hs:18:21 } + (NoExtField) (L (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:18:19 }) (HsTyVar @@ -732,6 +735,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 ===================================== @@ -1998,12 +1998,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 -- --------------------------------------------------------------------- @@ -3777,7 +3777,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 @@ -3801,7 +3801,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) @@ -3842,11 +3842,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 261a7c8ac5b5ff29e6e0380690cbb6ee9730f985 +Subproject commit 519a95998b09a2c9c7a42c3a0cf2ca0c4358bb49 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9e077999eb3d09af6f31eb92233d4d757ece75f8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9e077999eb3d09af6f31eb92233d4d757ece75f8 You're receiving 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 Jan 6 04:02:56 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 05 Jan 2023 23:02:56 -0500 Subject: [Git][ghc/ghc][master] Revert "configure: Drop uses of AC_PROG_CC_C99" Message-ID: <63b79d703d3b_f192a24acf41c395839@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - 3 changed files: - configure.ac - distrib/configure.ac.in - + m4/fp_set_cflags_c99.m4 Changes: ===================================== configure.ac ===================================== @@ -485,6 +485,11 @@ FP_CPP_CMD_WITH_ARGS(HaskellCPPCmd, HaskellCPPArgs) AC_SUBST([HaskellCPPCmd]) AC_SUBST([HaskellCPPArgs]) +FP_SET_CFLAGS_C99([CC],[CFLAGS],[CPPFLAGS]) +FP_SET_CFLAGS_C99([CC_STAGE0],[CONF_CC_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0]) +FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1]) +FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) + dnl ** Which ld to use dnl -------------------------------------------------------------- AC_ARG_VAR(LD,[Use as the path to ld. See also --disable-ld-override.]) ===================================== distrib/configure.ac.in ===================================== @@ -111,6 +111,11 @@ FP_CPP_CMD_WITH_ARGS(HaskellCPPCmd, HaskellCPPArgs) AC_SUBST([HaskellCPPCmd]) AC_SUBST([HaskellCPPArgs]) +FP_SET_CFLAGS_C99([CC],[CFLAGS],[CPPFLAGS]) +dnl FP_SET_CFLAGS_C99([CC_STAGE0],[CONF_CC_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0]) +FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1]) +FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) + dnl ** Which ld to use? dnl -------------------------------------------------------------- FIND_LD([$target],[GccUseLdOpt]) ===================================== m4/fp_set_cflags_c99.m4 ===================================== @@ -0,0 +1,38 @@ +# FP_SET_CFLAGS_C99 +# ---------------------------------- +# figure out which CFLAGS are needed to place the compiler into C99 mode +# $1 is name of CC variable (unmodified) +# $2 is name of CC flags variable (augmented if needed) +# $3 is name of CPP flags variable (augmented if needed) +AC_DEFUN([FP_SET_CFLAGS_C99], +[ + dnl save current state of AC_PROG_CC_C99 + FP_COPY_SHELLVAR([CC],[fp_save_CC]) + FP_COPY_SHELLVAR([CFLAGS],[fp_save_CFLAGS]) + FP_COPY_SHELLVAR([CPPFLAGS],[fp_save_CPPFLAGS]) + FP_COPY_SHELLVAR([ac_cv_prog_cc_c99],[fp_save_cc_c99]) + dnl set local state + CC="$$1" + CFLAGS="$$2" + CPPFLAGS="$$3" + unset ac_cv_prog_cc_c99 + dnl perform detection + AC_PROG_CC_C99 + fp_cc_c99="$ac_cv_prog_cc_c99" + case "x$ac_cv_prog_cc_c99" in + x) ;; # noop + xno) AC_MSG_ERROR([C99-compatible compiler needed]) ;; + *) $2="$$2 $ac_cv_prog_cc_c99" + $3="$$3 $ac_cv_prog_cc_c99" + ;; + esac + dnl restore saved state + FP_COPY_SHELLVAR([fp_save_CC],[CC]) + FP_COPY_SHELLVAR([fp_save_CFLAGS],[CFLAGS]) + FP_COPY_SHELLVAR([fp_save_CPPFLAGS],[CPPFLAGS]) + FP_COPY_SHELLVAR([fp_save_cc_c99],[ac_cv_prog_cc_c99]) + dnl cleanup + unset fp_save_CC + unset fp_save_CFLAGS + unset fp_save_cc_c99 +]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b2a2db04b24a4654261db8e0db6ad7bac1b3d7cf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b2a2db04b24a4654261db8e0db6ad7bac1b3d7cf You're receiving 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 Jan 6 04:45:35 2023 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Thu, 05 Jan 2023 23:45:35 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] fix typo in testcase Message-ID: <63b7a76fe06c9_f192a23f10bf8400082@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: bdfcab04 by Luite Stegeman at 2023-01-06T13:44:21+09:00 fix typo in testcase - - - - - 1 changed file: - testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm Changes: ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm ===================================== @@ -118,7 +118,7 @@ cmm_floating_7( W_ x1, F_ x2, D_ x3 y3 = %fadd(y3,x18); y3 = %fadd(y3,x21); - return ( y1, y2, y2 ); + return ( y1, y2, y3 ); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bdfcab04ec8a00b0eac94ce03a8d651c8e1685da -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bdfcab04ec8a00b0eac94ce03a8d651c8e1685da You're receiving 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 Jan 6 04:46:31 2023 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Thu, 05 Jan 2023 23:46:31 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] fix whitespace Message-ID: <63b7a7a749be8_f192a199a1e24400773@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 6c5a7aa5 by Luite Stegeman at 2023-01-06T13:46:15+09:00 fix whitespace - - - - - 1 changed file: - compiler/GHC/Cmm/CallConv.hs Changes: ===================================== compiler/GHC/Cmm/CallConv.hs ===================================== @@ -241,7 +241,7 @@ realArgRegsCover platform possible combinations of register values. Instead, there are generic helper stack frames that use a call_info word that describes the active registers and the number of stack words used by the arguments of a call. - + These helper stack frames are currently: - stg_ret_t: return a tuple to the continuation at the top of the stack View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c5a7aa533e4e627ea8e2aeae814dcfc52bc8d73 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c5a7aa533e4e627ea8e2aeae814dcfc52bc8d73 You're receiving 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 Jan 6 04:51:46 2023 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Thu, 05 Jan 2023 23:51:46 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] fix GHCiPrimCall expected output Message-ID: <63b7a8e2a2fd4_f192a1f049808401264@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 4d2aba40 by Luite Stegeman at 2023-01-06T13:51:00+09:00 fix GHCiPrimCall expected output - - - - - 1 changed file: - testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout Changes: ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout ===================================== @@ -43,7 +43,7 @@ additional floating point tests [-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] [(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e307),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e307),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e307),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e307),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e307),(Infinity,8060400.0),(1.0e37,8060400.0),(1.0e37,8060400.0),(1.0e37,8060399.0),(1.0e37,8060401.0),(1.0e37,8060398.0),(1.0e37,8060402.0),(1.0e37,Infinity),(1.0e37,1.0e307),(1.0e37,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0)] [(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e37),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e37),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e37),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e37),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e37),(Infinity,8060400.0),(1.0e307,8060400.0),(1.0e307,8060400.0),(1.0e307,8060399.0),(1.0e307,8060401.0),(1.0e307,8060398.0),(1.0e307,8060402.0),(1.0e307,Infinity),(1.0e307,1.0e37),(1.0e307,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0)] -[(69,2.017141e12,-0.0),(69,2.017141e12,0.0),(69,2.017141e12,-1.0),(69,2.017141e12,1.0),(69,2.017141e12,-2.0),(69,2.017141e12,2.0),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,-1.0e-307),(69,2.017141e12,-0.0),(69,2.017141e12,0.0),(69,2.017141e12,-1.0),(69,2.017141e12,1.0),(69,2.017141e12,-2.0),(69,2.017141e12,2.0),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,-1.0e-307),(69,2.017141e12,-0.0),(69,2.017141e12,0.0),(69,2.017141e12,-1.0),(69,2.017141e12,1.0),(69,2.017141e12,-2.0),(69,2.017141e12,2.0),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,-1.0e-307),(69,2.017141e12,-0.0),(69,2.017141e12,0.0),(69,2.017141e12,-1.0),(69,2.017141e12,1.0),(69,2.017141e12,-2.0),(69,2.017141e12,2.0),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,-1.0e-307),(69,2.017141e12,-0.0),(69,2.017141e12,0.0),(69,2.017141e12,-1.0),(69,2.017141e12,1.0),(69,2.017141e12,-2.0),(69,2.017141e12,2.0),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,-1.0e-307),(69,2.017141e12,-0.0),(69,2.017141e12,0.0),(69,2.017141e12,-1.0),(69,2.017141e12,1.0),(69,2.017141e12,-2.0),(69,2.017141e12,2.0),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,-1.0e-307),(69,Infinity,-0.0),(69,Infinity,0.0),(69,Infinity,-1.0),(69,Infinity,1.0),(69,Infinity,-2.0),(69,Infinity,2.0),(69,Infinity,Infinity),(69,Infinity,1.0e307),(69,Infinity,-1.0e-307),(69,1.0e37,-0.0),(69,1.0e37,0.0),(69,1.0e37,-1.0),(69,1.0e37,1.0),(69,1.0e37,-2.0),(69,1.0e37,2.0),(69,1.0e37,Infinity),(69,1.0e37,1.0e307),(69,1.0e37,-1.0e-307),(69,2.017141e12,-0.0),(69,2.017141e12,0.0),(69,2.017141e12,-1.0),(69,2.017141e12,1.0),(69,2.017141e12,-2.0),(69,2.017141e12,2.0),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,-1.0e-307),(70,2.017141e12,-0.0),(70,2.017141e12,0.0),(70,2.017141e12,-1.0),(70,2.017141e12,1.0),(70,2.017141e12,-2.0),(70,2.017141e12,2.0),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,-1.0e-307),(70,2.017141e12,-0.0),(70,2.017141e12,0.0),(70,2.017141e12,-1.0),(70,2.017141e12,1.0),(70,2.017141e12,-2.0),(70,2.017141e12,2.0),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,-1.0e-307),(70,2.017141e12,-0.0),(70,2.017141e12,0.0),(70,2.017141e12,-1.0),(70,2.017141e12,1.0),(70,2.017141e12,-2.0),(70,2.017141e12,2.0),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,-1.0e-307),(70,2.017141e12,-0.0),(70,2.017141e12,0.0),(70,2.017141e12,-1.0),(70,2.017141e12,1.0),(70,2.017141e12,-2.0),(70,2.017141e12,2.0),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,-1.0e-307),(70,2.017141e12,-0.0),(70,2.017141e12,0.0),(70,2.017141e12,-1.0),(70,2.017141e12,1.0),(70,2.017141e12,-2.0),(70,2.017141e12,2.0),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,-1.0e-307),(70,2.017141e12,-0.0),(70,2.017141e12,0.0),(70,2.017141e12,-1.0),(70,2.017141e12,1.0),(70,2.017141e12,-2.0),(70,2.017141e12,2.0),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,-1.0e-307),(70,Infinity,-0.0),(70,Infinity,0.0),(70,Infinity,-1.0),(70,Infinity,1.0),(70,Infinity,-2.0),(70,Infinity,2.0),(70,Infinity,Infinity),(70,Infinity,1.0e307),(70,Infinity,-1.0e-307),(70,1.0e37,-0.0),(70,1.0e37,0.0),(70,1.0e37,-1.0),(70,1.0e37,1.0),(70,1.0e37,-2.0),(70,1.0e37,2.0),(70,1.0e37,Infinity),(70,1.0e37,1.0e307),(70,1.0e37,-1.0e-307),(70,2.017141e12,-0.0),(70,2.017141e12,0.0),(70,2.017141e12,-1.0),(70,2.017141e12,1.0),(70,2.017141e12,-2.0),(70,2.017141e12,2.0),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,-1.0e-307),(71,2.017141e12,-0.0),(71,2.017141e12,0.0),(71,2.017141e12,-1.0),(71,2.017141e12,1.0),(71,2.017141e12,-2.0),(71,2.017141e12,2.0),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,-1.0e-307),(71,2.017141e12,-0.0),(71,2.017141e12,0.0),(71,2.017141e12,-1.0),(71,2.017141e12,1.0),(71,2.017141e12,-2.0),(71,2.017141e12,2.0),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,-1.0e-307),(71,2.017141e12,-0.0),(71,2.017141e12,0.0),(71,2.017141e12,-1.0),(71,2.017141e12,1.0),(71,2.017141e12,-2.0),(71,2.017141e12,2.0),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,-1.0e-307),(71,2.017141e12,-0.0),(71,2.017141e12,0.0),(71,2.017141e12,-1.0),(71,2.017141e12,1.0),(71,2.017141e12,-2.0),(71,2.017141e12,2.0),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,-1.0e-307),(71,2.017141e12,-0.0),(71,2.017141e12,0.0),(71,2.017141e12,-1.0),(71,2.017141e12,1.0),(71,2.017141e12,-2.0),(71,2.017141e12,2.0),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,-1.0e-307),(71,2.017141e12,-0.0),(71,2.017141e12,0.0),(71,2.017141e12,-1.0),(71,2.017141e12,1.0),(71,2.017141e12,-2.0),(71,2.017141e12,2.0),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,-1.0e-307),(71,Infinity,-0.0),(71,Infinity,0.0),(71,Infinity,-1.0),(71,Infinity,1.0),(71,Infinity,-2.0),(71,Infinity,2.0),(71,Infinity,Infinity),(71,Infinity,1.0e307),(71,Infinity,-1.0e-307),(71,1.0e37,-0.0),(71,1.0e37,0.0),(71,1.0e37,-1.0),(71,1.0e37,1.0),(71,1.0e37,-2.0),(71,1.0e37,2.0),(71,1.0e37,Infinity),(71,1.0e37,1.0e307),(71,1.0e37,-1.0e-307),(71,2.017141e12,-0.0),(71,2.017141e12,0.0),(71,2.017141e12,-1.0),(71,2.017141e12,1.0),(71,2.017141e12,-2.0),(71,2.017141e12,2.0),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,-1.0e-307),(68,2.017141e12,-0.0),(68,2.017141e12,0.0),(68,2.017141e12,-1.0),(68,2.017141e12,1.0),(68,2.017141e12,-2.0),(68,2.017141e12,2.0),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,-1.0e-307),(68,2.017141e12,-0.0),(68,2.017141e12,0.0),(68,2.017141e12,-1.0),(68,2.017141e12,1.0),(68,2.017141e12,-2.0),(68,2.017141e12,2.0),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,-1.0e-307),(68,2.017141e12,-0.0),(68,2.017141e12,0.0),(68,2.017141e12,-1.0),(68,2.017141e12,1.0),(68,2.017141e12,-2.0),(68,2.017141e12,2.0),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,-1.0e-307),(68,2.017141e12,-0.0),(68,2.017141e12,0.0),(68,2.017141e12,-1.0),(68,2.017141e12,1.0),(68,2.017141e12,-2.0),(68,2.017141e12,2.0),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,-1.0e-307),(68,2.017141e12,-0.0),(68,2.017141e12,0.0),(68,2.017141e12,-1.0),(68,2.017141e12,1.0),(68,2.017141e12,-2.0),(68,2.017141e12,2.0),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,-1.0e-307),(68,2.017141e12,-0.0),(68,2.017141e12,0.0),(68,2.017141e12,-1.0),(68,2.017141e12,1.0),(68,2.017141e12,-2.0),(68,2.017141e12,2.0),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,-1.0e-307),(68,Infinity,-0.0),(68,Infinity,0.0),(68,Infinity,-1.0),(68,Infinity,1.0),(68,Infinity,-2.0),(68,Infinity,2.0),(68,Infinity,Infinity),(68,Infinity,1.0e307),(68,Infinity,-1.0e-307),(68,1.0e37,-0.0),(68,1.0e37,0.0),(68,1.0e37,-1.0),(68,1.0e37,1.0),(68,1.0e37,-2.0),(68,1.0e37,2.0),(68,1.0e37,Infinity),(68,1.0e37,1.0e307),(68,1.0e37,-1.0e-307),(68,2.017141e12,-0.0),(68,2.017141e12,0.0),(68,2.017141e12,-1.0),(68,2.017141e12,1.0),(68,2.017141e12,-2.0),(68,2.017141e12,2.0),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,-1.0e-307)] +[(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.1181512090599e13),(69,Infinity,2.1181512090601e13),(69,Infinity,2.1181512090598e13),(69,Infinity,2.1181512090602e13),(69,Infinity,Infinity),(69,Infinity,1.0e307),(69,Infinity,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.1181512090599e13),(69,1.0e37,2.1181512090601e13),(69,1.0e37,2.1181512090598e13),(69,1.0e37,2.1181512090602e13),(69,1.0e37,Infinity),(69,1.0e37,1.0e307),(69,1.0e37,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.1181512090599e13),(70,Infinity,2.1181512090601e13),(70,Infinity,2.1181512090598e13),(70,Infinity,2.1181512090602e13),(70,Infinity,Infinity),(70,Infinity,1.0e307),(70,Infinity,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.1181512090599e13),(70,1.0e37,2.1181512090601e13),(70,1.0e37,2.1181512090598e13),(70,1.0e37,2.1181512090602e13),(70,1.0e37,Infinity),(70,1.0e37,1.0e307),(70,1.0e37,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.1181512090599e13),(71,Infinity,2.1181512090601e13),(71,Infinity,2.1181512090598e13),(71,Infinity,2.1181512090602e13),(71,Infinity,Infinity),(71,Infinity,1.0e307),(71,Infinity,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.1181512090599e13),(71,1.0e37,2.1181512090601e13),(71,1.0e37,2.1181512090598e13),(71,1.0e37,2.1181512090602e13),(71,1.0e37,Infinity),(71,1.0e37,1.0e307),(71,1.0e37,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.1181512090599e13),(68,Infinity,2.1181512090601e13),(68,Infinity,2.1181512090598e13),(68,Infinity,2.1181512090602e13),(68,Infinity,Infinity),(68,Infinity,1.0e307),(68,Infinity,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.1181512090599e13),(68,1.0e37,2.1181512090601e13),(68,1.0e37,2.1181512090598e13),(68,1.0e37,2.1181512090602e13),(68,1.0e37,Infinity),(68,1.0e37,1.0e307),(68,1.0e37,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13)] various sized tuple returns [(3,0,0),(3,1,0),(3,2,0),(3,18446744073709551615,0),(3,0,1),(3,1,1),(3,2,1),(3,18446744073709551615,1),(3,0,2),(3,1,2),(3,2,2),(3,18446744073709551615,2),(3,0,18446744073709551615),(3,1,18446744073709551615),(3,2,18446744073709551615),(3,18446744073709551615,18446744073709551615)] [(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just (-18446744073709551617))] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4d2aba408321ed72562dbbbbcda1de6218707205 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4d2aba408321ed72562dbbbbcda1de6218707205 You're receiving 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 Jan 6 08:03:13 2023 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Fri, 06 Jan 2023 03:03:13 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] 8 commits: HsToken in TypeArg (#19623) Message-ID: <63b7d5c138668_f192a28ca3e604104ee@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - f00059b2 by Luite Stegeman at 2023-01-06T14:03:47+09:00 Add PrimCallConv suppport to GHCi - - - - - ef05668c by Luite Stegeman at 2023-01-06T14:03:47+09:00 make bytecode assembler assertion failures more descriptive - - - - - 66bcc2db by Luite Stegeman at 2023-01-06T14:03:47+09:00 fix typo in testcase - - - - - f5ea9a1e by Luite Stegeman at 2023-01-06T14:03:47+09:00 fix whitespace - - - - - 2ab54402 by Luite Stegeman at 2023-01-06T14:03:47+09:00 fix GHCiPrimCall expected output - - - - - ee171e8b by Luite Stegeman at 2023-01-06T16:53:29+09:00 add GHCiPrimCall expected test output for wordsize 32 - - - - - 30 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Parser.y - 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/StgToByteCode.hs - compiler/GHC/StgToCmm/Foreign.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 - configure.ac - distrib/configure.ac.in - + m4/fp_set_cflags_c99.m4 - rts/Disassembler.c - rts/Interpreter.c - rts/RtsSymbols.c - rts/StgMiscClosures.cmm - rts/include/rts/Bytecodes.h - rts/include/stg/MiscClosures.h The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4d2aba408321ed72562dbbbbcda1de6218707205...ee171e8b127a7f11aedbfe45e284f08636588dec -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4d2aba408321ed72562dbbbbcda1de6218707205...ee171e8b127a7f11aedbfe45e284f08636588dec You're receiving 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 Jan 6 08:57:51 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 06 Jan 2023 03:57:51 -0500 Subject: [Git][ghc/ghc][wip/t22599] fix Message-ID: <63b7e28f757a4_f192a1978bfa4416811@gitlab.mail> Matthew Pickering pushed to branch wip/t22599 at Glasgow Haskell Compiler / GHC Commits: d294dcde by Matthew Pickering at 2023-01-06T08:57:27+00:00 fix - - - - - 1 changed file: - .gitlab/darwin/toolchain.nix Changes: ===================================== .gitlab/darwin/toolchain.nix ===================================== @@ -36,9 +36,10 @@ let "CONF_CXX_OPTS_STAGE2=--target=${targetTriple}" "CONF_GCC_LINKER_OPTS_STAGE2=--target=${targetTriple}" ]; - buildPhase = "true"; + buildPhase = "true"; preConfigure = '' - sed "s/\"\$CC\" -o actest actest.o \''${1} 2>\/dev\/null/true/i" configure + sed "s/\"\$CC\" -o actest actest.o \''${1} 2>\/dev\/null/true/i" configure > configure.new + mv configure.new configure cat configure ''; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d294dcde20920bdf2c42fb9a2b0ae8e06f971cd3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d294dcde20920bdf2c42fb9a2b0ae8e06f971cd3 You're receiving 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 Jan 6 09:11:03 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Fri, 06 Jan 2023 04:11:03 -0500 Subject: [Git][ghc/ghc][wip/int-index/tok-where] fixup! WIP: HsModuleHeaderTokens Message-ID: <63b7e5a7d8d0e_f192a199a1e2442097@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/tok-where at Glasgow Haskell Compiler / GHC Commits: 99d695c7 by Andrei Borzenkov at 2023-01-04T17:02:36+04:00 fixup! WIP: HsModuleHeaderTokens Fix tests passing for `WIP: HsModuleHeaderTokens` - - - - - 17 changed files: - testsuite/tests/ghc-api/exactprint/Test20239.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/module/mod185.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/parser/should_compile/KindSigs.stderr - testsuite/tests/parser/should_compile/T15323.stderr - testsuite/tests/parser/should_compile/T20452.stderr - testsuite/tests/parser/should_compile/T20718.stderr - testsuite/tests/parser/should_compile/T20718b.stderr - testsuite/tests/parser/should_compile/T20846.stderr - testsuite/tests/printer/T18791.stderr - testsuite/tests/printer/Test20297.stdout - utils/check-exact/ExactPrint.hs - utils/check-exact/Transform.hs Changes: ===================================== testsuite/tests/ghc-api/exactprint/Test20239.stderr ===================================== @@ -38,6 +38,15 @@ (1)) (Nothing) (Nothing)) + (HsModTk + (L + (TokenLoc + (EpaSpan { Test20239.hs:1:1-6 })) + (HsTok)) + (L + (TokenLoc + (EpaSpan { Test20239.hs:1:18-22 })) + (HsTok))) (Just (L (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:1:8-16 }) ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -31,6 +31,15 @@ (1)) (Nothing) (Nothing)) + (HsModTk + (L + (TokenLoc + (EpaSpan { T17544.hs:3:1-6 })) + (HsTok)) + (L + (TokenLoc + (EpaSpan { T17544.hs:3:15-19 })) + (HsTok))) (Just (L (SrcSpanAnn (EpAnnNotUsed) { T17544.hs:3:8-13 }) ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -43,6 +43,15 @@ " Bad comment for the module")) [])) [])))) + (HsModTk + (L + (TokenLoc + (EpaSpan { T17544_kw.hs:11:1-6 })) + (HsTok)) + (L + (TokenLoc + (EpaSpan { T17544_kw.hs:13:13-17 })) + (HsTok))) (Just (L (SrcSpanAnn (EpAnnNotUsed) { T17544_kw.hs:13:3-11 }) @@ -371,5 +380,3 @@ " Bad comment for clsmethod")) [])) []))))])))])) - - ===================================== testsuite/tests/module/mod185.stderr ===================================== @@ -30,6 +30,7 @@ (1)) (Nothing) (Nothing)) + (HsNoModTk) (Nothing) (Nothing) [(L ===================================== testsuite/tests/parser/should_compile/DumpParsedAst.stderr ===================================== @@ -31,6 +31,15 @@ (1)) (Nothing) (Nothing)) + (HsModTk + (L + (TokenLoc + (EpaSpan { DumpParsedAst.hs:5:1-6 })) + (HsTok)) + (L + (TokenLoc + (EpaSpan { DumpParsedAst.hs:5:22-26 })) + (HsTok))) (Just (L (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:5:8-20 }) @@ -1537,5 +1546,3 @@ {FastString: "hello"})))))))] (EmptyLocalBinds (NoExtField)))))])))))])) - - ===================================== testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr ===================================== @@ -47,6 +47,15 @@ (1)) (Nothing) (Nothing)) + (HsModTk + (L + (TokenLoc + (EpaSpan { DumpParsedAstComments.hs:5:1-6 })) + (HsTok)) + (L + (TokenLoc + (EpaSpan { DumpParsedAstComments.hs:5:30-34 })) + (HsTok))) (Just (L (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:5:8-28 }) ===================================== testsuite/tests/parser/should_compile/DumpSemis.stderr ===================================== @@ -42,6 +42,15 @@ (1)) (Nothing) (Nothing)) + (HsModTk + (L + (TokenLoc + (EpaSpan { DumpSemis.hs:1:1-6 })) + (HsTok)) + (L + (TokenLoc + (EpaSpan { DumpSemis.hs:1:18-22 })) + (HsTok))) (Just (L (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:1:8-16 }) @@ -2121,5 +2130,3 @@ (NoExtField)))))]))))))] (EmptyLocalBinds (NoExtField)))))])))))])) - - ===================================== testsuite/tests/parser/should_compile/KindSigs.stderr ===================================== @@ -31,6 +31,15 @@ (1)) (Nothing) (Nothing)) + (HsModTk + (L + (TokenLoc + (EpaSpan { KindSigs.hs:6:1-6 })) + (HsTok)) + (L + (TokenLoc + (EpaSpan { KindSigs.hs:6:17-21 })) + (HsTok))) (Just (L (SrcSpanAnn (EpAnnNotUsed) { KindSigs.hs:6:8-15 }) ===================================== testsuite/tests/parser/should_compile/T15323.stderr ===================================== @@ -31,6 +31,15 @@ (1)) (Nothing) (Nothing)) + (HsModTk + (L + (TokenLoc + (EpaSpan { T15323.hs:3:1-6 })) + (HsTok)) + (L + (TokenLoc + (EpaSpan { T15323.hs:3:15-19 })) + (HsTok))) (Just (L (SrcSpanAnn (EpAnnNotUsed) { T15323.hs:3:8-13 }) @@ -233,5 +242,3 @@ {OccName: v})))))) (Nothing)))]) []))))])) - - ===================================== testsuite/tests/parser/should_compile/T20452.stderr ===================================== @@ -31,6 +31,15 @@ (1)) (Nothing) (Nothing)) + (HsModTk + (L + (TokenLoc + (EpaSpan { T20452.hs:3:1-6 })) + (HsTok)) + (L + (TokenLoc + (EpaSpan { T20452.hs:3:15-19 })) + (HsTok))) (Just (L (SrcSpanAnn (EpAnnNotUsed) { T20452.hs:3:8-13 }) @@ -627,5 +636,3 @@ [] [] [])))])) - - ===================================== testsuite/tests/parser/should_compile/T20718.stderr ===================================== @@ -62,6 +62,15 @@ (1)) (Nothing) (Nothing)) + (HsModTk + (L + (TokenLoc + (EpaSpan { T20718.hs:3:1-6 })) + (HsTok)) + (L + (TokenLoc + (EpaSpan { T20718.hs:3:15-19 })) + (HsTok))) (Just (L (SrcSpanAnn (EpAnnNotUsed) { T20718.hs:3:8-13 }) ===================================== testsuite/tests/parser/should_compile/T20718b.stderr ===================================== @@ -62,6 +62,15 @@ (1)) (Nothing) (Nothing)) + (HsModTk + (L + (TokenLoc + (EpaSpan { T20718b.hs:4:1-6 })) + (HsTok)) + (L + (TokenLoc + (EpaSpan { T20718b.hs:4:16-20 })) + (HsTok))) (Just (L (SrcSpanAnn (EpAnnNotUsed) { T20718b.hs:4:8-14 }) @@ -69,5 +78,3 @@ (Nothing) [] [])) - - ===================================== testsuite/tests/parser/should_compile/T20846.stderr ===================================== @@ -31,6 +31,15 @@ (1)) (Nothing) (Nothing)) + (HsModTk + (L + (TokenLoc + (EpaSpan { T20846.hs:1:1-6 })) + (HsTok)) + (L + (TokenLoc + (EpaSpan { T20846.hs:1:15-19 })) + (HsTok))) (Just (L (SrcSpanAnn (EpAnnNotUsed) { T20846.hs:1:8-13 }) ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -31,6 +31,15 @@ (1)) (Nothing) (Nothing)) + (HsModTk + (L + (TokenLoc + (EpaSpan { T18791.hs:2:1-6 })) + (HsTok)) + (L + (TokenLoc + (EpaSpan { T18791.hs:2:15-19 })) + (HsTok))) (Just (L (SrcSpanAnn (EpAnnNotUsed) { T18791.hs:2:8-13 }) @@ -143,5 +152,3 @@ {OccName: T})))) (Nothing)))]) []))))])) - - ===================================== testsuite/tests/printer/Test20297.stdout ===================================== @@ -38,6 +38,15 @@ (1)) (Nothing) (Nothing)) + (HsModTk + (L + (TokenLoc + (EpaSpan { Test20297.hs:2:1-6 })) + (HsTok)) + (L + (TokenLoc + (EpaSpan { Test20297.hs:2:18-22 })) + (HsTok))) (Just (L (SrcSpanAnn (EpAnnNotUsed) { Test20297.hs:2:8-16 }) @@ -385,6 +394,15 @@ (1)) (Nothing) (Nothing)) + (HsModTk + (L + (TokenLoc + (EpaSpan { Test20297.ppr.hs:2:1-6 })) + (HsTok)) + (L + (TokenLoc + (EpaSpan { Test20297.ppr.hs:2:18-22 })) + (HsTok))) (Just (L (SrcSpanAnn (EpAnnNotUsed) { Test20297.ppr.hs:2:8-16 }) @@ -669,4 +687,3 @@ (EmptyLocalBinds (NoExtField)))))]))))]} [])))))])))))])) - ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -1367,7 +1367,7 @@ instance ExactPrint (HsModule GhcPs) where `debug` ("setAnnotationAnchor hsmod called" ++ showAst (anc,cs)) exact hsmod@(HsModule {hsmodExt = XModulePs { hsmodAnn = EpAnnNotUsed }}) = withPpr hsmod >> return hsmod - exact (HsModule (XModulePs an lo mdeprec mbDoc) mmn mexports imports decls) = do + exact (HsModule (XModulePs an lo mdeprec mbDoc) headertoks mmn mexports imports decls) = do mbDoc' <- markAnnotated mbDoc @@ -1398,7 +1398,7 @@ instance ExactPrint (HsModule GhcPs) where let anf = an0 { anns = (anns an0) { am_decls = am_decls' }} debugM $ "HsModule, anf=" ++ showAst anf - return (HsModule (XModulePs anf lo mdeprec' mbDoc') mmn' mexports' imports' decls') + return (HsModule (XModulePs anf lo mdeprec' mbDoc') headertoks mmn' mexports' imports' decls') -- --------------------------------------------------------------------- ===================================== utils/check-exact/Transform.hs ===================================== @@ -753,7 +753,7 @@ balanceSameLineComments (L la (Match anm mctxt pats (GRHSs x grhss lb))) = do -- --------------------------------------------------------------------- anchorEof :: ParsedSource -> ParsedSource -anchorEof (L l m@(HsModule (XModulePs an _lo _ _) _mn _exps _imps _decls)) = L l (m { hsmodExt = (hsmodExt m){ hsmodAnn = an' } }) +anchorEof (L l m@(HsModule (XModulePs an _lo _ _) _ht _mn _exps _imps _decls)) = L l (m { hsmodExt = (hsmodExt m){ hsmodAnn = an' } }) where an' = addCommentOrigDeltasAnn an @@ -893,12 +893,12 @@ class (Data t) => HasDecls t where -- --------------------------------------------------------------------- instance HasDecls ParsedSource where - hsDecls (L _ (HsModule (XModulePs _ _lo _ _) _mn _exps _imps decls)) = return decls - replaceDecls (L l (HsModule (XModulePs a lo deps haddocks) mname exps imps _decls)) decls + hsDecls (L _ (HsModule (XModulePs _ _lo _ _) _ht _mn _exps _imps decls)) = return decls + replaceDecls (L l (HsModule (XModulePs a lo deps haddocks) headertoks mname exps imps _decls)) decls = do logTr "replaceDecls LHsModule" -- modifyAnnsT (captureOrder m decls) - return (L l (HsModule (XModulePs a lo deps haddocks) mname exps imps decls)) + return (L l (HsModule (XModulePs a lo deps haddocks) headertoks mname exps imps decls)) -- --------------------------------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/99d695c7b4af6e6df4bfbc6f9316e7d0cbf28e98 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/99d695c7b4af6e6df4bfbc6f9316e7d0cbf28e98 You're receiving 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 Jan 6 09:40:44 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 06 Jan 2023 04:40:44 -0500 Subject: [Git][ghc/ghc][wip/t22599] 16 commits: Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Message-ID: <63b7ec9ca51b3_f192a199a1e2445096d@gitlab.mail> Matthew Pickering pushed to branch wip/t22599 at Glasgow Haskell Compiler / GHC Commits: 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - 541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - 2da60292 by Matthew Pickering at 2023-01-06T09:40:30+00:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Data/EnumSet.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/DocString.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/HsToCore/ListComp.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.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/d294dcde20920bdf2c42fb9a2b0ae8e06f971cd3...2da6029237c54628fa69223f62eee12f8715c0f5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d294dcde20920bdf2c42fb9a2b0ae8e06f971cd3...2da6029237c54628fa69223f62eee12f8715c0f5 You're receiving 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 Jan 6 10:04:41 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 06 Jan 2023 05:04:41 -0500 Subject: [Git][ghc/ghc][wip/T20666] 5 commits: Misc cleanup Message-ID: <63b7f23954cfa_f192a23f10bf845165f@gitlab.mail> Simon Peyton Jones pushed to branch wip/T20666 at Glasgow Haskell Compiler / GHC Commits: 541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - 5d4956aa by Richard Eisenberg at 2023-01-06T10:05:08+00:00 Refactor the treatment of loopy superclass dicts This patch completely re-engineers how we deal with loopy superclass dictionaries in instance declarations. It fixes #20666. The highlights are * Recognise that the loopy-superclass business should use precisely the Paterson conditions. This is much much nicer. See Note [Recursive superclasses] in GHC.Tc.TyCl.Instance * With that in mind, define "Paterson-smaller" in Note [Paterson conditions] in GHC.Tc.Validity, and the new data type `PatersonSize` in GHC.Tc.Utils.TcType, along with functions to compute and compare PatsonSizes * Use the new PatersonSize stuff when solving superclass constraints See Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance * In GHC.Tc.Solver.Monad.lookupInInerts, add a missing call to prohibitedSuperClassSolve. This was the original cause of #20666. * Treat (TypeError "stuff") as having PatersonSize zero. See Note [Paterson size for type family applications] in GHC.Tc.Utils.TcType. * Some refactoring way in which redundant constraints are reported; we don't want to complain about the extra, apparently-redundant constraints that we must add to an instance decl because of the loopy-superclass thing. I moved some work from GHC.Tc.Errors to GHC.Tc.Solver. * Add a new section to the user manual to describe the loopy superclass issue and what rules it follows. - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/HsToCore/ListComp.hs - compiler/GHC/HsToCore/Pmc/Desugar.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/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/Stg/BcPrep.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Layout.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd57ec2d180f45cc49f78dd6d5497ec0fe22e6d2...5d4956aaf052aca9d7e1cc25327858ce2058f1a6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd57ec2d180f45cc49f78dd6d5497ec0fe22e6d2...5d4956aaf052aca9d7e1cc25327858ce2058f1a6 You're receiving 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 Jan 6 10:09:40 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 06 Jan 2023 05:09:40 -0500 Subject: [Git][ghc/ghc][wip/T20666] Refactor the treatment of loopy superclass dicts Message-ID: <63b7f364a8f0b_f192a26e0eb9445231b@gitlab.mail> Simon Peyton Jones pushed to branch wip/T20666 at Glasgow Haskell Compiler / GHC Commits: a7b64fc7 by Richard Eisenberg at 2023-01-06T10:10:04+00:00 Refactor the treatment of loopy superclass dicts This patch completely re-engineers how we deal with loopy superclass dictionaries in instance declarations. It fixes #20666. The highlights are * Recognise that the loopy-superclass business should use precisely the Paterson conditions. This is much much nicer. See Note [Recursive superclasses] in GHC.Tc.TyCl.Instance * With that in mind, define "Paterson-smaller" in Note [Paterson conditions] in GHC.Tc.Validity, and the new data type `PatersonSize` in GHC.Tc.Utils.TcType, along with functions to compute and compare PatsonSizes * Use the new PatersonSize stuff when solving superclass constraints See Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance * In GHC.Tc.Solver.Monad.lookupInInerts, add a missing call to prohibitedSuperClassSolve. This was the original cause of #20666. * Treat (TypeError "stuff") as having PatersonSize zero. See Note [Paterson size for type family applications] in GHC.Tc.Utils.TcType. * Some refactoring way in which redundant constraints are reported; we don't want to complain about the extra, apparently-redundant constraints that we must add to an instance decl because of the loopy-superclass thing. I moved some work from GHC.Tc.Errors to GHC.Tc.Solver. * Add a new section to the user manual to describe the loopy superclass issue and what rules it follows. - - - - - 30 changed files: - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Infer.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/InertSet.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types/Constraint.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/Tc/Validity.hs - docs/users_guide/exts/instances.rst - testsuite/tests/deriving/should_compile/T14339.hs - testsuite/tests/deriving/should_fail/T21302.hs - testsuite/tests/deriving/should_fail/T8165_fail2.stderr - testsuite/tests/indexed-types/should_fail/NotRelaxedExamples.stderr - testsuite/tests/indexed-types/should_fail/T10817.stderr - testsuite/tests/indexed-types/should_fail/T13271.stderr - testsuite/tests/indexed-types/should_fail/T15172.stderr - testsuite/tests/indexed-types/should_fail/TyFamUndec.stderr - testsuite/tests/typecheck/should_compile/T15473.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a7b64fc7b5c68975280f3f59139d64eacf449fdd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a7b64fc7b5c68975280f3f59139d64eacf449fdd You're receiving 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 Jan 6 10:10:20 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 06 Jan 2023 05:10:20 -0500 Subject: [Git][ghc/ghc][wip/t22599] ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Message-ID: <63b7f38c6d8c_f192a292139b8453088@gitlab.mail> Matthew Pickering pushed to branch wip/t22599 at Glasgow Haskell Compiler / GHC Commits: baa3e031 by Matthew Pickering at 2023-01-06T10:09:58+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 ===================================== @@ -213,10 +213,14 @@ function set_toolchain_paths() { x86_64-darwin|aarch64-darwin) ;; *) fail "unknown NIX_SYSTEM" ;; esac - nix build -f .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh + info "Building toolchain for $NIX_SYSTEM" + nix-build .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh cat toolchain.sh fi - source toolchain.sh ;; + source toolchain.sh + info "--info for GHC for $NIX_SYSTEM" + $GHC --info + ;; env) # These are generally set by the Docker image but # we provide these handy fallbacks in case the @@ -320,7 +324,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 = [ @@ -38,6 +38,21 @@ let ]; buildPhase = "true"; + # This is a horrible hack because the configure script invokes /usr/bin/clang + # without a `--target` flag. Then depending on whether the `nix` binary itself is + # a native x86 or arm64 binary means that /usr/bin/clang thinks it needs to run in + # x86 or arm64 mode. + + # The correct answer for the check in question is the first one we try, so by replacing + # the condition to true; we select the right C++ standard library still. + preConfigure = '' + sed "s/\"\$CC\" -o actest actest.o \''${1} 2>\/dev\/null/true/i" configure > configure.new + mv configure.new configure + chmod +x configure + cat configure + + ''; + # N.B. Work around #20253. nativeBuildInputs = [ pkgs.gnused ]; postInstallPhase = '' ===================================== .gitlab/gen_ci.hs ===================================== @@ -349,8 +349,8 @@ 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" - , "CABAL_INSTALL_VERSION" =: "3.6.2.0" + , "GHC_VERSION" =: "9.4.3" + , "CABAL_INSTALL_VERSION" =: "3.8.1.0" ] opsysVariables _ (Linux distro) = distroVariables distro opsysVariables AArch64 (Darwin {}) = @@ -378,8 +378,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 ===================================== @@ -594,9 +594,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.6.2.0", + "CABAL_INSTALL_VERSION": "3.8.1.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" @@ -1793,9 +1793,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", @@ -1852,9 +1852,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", @@ -2225,9 +2225,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-release", "BUILD_FLAVOUR": "release", - "CABAL_INSTALL_VERSION": "3.6.2.0", + "CABAL_INSTALL_VERSION": "3.8.1.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", @@ -2957,9 +2957,9 @@ "BIGNUM_BACKEND": "native", "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", + "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", @@ -3017,9 +3017,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-release+no_split_sections", "BUILD_FLAVOUR": "release+no_split_sections", - "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", @@ -3145,9 +3145,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.6.2.0", + "CABAL_INSTALL_VERSION": "3.8.1.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" } @@ -4326,9 +4326,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", @@ -4384,9 +4384,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/baa3e031735070ff25f4e05c2b14e084bcab4281 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/baa3e031735070ff25f4e05c2b14e084bcab4281 You're receiving 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 Jan 6 10:26:30 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 06 Jan 2023 05:26:30 -0500 Subject: [Git][ghc/ghc][wip/andreask/spec-transitive] First PoC partially done Message-ID: <63b7f75649e2_f192a1978bfa4458381@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/spec-transitive at Glasgow Haskell Compiler / GHC Commits: 1c93cdb6 by Andreas Klebinger at 2023-01-06T11:25:00+01:00 First PoC partially done - - - - - 29 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - + compiler/GHC/Core/Opt/SpecRec.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Id.hs - compiler/GHC/Types/Id/Info.hs - compiler/GHC/Types/SourceText.hs - compiler/Language/Haskell/Syntax/Binds.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -60,7 +60,7 @@ module GHC.Core ( -- ** Predicates and deconstruction on 'Unfolding' unfoldingTemplate, expandUnfolding_maybe, - maybeUnfoldingTemplate, otherCons, + maybeUnfoldingTemplate, maybeUnfoldingSource, otherCons, isValueUnfolding, isEvaldUnfolding, isCheapUnfolding, isExpandableUnfolding, isConLikeUnfolding, isCompulsoryUnfolding, isStableUnfolding, isStableUserUnfolding, isStableSystemUnfolding, @@ -1454,6 +1454,11 @@ maybeUnfoldingTemplate (DFunUnfolding { df_bndrs = bndrs, df_con = con, df_args maybeUnfoldingTemplate _ = Nothing +maybeUnfoldingSource :: Unfolding -> Maybe UnfoldingSource +maybeUnfoldingSource (CoreUnfolding { uf_src = src }) + = Just src +maybeUnfoldingSource _ = Nothing + -- | The constructors that the unfolding could never be: -- returns @[]@ if no information is available otherCons :: Unfolding -> [AltCon] ===================================== compiler/GHC/Core/FVs.hs ===================================== @@ -31,10 +31,11 @@ module GHC.Core.FVs ( bndrRuleAndUnfoldingIds, idFVs, idRuleVars, stableUnfoldingVars, - ruleFreeVars, rulesFreeVars, + ruleFreeVars, rulesFreeVars, rulesSomeFreeVars, rulesSomeFreeVarsList, rulesFreeVarsDSet, mkRuleInfo, ruleLhsFreeIds, ruleLhsFreeIdsList, ruleRhsFreeVars, rulesRhsFreeIds, + rulesRhsSomeFVs, ruleRhsSomeFreeVars, exprFVs, @@ -466,34 +467,47 @@ data RuleFVsFrom -- | Those locally-defined variables free in the left and/or right hand sides -- of the rule, depending on the first argument. Returns an 'FV' computation. ruleFVs :: RuleFVsFrom -> CoreRule -> FV -ruleFVs !_ (BuiltinRule {}) = emptyFV -ruleFVs from (Rule { ru_fn = _do_not_include +ruleFVs = ruleSomeFVs isLocalVar + +ruleSomeFVs :: InterestingVarFun -> RuleFVsFrom -> CoreRule -> FV +ruleSomeFVs _fv_cand !_ (BuiltinRule {}) = emptyFV +ruleSomeFVs fv_cand from (Rule { ru_fn = _do_not_include -- See Note [Rule free var hack] , ru_bndrs = bndrs , ru_rhs = rhs, ru_args = args }) - = filterFV isLocalVar $ addBndrs bndrs (exprs_fvs exprs) + = filterFV fv_cand $ addBndrs bndrs (exprs_fvs exprs) where exprs = case from of LhsOnly -> args RhsOnly -> [rhs] BothSides -> rhs:args - -- | Those locally-defined variables free in the left and/or right hand sides -- from several rules, depending on the first argument. -- Returns an 'FV' computation. rulesFVs :: RuleFVsFrom -> [CoreRule] -> FV rulesFVs from = mapUnionFV (ruleFVs from) +rulesSomeFVs :: InterestingVarFun -> RuleFVsFrom -> [CoreRule] -> FV +rulesSomeFVs fv_cand from = mapUnionFV (ruleSomeFVs fv_cand from) + -- | Those variables free in the right hand side of a rule returned as a -- non-deterministic set ruleRhsFreeVars :: CoreRule -> VarSet ruleRhsFreeVars = fvVarSet . ruleFVs RhsOnly +-- | Those variables free in the right hand side of a rule returned as a +-- non-deterministic set +ruleRhsSomeFreeVars :: InterestingVarFun -> CoreRule -> VarSet +ruleRhsSomeFreeVars fv_cand = fvVarSet . ruleSomeFVs fv_cand RhsOnly + -- | Those locally-defined free 'Id's in the right hand side of several rules -- returned as a non-deterministic set rulesRhsFreeIds :: [CoreRule] -> VarSet rulesRhsFreeIds = fvVarSet . filterFV isLocalId . rulesFVs RhsOnly +rulesRhsSomeFVs :: InterestingVarFun -> [CoreRule] -> VarSet +rulesRhsSomeFVs fv_cand = fvVarSet . rulesSomeFVs fv_cand RhsOnly + ruleLhsFreeIds :: CoreRule -> VarSet -- ^ This finds all locally-defined free Ids on the left hand side of a rule -- and returns them as a non-deterministic set @@ -518,6 +532,12 @@ rulesFreeVarsDSet rules = fvDVarSet $ rulesFVs BothSides rules rulesFreeVars :: [CoreRule] -> VarSet rulesFreeVars rules = fvVarSet $ rulesFVs BothSides rules +rulesSomeFreeVars :: InterestingVarFun -> [CoreRule] -> VarSet +rulesSomeFreeVars fv_cand rules = fvVarSet $ rulesSomeFVs fv_cand BothSides rules + +rulesSomeFreeVarsList :: InterestingVarFun -> [CoreRule] -> [Var] +rulesSomeFreeVarsList fv_cand rules = fvVarList $ rulesSomeFVs fv_cand BothSides rules + -- | Make a 'RuleInfo' containing a number of 'CoreRule's, suitable -- for putting into an 'IdInfo' mkRuleInfo :: [CoreRule] -> RuleInfo ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -677,6 +677,7 @@ mkCastWrapperPragInfo prag_info , inl_rule = rule_info } -- in GHC.Core.Opt.WorkWrap -- RuleMatchInfo is (and must be) unaffected (pragHasInlineable prag_info) + (pragSpecRec prag_info) where -- See Note [Wrapper activation] in GHC.Core.Opt.WorkWrap -- But simpler, because we don't need to disable during InitialPhase ===================================== compiler/GHC/Core/Opt/SpecRec.hs ===================================== @@ -0,0 +1,211 @@ +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE TupleSections #-} + +-- | Transfer specrec pragmas from functions having such a pragma +-- to functions calling such functions. +module GHC.Core.Opt.SpecRec + ( transferSpecRecs + ) where + +import GHC.Prelude + + +import GHC.Types.Basic +import GHC.Driver.Session +import GHC.Types.Name hiding (varName) +import GHC.Types.Id +import GHC.Unit.Module.ModGuts +import GHC.Types.Var.Set +import GHC.Types.Name.Env +import GHC.Unit.Types +import GHC.Core +import GHC.Core.Rules +import GHC.Core.FVs +import GHC.Utils.Outputable + +import Data.Graph +import GHC.Utils.Monad.State.Strict +import Control.Monad +import Data.Maybe +{- +-- We need to transfer the pragma in these cases: + +{-# SPECREC foo #-} +foo = ... + +We transfer the pragma if foo is mentioned in: +* The RHS of a function +* The unfolding. -- TODO: Not needed after desugar? +-- TODO: Rules + +-} + +transferSpecRecs :: ModGuts -> ModGuts +-- transferSpecRecs _dflags guts = guts +transferSpecRecs guts = + let env :: Env + env = Env + { thisModule = mg_module guts + , orphanRules = mkRuleBase (mg_rules guts) + } + in guts { mg_binds = doCoreProgram env (mg_binds guts) + } + +-- bind_fvs (NonRec _ rhs) = +doCoreProgram :: Env -> CoreProgram -> CoreProgram +doCoreProgram env binds = flip evalState (SS mempty mempty) $ do + -- pprTraceM "binds_in" $ vcat $ map ppr binds + let sorted_binds = depAnal (map getName . bindersOf) bind_deps binds + -- pprTraceM "binds_sorted" $ vcat $ map (ppr . bindersOf) sorted_binds + done_binds <- doSccs env sorted_binds + -- pprTraceM "binds_out" $ vcat $ map (ppr . bindersOf) done_binds + return done_binds + where + bind_deps bind = + let bs = bindersOf bind + rhss = rhssOfBind bind + rhss_fvs = exprsSomeFreeVarsList (const True) rhss + unfs = map realIdUnfolding bs + unf_rhs = catMaybes . map maybeUnfoldingTemplate $ unfs + unf_fvs = exprsSomeFreeVarsList (const True) unf_rhs + id_rules = concatMap idCoreRules bs + id_rules_fvs = rulesSomeFreeVarsList (const True) id_rules + in map getName $ unf_fvs ++ id_rules_fvs ++ unf_fvs ++ rhss_fvs + +mcons :: Monad m => a -> m [a] -> m [a] +mcons x xs = liftM (x:) xs + +doSccs :: Env -> [SCC CoreBind] -> M [CoreBind] +doSccs env binds = do + bindss <- mapM (doScc env) binds + pure $ concat bindss + +doScc :: Env -> SCC CoreBind -> M [CoreBind] +doScc env (AcyclicSCC bind) = do + (b,is_spec) <- doBind env bind + when is_spec $ addSpecBinders $ bindersOf b + pure [b] +doScc env (CyclicSCC binds) = do + -- A bunch of binders which might refer to each other in a cyclic fashion via + -- something like rules. So we must put specrec on all of them. + (bs,is_specs) <- unzip <$> mapM (doBind env) binds + when (or is_specs) $ addSpecBinders $ bindersOfBinds bs + pure $ map setSpec bs + +addSpecBinders :: [Id] -> M () +addSpecBinders ids = do + mapM_ addSpec ids + mapM_ addDone ids + return () + +doBind :: Env -> CoreBind -> M (CoreBind, Bool) +doBind env bind = do + to_spec <- spec_set <$> get + let bs = bindersOf bind + rhss = rhssOfBind bind + spec_id = any idHasSpecRec bs + spec_rhs = any (is_spec_expr to_spec) rhss + spec_unf = any (is_spec_unf to_spec . realIdUnfolding) bs + spec_rules = any (is_spec_rules to_spec . idCoreRules) bs + + if spec_id || spec_rhs || spec_unf || spec_rules + -- If the rhs, unfolding or a rule rhs mentions a spec-rec function + -- we must make the function itself spec-rec + then pure (setSpec bind, True) + -- Otherwise another binding might still become spec-rec in the future + else pure (bind, False) + + where + is_spec_rules spec_set rules = + let fvs = rulesRhsSomeFVs (\v -> isId v && idHasSpecRec v || elemVarSet v spec_set) rules + in not (isEmptyVarSet fvs) + + is_spec_expr :: VarSet -> CoreExpr -> Bool + is_spec_expr spec_set expr = + let fvs = exprSomeFreeVars (\v -> isId v && idHasSpecRec v || elemVarSet v spec_set) expr + in not (isEmptyVarSet fvs) + + is_spec_unf :: VarSet -> Unfolding -> Bool + is_spec_unf spec_set unf = do + case maybeUnfoldingSource unf of + -- We already look at the rhs and the unf is the same + Just VanillaSrc -> False + _ -> case maybeUnfoldingTemplate unf of + Just unf_tmpl -> do + is_spec_expr spec_set unf_tmpl + Nothing -> False + + -- TODO: Properly set activation + +setSpec :: Bind Id -> Bind Id +setSpec (NonRec b rhs) = NonRec (setHasSpecRec b (Just AlwaysActive)) rhs +setSpec (Rec pairs) = Rec $ map (\(b,rhs) -> (setHasSpecRec b (Just AlwaysActive), rhs)) pairs + + +-- doBind :: Env -> CoreBind -> M CoreBind +-- doBind env (NonRec b rhs) = NonRec b <$> doExpr (addParent b env) rhs +-- doBind env (Rec bs) = Rec <$> mapM doPair bs +-- where +-- doPair (b,rhs) = (b,) <$> doExpr (addParent b env) rhs + +-- doExpr :: Env -> CoreExpr -> M CoreExpr +-- doExpr env e@(Var v) +-- | needsCallSiteCostCentre env v = do +-- let nameDoc :: SDoc +-- nameDoc = withUserStyle alwaysQualify DefaultDepth $ +-- hcat (punctuate dot (map ppr (parents env))) <> parens (text "calling:" <> ppr v) + +-- ccName :: CcName +-- ccName = mkFastString $ renderWithContext defaultSDocContext nameDoc +-- ccIdx <- getCCIndex' ccName +-- let count = countEntries env +-- span = case revParents env of +-- top:_ -> nameSrcSpan $ varName top +-- _ -> noSrcSpan +-- cc = NormalCC (ExprCC ccIdx) ccName (thisModule env) span +-- tick :: CoreTickish +-- tick = ProfNote cc count True +-- pure $ Tick tick e +-- | otherwise = pure e +-- doExpr _env e@(Lit _) = pure e +-- doExpr env (f `App` x) = App <$> doExpr env f <*> doExpr env x +-- doExpr env (Lam b x) = Lam b <$> doExpr env x +-- doExpr env (Let b rhs) = Let <$> doBind env b <*> doExpr env rhs +-- doExpr env (Case scrut b ty alts) = +-- Case <$> doExpr env scrut <*> pure b <*> pure ty <*> mapM doAlt alts +-- where +-- doAlt (Alt con bs rhs) = Alt con bs <$> doExpr env rhs +-- doExpr env (Cast expr co) = Cast <$> doExpr env expr <*> pure co +-- doExpr env (Tick t e) = Tick t <$> doExpr env e +-- doExpr _env e@(Type _) = pure e +-- doExpr _env e@(Coercion _) = pure e + +data SpecState = SS + { spec_set :: !VarSet + , spec_done :: !VarSet + } + +type M = State SpecState + +addSpec :: Var -> M () +addSpec v = do + s <- get + put $! s { spec_set = extendVarSet (spec_set s) v } + +addDone :: Var -> M () +addDone v = do + s <- get + put $! s { spec_done = extendVarSet (spec_done s) v } + + + +data Env = Env + { thisModule :: Module + , orphanRules :: RuleBase + } + ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -52,6 +52,7 @@ import GHC.Types.Var ( PiTyBinder(..), isLocalVar, isInvisibleFunArg ) import GHC.Types.Var.Set import GHC.Types.Var.Env import GHC.Types.Id +import GHC.Types.Id.Info import GHC.Types.Error import GHC.Utils.Error ( mkMCDiagnostic ) @@ -1613,6 +1614,7 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs | notNull calls_for_me -- And there are some calls to specialise , not (isNeverActive inl_act) || idHasInlineable fn -- Explicit INLINEABLE pragma + || idHasSpecRec fn -- SpecRec || gopt Opt_SpecialiseAggressively dflags -- -fspecialise-aggressively , not (isOpaquePragma inl_prag) -- Don't specialise NOINLINE things by default. @@ -1766,6 +1768,11 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs | otherwise = inl_prag + spec_inlineable = idHasInlineable fn + spec_rec = idSpecRec fn + + spec_prag_info = mkPragInfo spec_inl_prag spec_inlineable spec_rec + -------------------------------------- -- Adding arity information just propagates it a bit faster -- See Note [Arity decrease] in GHC.Core.Opt.Simplify @@ -1773,7 +1780,7 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs -- So if f has INLINE[1] so does spec_fn arity_decr = count isValArg rule_lhs_args - count isId spec_bndrs spec_f_w_arity = spec_fn `setIdArity` max 0 (fn_arity - arity_decr) - `setInlinePragma` spec_inl_prag + `setIdPragmaInfo` spec_prag_info `setIdUnfolding` spec_unf `asJoinId_maybe` spec_join_arity ===================================== compiler/GHC/Core/Opt/WorkWrap.hs ===================================== @@ -830,6 +830,7 @@ mkWWBindPair ww_opts fn_id fn_info fn_args fn_body work_uniq div -- inl_inline: copy from fn_id; see Note [Worker/wrapper for INLINABLE functions] -- inl_act: see Note [Worker activation] -- inl_rule: it does not make sense for workers to be constructorlike. + work_prag_info = mkPragInfo work_prag fn_has_inlineable fn_spec_rec work_join_arity | isJoinId fn_id = Just join_arity | otherwise = Nothing @@ -844,8 +845,7 @@ mkWWBindPair ww_opts fn_id fn_info fn_args fn_body work_uniq div -- Doesn't matter much, since we will simplify next, but -- seems right-er to do so - `setInlinePragma` work_prag - `setHasInlineable` fn_has_inlineable + `setIdPragmaInfo` work_prag_info `setIdUnfolding` mkWorkerUnfolding simpl_opts work_fn fn_unfolding -- See Note [Worker/wrapper for INLINABLE functions] @@ -874,6 +874,7 @@ mkWWBindPair ww_opts fn_id fn_info fn_args fn_body work_uniq div wrap_rhs = wrap_fn work_id wrap_prag = mkStrWrapperInlinePrag fn_inl_prag fn_rules + wrap_prag_info = mkPragInfo wrap_prag fn_has_inlineable fn_spec_rec wrap_unf = mkWrapperUnfolding (simpleOptExpr simpl_opts wrap_rhs) arity wrap_id = fn_id `setIdUnfolding` wrap_unf @@ -881,7 +882,7 @@ mkWWBindPair ww_opts fn_id fn_info fn_args fn_body work_uniq div `setIdOccInfo` noOccInfo -- We must keep hasInlineable to ensure wrappers can specialise -- if they are NOINLINE[final] - `setHasInlineable`fn_has_inlineable + `setIdPragmaInfo` wrap_prag_info -- Zap any loop-breaker-ness, to avoid bleating from Lint -- about a loop breaker with an INLINE rule @@ -890,6 +891,7 @@ mkWWBindPair ww_opts fn_id fn_info fn_args fn_body work_uniq div fn_unfolding = realUnfoldingInfo fn_info fn_has_inlineable = inlineableInfo fn_info fn_rules = ruleInfoRules (ruleInfo fn_info) + fn_spec_rec = specRecInfo fn_info mkStrWrapperInlinePrag :: InlinePragma -> [CoreRule] -> InlinePragma mkStrWrapperInlinePrag (InlinePragma { inl_inline = fn_inl ===================================== compiler/GHC/Core/Ppr.hs ===================================== @@ -489,6 +489,9 @@ pprIdBndrInfo info has_inlineable = inlineableInfo info && isNoInlinePragma prag_info -- The flag is redundant -- unless we have NOINLINE. + spec_rec = specRecInfo info + has_spec_rec = isJust spec_rec || True + occ_info = occInfo info dmd_info = demandInfo info @@ -502,6 +505,7 @@ pprIdBndrInfo info doc = showAttributes [ (has_prag, text "InlPrag=" <> pprInlineDebug prag_info) , (has_inlineable, text "Inlineable") + , (has_spec_rec, text "SpecRec:" <> ppr spec_rec) , (has_occ, text "Occ=" <> ppr occ_info) , (has_dmd, text "Dmd=" <> ppr dmd_info) , (has_lbv , text "OS=" <> ppr lbv_info) @@ -512,6 +516,7 @@ instance Outputable IdInfo where [ (has_prag, text "InlPrag=" <> pprInlineDebug prag_info) -- Todo: This is only interesting for NoInline pragmas , (has_inlineable, text "Inlineable") + , (has_spec_rec, text "SpecRec:" <> ppr spec_rec) , (has_occ, text "Occ=" <> ppr occ_info) , (has_dmd, text "Dmd=" <> ppr dmd_info) , (has_lbv , text "OS=" <> ppr lbv_info) @@ -525,6 +530,9 @@ instance Outputable IdInfo where where prag_info = inlinePragInfo info has_prag = not (isDefaultInlinePragma prag_info) + spec_rec = specRecInfo info + has_spec_rec = isJust spec_rec || True + occ_info = occInfo info has_occ = not (isManyOccs occ_info) ===================================== compiler/GHC/CoreToIface.hs ===================================== @@ -84,7 +84,7 @@ import GHC.Utils.Panic import GHC.Utils.Panic.Plain import GHC.Utils.Misc -import Data.Maybe ( isNothing, catMaybes ) +import Data.Maybe {- Note [Avoiding space leaks in toIface*] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -463,7 +463,7 @@ toIfaceIdDetails other = pprTrace "toIfaceIdDetails" (ppr other) toIfaceIdInfo :: IdInfo -> IfaceIdInfo toIfaceIdInfo id_info = catMaybes [arity_hsinfo, caf_hsinfo, strict_hsinfo, cpr_hsinfo, - inline_hsinfo, has_inlineable_hsinfo, unfold_hsinfo] + inline_hsinfo, has_inlineable_hsinfo, unfold_hsinfo, spec_rec_hsinfo] -- NB: strictness and arity must appear in the list before unfolding -- See GHC.IfaceToCore.tcUnfolding where @@ -503,6 +503,10 @@ toIfaceIdInfo id_info | has_inlineable = Just HsInlineable | otherwise = Nothing + ------------ SpecRec flag ------------ + spec_rec_hsinfo = maybe Nothing (Just . HsSpecRec) (specRecInfo id_info) + + toIfaceJoinInfo :: Maybe JoinArity -> IfaceJoinInfo toIfaceJoinInfo (Just ar) = IfaceJoinPoint ar ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -175,6 +175,7 @@ import GHC.Core.Multiplicity import GHC.Core.Utils ( exprType ) import GHC.Core.ConLike import GHC.Core.Opt.Pipeline +import GHC.Core.Opt.SpecRec import GHC.Core.Opt.Pipeline.Types ( CoreToDo (..)) import GHC.Core.TyCon import GHC.Core.InstEnv @@ -2488,11 +2489,16 @@ hscTidy hsc_env guts = do let logger = hsc_logger hsc_env let this_mod = mg_module guts + (specrec_guts) <- withTiming logger + (text "CoreTidy"<+>brackets (ppr this_mod)) + (const ()) + $! {-# SCC "CoreTidy" #-} (return $ transferSpecRecs guts) + opts <- initTidyOpts hsc_env (cgguts, details) <- withTiming logger (text "CoreTidy"<+>brackets (ppr this_mod)) (const ()) - $! {-# SCC "CoreTidy" #-} tidyProgram opts guts + $! {-# SCC "CoreTidy" #-} tidyProgram opts specrec_guts -- post tidy pretty-printing and linting... let tidy_rules = md_rules details ===================================== compiler/GHC/HsToCore.hs ===================================== @@ -57,6 +57,7 @@ import GHC.Core.DataCon ( dataConWrapId ) import GHC.Core.Make import GHC.Core.Rules import GHC.Core.Opt.Pipeline.Types ( CoreToDo(..) ) +import GHC.Core.Opt.SpecRec import GHC.Core.Ppr import GHC.Builtin.Names @@ -254,7 +255,7 @@ deSugar hsc_env ; docs <- extractDocs dflags tcg_env - ; let mod_guts = ModGuts { + ; let mod_guts = transferSpecRecs ModGuts { mg_module = mod, mg_hsc_src = hsc_src, mg_loc = mkFileSrcSpan mod_loc, @@ -284,6 +285,7 @@ deSugar hsc_env mg_complete_matches = complete_matches, mg_docs = docs } + ; return (msgs, Just mod_guts) }}}} ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -993,6 +993,8 @@ rep_sig (L loc (ClassOpSig _ is_deflt nms ty)) | otherwise = mapM (rep_ty_sig sigDName (locA loc) ty) nms rep_sig (L loc (FixSig _ fix_sig)) = rep_fix_d (locA loc) fix_sig rep_sig (L loc (InlineSig _ nm ispec))= rep_inline nm ispec (locA loc) +rep_sig (L loc (SpecRecSig _ nm act)) + = rep_specrec nm act (locA loc) rep_sig (L loc (SpecSig _ nm tys ispec)) = concatMapM (\t -> rep_specialise nm t ispec (locA loc)) tys rep_sig (L loc (SpecInstSig _ ty)) = rep_specialiseInst ty (locA loc) @@ -1097,6 +1099,8 @@ rep_inline nm ispec loc ; return [(loc, pragma)] } +rep_specrec = error "TODO" + rep_specialise :: LocatedN Name -> LHsSigType GhcRn -> InlinePragma -> SrcSpan -> MetaM [(SrcSpan, Core (M TH.Dec))] ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -1718,6 +1718,11 @@ instance HiePass p => ToHie (SigContext (LocatedA (Sig (GhcPass p)))) where InlineSig _ name _ -> [ toHie $ (C Use) name ] + SpecRecSig _ name act -> + [ toHie $ (C Use) name + -- TODO: activation + -- , toHie $ act + ] SpecSig _ name typs _ -> [ toHie $ (C Use) name , toHie $ map (TS (ResolvedScopes [])) typs ===================================== compiler/GHC/Iface/Recomp.hs ===================================== @@ -1035,9 +1035,14 @@ addFingerprints hsc_env iface0 -- See Note [Identity versus semantic module] | semantic_mod /= this_mod , not (isHoleModule semantic_mod) = global_hash_fn name - | otherwise = return (snd (lookupOccEnv local_env (getOccName name) - `orElse` pprPanic "urk! lookup local fingerprint" - (ppr name $$ ppr local_env))) + | otherwise = do + let fp = lookupOccEnv local_env (getOccName name) `orElse` + (pprTrace "urk! lookup local fingerprint" + (ppr (nameModule name) $$ ppr name $$ ppr local_env) + -- TODO: ??? + (undefined, fingerprint0) + ) + return $ snd fp -- This panic indicates that we got the dependency -- analysis wrong, because we needed a fingerprint for -- an entity that wasn't in the environment. To debug ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -358,6 +358,7 @@ data IfaceInfoItem | HsUnfold Bool -- True <=> isStrongLoopBreaker is true IfaceUnfolding -- See Note [Expose recursive functions] | HsInlineable + | HsSpecRec Activation | HsNoCafRefs | HsLFInfo IfaceLFInfo | HsTagSig TagSig @@ -1517,6 +1518,7 @@ instance Outputable IfaceInfoItem where <> colon <+> ppr unf ppr (HsInline prag) = text "Inline:" <+> ppr prag ppr (HsInlineable) = text "HasInlineable:True" + ppr (HsSpecRec act) = text "SpecRec:" <> ppr act ppr (HsArity arity) = text "Arity:" <+> int arity ppr (HsDmdSig str) = text "Strictness:" <+> ppr str ppr (HsCprSig cpr) = text "CPR:" <+> ppr cpr @@ -2287,7 +2289,8 @@ instance Binary IfaceInfoItem where put_ bh (HsCprSig cpr) = putByte bh 6 >> put_ bh cpr put_ bh (HsLFInfo lf_info) = putByte bh 7 >> put_ bh lf_info put_ bh (HsTagSig sig) = putByte bh 8 >> put_ bh sig - put_ bh (HsInlineable) = putByte bh 9 + put_ bh (HsInlineable) = putByte bh 9 + put_ bh (HsSpecRec act) = putByte bh 10 >> put_ bh act get bh = do h <- getByte bh @@ -2303,6 +2306,7 @@ instance Binary IfaceInfoItem where 7 -> HsLFInfo <$> get bh 8 -> HsTagSig <$> get bh 9 -> pure HsInlineable + 10 -> HsSpecRec <$> get bh _ -> error "Binary:IfaceInfoItem - Invalid byte" instance Binary IfaceUnfolding where @@ -2713,6 +2717,7 @@ instance NFData IfaceInfoItem where HsLFInfo lf_info -> lf_info `seq` () -- TODO: seq further? HsTagSig sig -> sig `seq` () HsInlineable -> () + HsSpecRec act -> rnf act instance NFData IfGuidance where rnf = \case ===================================== compiler/GHC/Iface/Tidy.hs ===================================== @@ -384,6 +384,8 @@ tidyProgram opts (ModGuts { mg_module = mod (unfold_env, tidy_occ_env) <- chooseExternalIds opts mod all_binds imp_rules let (trimmed_binds, trimmed_rules) = findExternalRules opts all_binds imp_rules unfold_env + -- pprTraceM "trimmed_binds" (ppr $ bindersOfBinds trimmed_binds) + (tidy_env, tidy_binds) <- tidyTopBinds unfold_env boot_exports tidy_occ_env trimmed_binds -- See Note [Grand plan for static forms] in GHC.Iface.Tidy.StaticPtrTable. @@ -652,7 +654,9 @@ chooseExternalIds :: TidyOpts chooseExternalIds opts mod binds imp_id_rules = do { (unfold_env1,occ_env1) <- search init_work_list emptyVarEnv init_occ_env + -- ; pprTraceM "unfoldEnv" (ppr unfold_env1) ; let internal_ids = filter (not . (`elemVarEnv` unfold_env1)) binders + -- ; pprTraceM "internals" (ppr internal_ids) ; tidy_internal internal_ids unfold_env1 occ_env1 } where name_cache = opt_name_cache opts @@ -717,7 +721,9 @@ chooseExternalIds opts mod binds imp_id_rules search [] unfold_env occ_env = return (unfold_env, occ_env) search ((idocc,referrer) : rest) unfold_env occ_env - | idocc `elemVarEnv` unfold_env = search rest unfold_env occ_env + | idocc `elemVarEnv` unfold_env = + -- pprTrace "search.1" (ppr idocc <+> ppr referrer) $ + search rest unfold_env occ_env | otherwise = do (occ_env', name') <- tidyTopName mod name_cache (Just referrer) occ_env idocc let @@ -733,6 +739,11 @@ chooseExternalIds opts mod binds imp_id_rules referrer' | isExportedId refined_id = refined_id | otherwise = referrer -- + -- pprTraceM "search.2" + -- (ppr idocc <+> ppr referrer $$ + -- text "show:" <> ppr show_unfold $$ + -- text "name',external:" <> ppr (name', isExternalName name') + -- ) search (zip new_ids (repeat referrer') ++ rest) unfold_env' occ_env' tidy_internal :: [Id] -> UnfoldEnv -> TidyOccEnv @@ -762,6 +773,7 @@ addExternal opts id loop_breaker = isStrongLoopBreaker (occInfo idinfo) bottoming_fn = isDeadEndSig (dmdSigInfo idinfo) inlineable = inlineableInfo idinfo + spec_rec = specRecInfo idinfo -- Stuff to do with the Id's unfolding -- We leave the unfolding there even if there is a worker @@ -776,6 +788,7 @@ addExternal opts id -- source is an inline rule || inlineable + || isJust spec_rec || not dont_inline where @@ -1033,7 +1046,11 @@ findExternalRules opts binds imp_id_rules unfold_env where stuff@(binds', bndr_set, needed_fvs, rules) = trim_binds binds - needed bndr = isExportedId bndr || bndr `elemVarSet` needed_fvs + shows_unf bndr = case lookupVarEnv unfold_env bndr of + Just (name, show_unf) + | isExternalName name || show_unf -> True + _ -> False + needed bndr = isExportedId bndr || bndr `elemVarSet` needed_fvs || shows_unf bndr bndrs = bindersOf bind rhss = rhssOfBind bind @@ -1281,7 +1298,7 @@ tidyTopIdInfo rhs_tidy_env name rhs_ty orig_rhs tidy_rhs idinfo show_unfold Nothing -> False Just (arity, _, _) -> not (isDeadEndAppSig id_sig arity) - prag_info = mkPragInfo (inlinePragInfo idinfo) (inlineableInfo idinfo) + prag_info = mkPragInfo (inlinePragInfo idinfo) (inlineableInfo idinfo) (specRecInfo idinfo) --------- Unfolding ------------ -- Force unfold_info (hence bangs), otherwise the old unfolding -- is retained during code generation. See #22071 ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -1725,6 +1725,7 @@ tcIdInfo ignore_prags toplvl name ty info = do tcPrag info (HsCprSig cpr) = return (info `setCprSigInfo` cpr) tcPrag info (HsInline prag) = return (info `setInlinePragInfo` prag) tcPrag info (HsInlineable) = return (info `setHasInlineableInfo` True) + tcPrag info (HsSpecRec act) = return (info `setHasSpecRecInfo` (Just act)) tcPrag info (HsLFInfo lf_info) = do lf_info <- tcLFInfo lf_info return (info `setLFInfo` lf_info) ===================================== compiler/GHC/Rename/Bind.hs ===================================== @@ -1054,6 +1054,10 @@ renameSig ctxt sig@(InlineSig _ v s) = do { new_v <- lookupSigOccRnN ctxt sig v ; return (InlineSig noAnn new_v s, emptyFVs) } +renameSig ctxt sig@(SpecRecSig _ v s) + = do { new_v <- lookupSigOccRnN ctxt sig v + ; return (SpecRecSig noAnn new_v s, emptyFVs) } + renameSig ctxt (FixSig _ fsig) = do { new_fsig <- rnSrcFixityDecl ctxt fsig ; return (FixSig noAnn new_fsig, emptyFVs) } @@ -1138,6 +1142,10 @@ okHsSig ctxt (L _ sig) (InlineSig {}, HsBootCtxt {}) -> False (InlineSig {}, _) -> True + (SpecRecSig {}, HsBootCtxt {}) -> False + (SpecRecSig {}, LocalBindCtxt {}) -> False + (SpecRecSig {}, _) -> True + (SpecSig {}, TopSigCtxt {}) -> True (SpecSig {}, LocalBindCtxt {}) -> True (SpecSig {}, InstDeclCtxt {}) -> True @@ -1176,10 +1184,11 @@ findDupSigs sigs expand_sig :: Sig GhcPs -> [(LocatedN RdrName, Sig GhcPs)] -- AZ expand_sig sig@(FixSig _ (FixitySig _ ns _)) = zip ns (repeat sig) expand_sig sig@(InlineSig _ n _) = [(n,sig)] + expand_sig sig@(SpecRecSig _ n _) = [(n,sig)] expand_sig sig@(TypeSig _ ns _) = [(n,sig) | n <- ns] expand_sig sig@(ClassOpSig _ _ ns _) = [(n,sig) | n <- ns] expand_sig sig@(PatSynSig _ ns _ ) = [(n,sig) | n <- ns] - expand_sig sig@(SCCFunSig (_, _) n _) = [(n,sig)] + expand_sig sig@(SCCFunSig (_, _) n _) = [(n,sig)] expand_sig _ = [] matching_sig :: (LocatedN RdrName, Sig GhcPs) -> (LocatedN RdrName, Sig GhcPs) -> Bool --AZ @@ -1194,6 +1203,7 @@ findDupSigs sigs mtch (ClassOpSig _ d1 _ _) (ClassOpSig _ d2 _ _) = d1 == d2 mtch (PatSynSig _ _ _) (PatSynSig _ _ _) = True mtch (SCCFunSig{}) (SCCFunSig{}) = True + mtch (SpecRecSig{}) (SpecRecSig{}) = True mtch _ _ = False -- Warn about multiple MINIMAL signatures ===================================== compiler/GHC/Tc/Gen/Bind.hs ===================================== @@ -637,6 +637,7 @@ tcPolyCheck prag_fn poly_id2 = mkLocalId mono_name (idMult poly_id) (idType poly_id) ; spec_prags <- tcSpecPrags poly_id prag_sigs ; poly_id <- addInlinePrags poly_id prag_sigs + ; poly_id <- addSpecRecPrags poly_id prag_sigs ; mod <- getModule ; tick <- funBindTicks (locA nm_loc) poly_id mod prag_sigs @@ -832,6 +833,7 @@ mkExport prag_fn residual insoluble qtvs theta -- NB: poly_id has a zonked type ; poly_id <- addInlinePrags poly_id prag_sigs + ; poly_id <- addSpecRecPrags poly_id prag_sigs ; spec_prags <- tcSpecPrags poly_id prag_sigs -- tcPrags requires a zonked poly_id @@ -1514,7 +1516,10 @@ tcLhsSigId no_gen (name, sig) newSigLetBndr :: LetBndrSpec -> Name -> TcIdSigInst -> TcM TcId newSigLetBndr (LetGblBndr prags) name (TISI { sig_inst_sig = id_sig }) | CompleteSig { sig_bndr = poly_id } <- id_sig - = addInlinePrags poly_id (lookupPragEnv prags name) + = do + poly_id <- addInlinePrags poly_id (lookupPragEnv prags name) + poly_id <- addSpecRecPrags poly_id (lookupPragEnv prags name) + return poly_id newSigLetBndr no_gen name (TISI { sig_inst_tau = tau }) = newLetBndr no_gen name ManyTy tau -- Binders with a signature are currently always of multiplicity ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -32,7 +32,7 @@ import GHC.Hs.Syn.Type import GHC.Rename.Utils import GHC.Tc.Errors.Types import GHC.Tc.Utils.Zonk -import GHC.Tc.Gen.Sig( TcPragEnv, lookupPragEnv, addInlinePrags ) +import GHC.Tc.Gen.Sig import GHC.Tc.Utils.Monad import GHC.Tc.Utils.Instantiate import GHC.Types.FieldLabel @@ -265,7 +265,11 @@ newLetBndr LetLclBndr name w ty = do { mono_name <- cloneLocalName name ; return (mkLocalId mono_name w ty) } newLetBndr (LetGblBndr prags) name w ty - = addInlinePrags (mkLocalId name w ty) (lookupPragEnv prags name) + = do { let prags' = (lookupPragEnv prags name) + ; bndr <- addInlinePrags (mkLocalId name w ty) prags' + ; bndr <- addSpecRecPrags bndr prags' + ; return bndr + } tc_sub_type :: PatEnv -> ExpSigmaType -> TcSigmaType -> TcM HsWrapper -- tcSubTypeET with the UserTypeCtxt specialised to GenSigCtxt ===================================== compiler/GHC/Tc/Gen/Sig.hs ===================================== @@ -22,7 +22,7 @@ module GHC.Tc.Gen.Sig( TcPragEnv, emptyPragEnv, lookupPragEnv, extendPragEnv, mkPragEnv, tcSpecPrags, tcSpecWrapper, tcImpPrags, - addInlinePrags, addInlinePragArity + addInlinePrags, addInlinePragArity, addSpecRecPrags ) where import GHC.Prelude @@ -56,8 +56,7 @@ import GHC.Core.TyCo.Rep( mkNakedFunTy ) import GHC.Types.Error import GHC.Types.Var ( TyVar, Specificity(..), tyVarKind, binderVars, invisArgTypeLike ) -import GHC.Types.Id ( Id, idName, idType, setIdPragmaInfo - , mkLocalId, realIdUnfolding ) +import GHC.Types.Id import GHC.Types.Id.Info import GHC.Types.Basic import GHC.Types.Name @@ -592,6 +591,7 @@ mkPragEnv sigs binds get_sig sig@(L _ (SpecSig _ (L _ nm) _ _)) = Just (nm, add_arity nm sig) get_sig sig@(L _ (InlineSig _ (L _ nm) _)) = Just (nm, add_arity nm sig) get_sig sig@(L _ (SCCFunSig _ (L _ nm) _)) = Just (nm, sig) + get_sig sig@(L _ (SpecRecSig _ (L _ nm) _)) = Just (nm, sig) get_sig _ = Nothing add_arity n sig -- Adjust inl_sat field to match visible arity of function @@ -633,7 +633,7 @@ computePragmaInfo info (prag:prags) -- INLINEABLE + NOINLINE | NoInline{} <- new_spec , isDefaultActivationPragma old_prag - -> computePragmaInfo (mkPragInfo prag True) prags + -> computePragmaInfo (mkPragInfo prag True spec_rec) prags | otherwise -> Nothing NoInline{} -- NOINLINE + INLINEABLE @@ -645,12 +645,13 @@ computePragmaInfo info (prag:prags) Opaque{} -> Nothing NoUserInlinePrag -> computePragmaInfo - (mkPragInfo prag (isInlinablePragma prag)) + (mkPragInfo prag (isInlinablePragma prag) spec_rec) prags where old_prag = pragInfoInline $ info old_spec = inl_inline old_prag new_spec = inl_inline prag + spec_rec = pragSpecRec info @@ -659,7 +660,7 @@ addInlinePrags :: TcId -> [LSig GhcRn] -> TcM TcId addInlinePrags poly_id prags_for_me | inl@(L _ inl_prag) : inls <- inl_prags = do { traceTc "addInlinePrag" (ppr poly_id $$ ppr inl_prag) - ; let init_info = (mkPragInfo inl_prag $ isInlinablePragma inl_prag) + ; let init_info = mkPragInfo inl_prag (isInlinablePragma inl_prag) (idSpecRec poly_id) m_prag_info = computePragmaInfo init_info (map unLoc inls) @@ -687,6 +688,15 @@ addInlinePrags poly_id prags_for_me let dia = TcRnMultipleInlinePragmas poly_id inl1 (inl2 NE.:| inls) in addDiagnosticTc dia +----------------- +addSpecRecPrags :: TcId -> [LSig GhcRn] -> TcM TcId +addSpecRecPrags poly_id prags_for_me + = case spec_rec of + [] -> return poly_id + [L _ act] -> return $ setHasSpecRec poly_id (Just act) + (_:_) -> error "TODO: Duplicate SpecRec" + where + spec_rec = [L loc act | L loc (SpecRecSig _ _ act) <- prags_for_me] {- Note [Pattern synonym inline arity] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -829,7 +839,7 @@ tcSpecPrags poly_id prag_sigs where spec_sigs = filter isSpecLSig prag_sigs bad_sigs = filter is_bad_sig prag_sigs - is_bad_sig s = not (isSpecLSig s || isInlineLSig s || isSCCFunSig s) + is_bad_sig s = not (isSpecLSig s || isSpecRecLSig s || isInlineLSig s || isSCCFunSig s) warn_discarded_sigs bad_sigs_ne = let dia = TcRnUnexpectedPragmas poly_id bad_sigs_ne ===================================== compiler/GHC/Tc/TyCl/Class.hs ===================================== @@ -253,6 +253,7 @@ tcDefMeth clas tyvars this_dict binds_in hs_sig_fn prag_fn global_dm_id <- tcLookupId dm_name ; global_dm_id <- addInlinePrags global_dm_id prags + ; global_dm_id <- addSpecRecPrags global_dm_id prags ; local_dm_name <- newNameAt (getOccName sel_name) bndr_loc -- Base the local_dm_name on the selector name, because -- type errors from tcInstanceMethodBody come from here ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -1900,6 +1900,7 @@ tcMethodBody clas tyvars dfun_ev_vars inst_tys tcMethodBodyHelp sig_fn sel_id local_meth_id (L bind_loc lm_bind) ; global_meth_id <- addInlinePrags global_meth_id prags + ; global_meth_id <- addSpecRecPrags global_meth_id prags ; spec_prags <- tcSpecPrags global_meth_id prags ; let specs = mk_meth_spec_prags global_meth_id spec_inst_prags spec_prags @@ -2113,7 +2114,11 @@ mkDefMethBind loc dfun_id clas sel_id dm_name = [] -- Copy the inline pragma (if any) from the default method -- to this version. Note [INLINE and default methods] - + spec_rec = idSpecRec dm_id + spec_rec_prag | Just act <- spec_rec + = [noLocA (SpecRecSig noAnn fn act)] + | otherwise + = [] fn = noLocA (idName sel_id) visible_inst_tys = [ ty | (tcb, ty) <- tyConBinders (classTyCon clas) `zip` inst_tys , tyConBinderForAllTyFlag tcb /= Inferred ] @@ -2127,7 +2132,7 @@ mkDefMethBind loc dfun_id clas sel_id dm_name (vcat [ppr clas <+> ppr inst_tys, nest 2 (ppr sel_id <+> equals <+> ppr rhs)])) - ; return (bind, inline_prags) } + ; return (bind, spec_rec_prag ++ inline_prags) } where (_, _, _, inst_tys) = tcSplitDFunTy (idType dfun_id) ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -26,8 +26,7 @@ import GHC.Tc.Utils.TcMType import GHC.Tc.Utils.Zonk import GHC.Tc.Errors.Types import GHC.Tc.Utils.Monad -import GHC.Tc.Gen.Sig ( TcPragEnv, emptyPragEnv, completeSigFromId, lookupPragEnv - , addInlinePrags, addInlinePragArity ) +import GHC.Tc.Gen.Sig import GHC.Tc.Solver import GHC.Tc.Utils.Unify import GHC.Tc.Utils.TcType @@ -851,9 +850,11 @@ tcPatSynMatcher (L loc ps_name) lpat prag_fn -- Add INLINE pragmas; see Note [Pragmas for pattern synonyms] -- NB: prag_fn is keyed by the PatSyn Name, not the (internal) matcher name - ; matcher_prag_id <- addInlinePrags matcher_id $ - map (addInlinePragArity matcher_arity) $ - lookupPragEnv prag_fn ps_name + ; let prags = map (addInlinePragArity matcher_arity) $ + lookupPragEnv prag_fn ps_name + + ; matcher_prag_id <- addInlinePrags matcher_id prags + ; matcher_prag_id <- addSpecRecPrags matcher_prag_id prags ; let bind = FunBind{ fun_id = L loc matcher_prag_id , fun_matches = mg @@ -949,9 +950,11 @@ tcPatSynBuilderBind prag_fn (PSB { psb_id = ps_lname@(L loc ps_name) -- Add INLINE pragmas; see Note [Pragmas for pattern synonyms] -- NB: prag_fn is keyed by the PatSyn Name, not the (internal) builder name - ; builder_id <- addInlinePrags builder_id $ - map (addInlinePragArity builder_arity) $ - lookupPragEnv prag_fn ps_name + ; let prags = map (addInlinePragArity builder_arity) $ + lookupPragEnv prag_fn ps_name + ; builder_id <- addInlinePrags builder_id prags + ; builder_id <- addSpecRecPrags builder_id prags + ; let match_group' | need_dummy_arg = add_dummy_arg match_group | otherwise = match_group ===================================== compiler/GHC/Types/Basic.hs ===================================== @@ -1711,6 +1711,15 @@ instance Binary Activation where ab <- get bh return (ActiveAfter src ab) +instance NFData Activation where + rnf act = case act of + AlwaysActive -> () + NeverActive -> () + ActiveBefore src phase -> src `deepseq` phase `deepseq` () + ActiveAfter src phase -> src `deepseq` phase `deepseq` () + FinalActive -> () + + instance Outputable RuleMatchInfo where ppr ConLike = text "CONLIKE" ppr FunLike = text "FUNLIKE" ===================================== compiler/GHC/Types/Id.hs ===================================== @@ -83,7 +83,8 @@ module GHC.Types.Id ( -- ** Inline pragma stuff idPragmaInfo, idInlinePragma, idHasInlineable, setInlinePragma, - setIdPragmaInfo, modifyInlinePragma, setHasInlineable, + idHasSpecRec, idSpecRec, + setIdPragmaInfo, modifyInlinePragma, setHasInlineable, setHasSpecRec, idInlineActivation, setInlineActivation, idRuleMatchInfo, -- ** One-shot lambdas @@ -176,6 +177,7 @@ infixl 1 `setIdUnfolding`, `setIdSpecialisation`, `setInlinePragma`, `setHasInlineable`, + `setHasSpecRec`, `setIdPragmaInfo`, `setInlineActivation`, `idCafInfo`, @@ -899,6 +901,12 @@ idInlinePragma id = inlinePragInfo (idInfo id) idHasInlineable :: Id -> Bool idHasInlineable id = inlineableInfo (idInfo id) +idHasSpecRec :: Id -> Bool +idHasSpecRec id = isJust $ specRecInfo (idInfo id) + +idSpecRec :: Id -> Maybe Activation +idSpecRec id = specRecInfo (idInfo id) + idPragmaInfo :: Id -> PragInfo idPragmaInfo id = pragInfo (idInfo id) @@ -908,6 +916,9 @@ setInlinePragma id prag = modifyIdInfo (`setInlinePragInfo` prag) id setHasInlineable :: Id -> Bool -> Id setHasInlineable id inlineable = modifyIdInfo (`setHasInlineableInfo` inlineable) id +setHasSpecRec :: Id -> (Maybe Activation) -> Id +setHasSpecRec id spec_rec = modifyIdInfo (`setHasSpecRecInfo` spec_rec) id + setIdPragmaInfo :: Id -> PragInfo -> Id setIdPragmaInfo id pragInfo = modifyIdInfo (`setPragInfo` pragInfo) id @@ -1053,6 +1064,7 @@ transferPolyIdInfo old_id abstract_wrt new_id old_arity = arityInfo old_info old_inline_prag = inlinePragInfo old_info old_unf_info = inlineableInfo old_info + old_spec_rec = specRecInfo old_info old_occ_info = occInfo old_info new_arity = old_arity + arity_increase new_occ_info = zapOccTailCallInfo old_occ_info @@ -1077,6 +1089,7 @@ transferPolyIdInfo old_id abstract_wrt new_id transfer new_info = new_info `setArityInfo` new_arity `setInlinePragInfo` old_inline_prag `setHasInlineableInfo` old_unf_info + `setHasSpecRecInfo` old_spec_rec `setOccInfo` new_occ_info `setDmdSigInfo` new_strictness `setCprSigInfo` new_cpr ===================================== compiler/GHC/Types/Id/Info.hs ===================================== @@ -49,10 +49,11 @@ module GHC.Types.Id.Info ( -- ** Unfolding Info realUnfoldingInfo, unfoldingInfo, setUnfoldingInfo, hasInlineUnfolding, inlinePragInfo, setInlinePragInfo, inlineableInfo, setHasInlineableInfo, + specRecInfo, setHasSpecRecInfo, -- ** The PragInfo type setPragInfo, pragInfo, PragInfo, mkPragInfo, - pragInfoInline, pragHasInlineable, + pragInfoInline, pragHasInlineable, pragSpecRec, setPragInfoInline, -- ** The OccInfo type @@ -117,6 +118,7 @@ infixl 1 `setRuleInfo`, `setArityInfo`, `setInlinePragInfo`, `setHasInlineableInfo`, + `setHasSpecRecInfo`, `setUnfoldingInfo`, `setOneShotInfo`, `setOccInfo`, @@ -439,6 +441,9 @@ inlinePragInfo = pragInfoInline . pragInfo inlineableInfo :: IdInfo -> Bool inlineableInfo = pragHasInlineable . pragInfo +specRecInfo :: IdInfo -> (Maybe Activation) +specRecInfo = pragSpecRec . pragInfo + -- | Info about a lambda-bound variable, if the 'Id' is one oneShotInfo :: IdInfo -> OneShotInfo oneShotInfo = bitfieldGetOneShotInfo . bitfield @@ -474,6 +479,9 @@ setInlinePragInfo :: IdInfo -> InlinePragma -> IdInfo setInlinePragInfo info pr = pr `seq` info { pragInfo = setPragInfoInline pr (pragInfo info) } setHasInlineableInfo :: IdInfo -> Bool -> IdInfo setHasInlineableInfo info pr = pr `seq` info { pragInfo = setPragInfoUnf pr (pragInfo info) } +setHasSpecRecInfo :: IdInfo -> (Maybe Activation) -> IdInfo +setHasSpecRecInfo info pr = pr `seq` info { pragInfo = setPragInfoSpecRec pr (pragInfo info) } + -- Try to avoid space leaks by seq'ing -- | Essentially returns the 'realUnfoldingInfo' field, but does not expose the @@ -641,18 +649,21 @@ ppArityInfo n = hsep [text "Arity", int n] -- entirely as a way to inhibit inlining until we want it data PragInfo = PragInfo { -- | INLINE etc info - pragInfoInline :: !InlinePragma + pragInfoInline :: InlinePragma , -- | Should we keep the unfolding? - pragHasInlineable :: !Bool + pragHasInlineable :: Bool + , -- | Allow specialisation transitively? + pragSpecRec :: (Maybe Activation) } deriving Eq instance Outputable PragInfo where ppr prag = text "PragInfo=" <> braces (ppr (pragInfoInline prag) <> comma <> - text "HasInlineable:" <> ppr (pragHasInlineable prag)) + text "HasInlineable:" <> ppr (pragHasInlineable prag) <> comma <> + text "SpecRec:" <> ppr (pragSpecRec prag)) --- | mkPragInfo inl_prag has_inlineable -mkPragInfo :: InlinePragma -> Bool -> PragInfo +-- | mkPragInfo inl_prag has_inlineable spec_rec +mkPragInfo :: InlinePragma -> Bool -> (Maybe Activation) -> PragInfo mkPragInfo = PragInfo setPragInfoInline :: InlinePragma -> PragInfo -> PragInfo @@ -661,14 +672,21 @@ setPragInfoInline inl prag_info = prag_info { pragInfoInline = inl } setPragInfoUnf :: Bool -> PragInfo -> PragInfo setPragInfoUnf keep prag_info = prag_info { pragHasInlineable = keep } +setPragInfoSpecRec :: (Maybe Activation) -> PragInfo -> PragInfo +setPragInfoSpecRec spec_rec prag_info = prag_info { pragSpecRec = spec_rec } + defaultPragInfo :: PragInfo defaultPragInfo = PragInfo { pragInfoInline = defaultInlinePragma - , pragHasInlineable = defaultHasInlineableInfo } + , pragHasInlineable = defaultHasInlineableInfo + , pragSpecRec = defaultSpecRecInfo } defaultHasInlineableInfo :: Bool defaultHasInlineableInfo = False +defaultSpecRecInfo :: Maybe Activation +defaultSpecRecInfo = Nothing + {- ************************************************************************ * * ===================================== compiler/GHC/Types/SourceText.hs ===================================== @@ -39,6 +39,8 @@ import Data.Data import GHC.Real ( Ratio(..) ) import GHC.Types.SrcLoc +import Control.DeepSeq + {- Note [Pragma source text] ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -121,6 +123,10 @@ instance Binary SourceText where return (SourceText s) _ -> panic $ "Binary SourceText:" ++ show h +instance NFData SourceText where + rnf NoSourceText = () + rnf (SourceText s) = rnf s + -- | Special combinator for showing string literals. pprWithSourceText :: SourceText -> SDoc -> SDoc pprWithSourceText NoSourceText d = d ===================================== compiler/Language/Haskell/Syntax/Binds.hs ===================================== @@ -36,7 +36,7 @@ import GHC.Data.Bag (Bag) import GHC.Types.Basic (InlinePragma, Activation) import GHC.Data.BooleanFormula (LBooleanFormula) -import GHC.Types.SourceText (StringLiteral, SourceText) +import GHC.Types.SourceText (StringLiteral) import Data.Void import Data.Bool @@ -482,6 +482,10 @@ isSpecLSig :: forall p. UnXRec p => LSig p -> Bool isSpecLSig (unXRec @p -> SpecSig {}) = True isSpecLSig _ = False +isSpecRecLSig :: forall p. UnXRec p => LSig p -> Bool +isSpecRecLSig (unXRec @p -> SpecRecSig {}) = True +isSpecRecLSig _ = False + isSpecInstLSig :: forall p. UnXRec p => LSig p -> Bool isSpecInstLSig (unXRec @p -> SpecInstSig {}) = True isSpecInstLSig _ = False @@ -491,6 +495,7 @@ isPragLSig :: forall p. UnXRec p => LSig p -> Bool isPragLSig (unXRec @p -> SpecSig {}) = True isPragLSig (unXRec @p -> InlineSig {}) = True isPragLSig (unXRec @p -> SCCFunSig {}) = True +isPragLSig (unXRec @p -> SpecRecSig {}) = True isPragLSig (unXRec @p -> CompleteMatchSig {}) = True isPragLSig _ = False ===================================== compiler/ghc.cabal.in ===================================== @@ -330,6 +330,7 @@ Library GHC.Core.Opt.Simplify.Utils GHC.Core.Opt.SpecConstr GHC.Core.Opt.Specialise + GHC.Core.Opt.SpecRec GHC.Core.Opt.StaticArgs GHC.Core.Opt.Stats GHC.Core.Opt.WorkWrap View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1c93cdb6a09ac0c0fd711754da0b7780dda4f65b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1c93cdb6a09ac0c0fd711754da0b7780dda4f65b You're receiving 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 Jan 6 10:39:22 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 06 Jan 2023 05:39:22 -0500 Subject: [Git][ghc/ghc][wip/andreask/spec-transitive] First PoC partially done Message-ID: <63b7fa5a79546_f192a24acf41c4724ef@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/spec-transitive at Glasgow Haskell Compiler / GHC Commits: 0366194b by Andreas Klebinger at 2023-01-06T11:37:58+01:00 First PoC partially done - - - - - 29 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - + compiler/GHC/Core/Opt/SpecRec.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Id.hs - compiler/GHC/Types/Id/Info.hs - compiler/GHC/Types/SourceText.hs - compiler/Language/Haskell/Syntax/Binds.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -60,7 +60,7 @@ module GHC.Core ( -- ** Predicates and deconstruction on 'Unfolding' unfoldingTemplate, expandUnfolding_maybe, - maybeUnfoldingTemplate, otherCons, + maybeUnfoldingTemplate, maybeUnfoldingSource, otherCons, isValueUnfolding, isEvaldUnfolding, isCheapUnfolding, isExpandableUnfolding, isConLikeUnfolding, isCompulsoryUnfolding, isStableUnfolding, isStableUserUnfolding, isStableSystemUnfolding, @@ -1454,6 +1454,11 @@ maybeUnfoldingTemplate (DFunUnfolding { df_bndrs = bndrs, df_con = con, df_args maybeUnfoldingTemplate _ = Nothing +maybeUnfoldingSource :: Unfolding -> Maybe UnfoldingSource +maybeUnfoldingSource (CoreUnfolding { uf_src = src }) + = Just src +maybeUnfoldingSource _ = Nothing + -- | The constructors that the unfolding could never be: -- returns @[]@ if no information is available otherCons :: Unfolding -> [AltCon] ===================================== compiler/GHC/Core/FVs.hs ===================================== @@ -31,10 +31,11 @@ module GHC.Core.FVs ( bndrRuleAndUnfoldingIds, idFVs, idRuleVars, stableUnfoldingVars, - ruleFreeVars, rulesFreeVars, + ruleFreeVars, rulesFreeVars, rulesSomeFreeVars, rulesSomeFreeVarsList, rulesFreeVarsDSet, mkRuleInfo, ruleLhsFreeIds, ruleLhsFreeIdsList, ruleRhsFreeVars, rulesRhsFreeIds, + rulesRhsSomeFVs, ruleRhsSomeFreeVars, exprFVs, @@ -466,34 +467,47 @@ data RuleFVsFrom -- | Those locally-defined variables free in the left and/or right hand sides -- of the rule, depending on the first argument. Returns an 'FV' computation. ruleFVs :: RuleFVsFrom -> CoreRule -> FV -ruleFVs !_ (BuiltinRule {}) = emptyFV -ruleFVs from (Rule { ru_fn = _do_not_include +ruleFVs = ruleSomeFVs isLocalVar + +ruleSomeFVs :: InterestingVarFun -> RuleFVsFrom -> CoreRule -> FV +ruleSomeFVs _fv_cand !_ (BuiltinRule {}) = emptyFV +ruleSomeFVs fv_cand from (Rule { ru_fn = _do_not_include -- See Note [Rule free var hack] , ru_bndrs = bndrs , ru_rhs = rhs, ru_args = args }) - = filterFV isLocalVar $ addBndrs bndrs (exprs_fvs exprs) + = filterFV fv_cand $ addBndrs bndrs (exprs_fvs exprs) where exprs = case from of LhsOnly -> args RhsOnly -> [rhs] BothSides -> rhs:args - -- | Those locally-defined variables free in the left and/or right hand sides -- from several rules, depending on the first argument. -- Returns an 'FV' computation. rulesFVs :: RuleFVsFrom -> [CoreRule] -> FV rulesFVs from = mapUnionFV (ruleFVs from) +rulesSomeFVs :: InterestingVarFun -> RuleFVsFrom -> [CoreRule] -> FV +rulesSomeFVs fv_cand from = mapUnionFV (ruleSomeFVs fv_cand from) + -- | Those variables free in the right hand side of a rule returned as a -- non-deterministic set ruleRhsFreeVars :: CoreRule -> VarSet ruleRhsFreeVars = fvVarSet . ruleFVs RhsOnly +-- | Those variables free in the right hand side of a rule returned as a +-- non-deterministic set +ruleRhsSomeFreeVars :: InterestingVarFun -> CoreRule -> VarSet +ruleRhsSomeFreeVars fv_cand = fvVarSet . ruleSomeFVs fv_cand RhsOnly + -- | Those locally-defined free 'Id's in the right hand side of several rules -- returned as a non-deterministic set rulesRhsFreeIds :: [CoreRule] -> VarSet rulesRhsFreeIds = fvVarSet . filterFV isLocalId . rulesFVs RhsOnly +rulesRhsSomeFVs :: InterestingVarFun -> [CoreRule] -> VarSet +rulesRhsSomeFVs fv_cand = fvVarSet . rulesSomeFVs fv_cand RhsOnly + ruleLhsFreeIds :: CoreRule -> VarSet -- ^ This finds all locally-defined free Ids on the left hand side of a rule -- and returns them as a non-deterministic set @@ -518,6 +532,12 @@ rulesFreeVarsDSet rules = fvDVarSet $ rulesFVs BothSides rules rulesFreeVars :: [CoreRule] -> VarSet rulesFreeVars rules = fvVarSet $ rulesFVs BothSides rules +rulesSomeFreeVars :: InterestingVarFun -> [CoreRule] -> VarSet +rulesSomeFreeVars fv_cand rules = fvVarSet $ rulesSomeFVs fv_cand BothSides rules + +rulesSomeFreeVarsList :: InterestingVarFun -> [CoreRule] -> [Var] +rulesSomeFreeVarsList fv_cand rules = fvVarList $ rulesSomeFVs fv_cand BothSides rules + -- | Make a 'RuleInfo' containing a number of 'CoreRule's, suitable -- for putting into an 'IdInfo' mkRuleInfo :: [CoreRule] -> RuleInfo ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -677,6 +677,7 @@ mkCastWrapperPragInfo prag_info , inl_rule = rule_info } -- in GHC.Core.Opt.WorkWrap -- RuleMatchInfo is (and must be) unaffected (pragHasInlineable prag_info) + (pragSpecRec prag_info) where -- See Note [Wrapper activation] in GHC.Core.Opt.WorkWrap -- But simpler, because we don't need to disable during InitialPhase ===================================== compiler/GHC/Core/Opt/SpecRec.hs ===================================== @@ -0,0 +1,211 @@ +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE TupleSections #-} + +-- | Transfer specrec pragmas from functions having such a pragma +-- to functions calling such functions. +module GHC.Core.Opt.SpecRec + ( transferSpecRecs + ) where + +import GHC.Prelude + + +import GHC.Types.Basic +import GHC.Driver.Session +import GHC.Types.Name hiding (varName) +import GHC.Types.Id +import GHC.Unit.Module.ModGuts +import GHC.Types.Var.Set +import GHC.Types.Name.Env +import GHC.Unit.Types +import GHC.Core +import GHC.Core.Rules +import GHC.Core.FVs +import GHC.Utils.Outputable + +import Data.Graph +import GHC.Utils.Monad.State.Strict +import Control.Monad +import Data.Maybe +{- +-- We need to transfer the pragma in these cases: + +{-# SPECREC foo #-} +foo = ... + +We transfer the pragma if foo is mentioned in: +* The RHS of a function +* The unfolding. -- TODO: Not needed after desugar? +-- TODO: Rules + +-} + +transferSpecRecs :: ModGuts -> ModGuts +-- transferSpecRecs _dflags guts = guts +transferSpecRecs guts = + let env :: Env + env = Env + { thisModule = mg_module guts + , orphanRules = mkRuleBase (mg_rules guts) + } + in guts { mg_binds = doCoreProgram env (mg_binds guts) + } + +-- bind_fvs (NonRec _ rhs) = +doCoreProgram :: Env -> CoreProgram -> CoreProgram +doCoreProgram env binds = flip evalState (SS mempty mempty) $ do + -- pprTraceM "binds_in" $ vcat $ map ppr binds + let sorted_binds = depAnal (map getName . bindersOf) bind_deps binds + -- pprTraceM "binds_sorted" $ vcat $ map (ppr . bindersOf) sorted_binds + done_binds <- doSccs env sorted_binds + -- pprTraceM "binds_out" $ vcat $ map (ppr . bindersOf) done_binds + return done_binds + where + bind_deps bind = + let bs = bindersOf bind + rhss = rhssOfBind bind + rhss_fvs = exprsSomeFreeVarsList (const True) rhss + unfs = map realIdUnfolding bs + unf_rhs = catMaybes . map maybeUnfoldingTemplate $ unfs + unf_fvs = exprsSomeFreeVarsList (const True) unf_rhs + id_rules = concatMap idCoreRules bs + id_rules_fvs = rulesSomeFreeVarsList (const True) id_rules + in map getName $ unf_fvs ++ id_rules_fvs ++ unf_fvs ++ rhss_fvs + +mcons :: Monad m => a -> m [a] -> m [a] +mcons x xs = liftM (x:) xs + +doSccs :: Env -> [SCC CoreBind] -> M [CoreBind] +doSccs env binds = do + bindss <- mapM (doScc env) binds + pure $ concat bindss + +doScc :: Env -> SCC CoreBind -> M [CoreBind] +doScc env (AcyclicSCC bind) = do + (b,is_spec) <- doBind env bind + when is_spec $ addSpecBinders $ bindersOf b + pure [b] +doScc env (CyclicSCC binds) = do + -- A bunch of binders which might refer to each other in a cyclic fashion via + -- something like rules. So we must put specrec on all of them. + (bs,is_specs) <- unzip <$> mapM (doBind env) binds + when (or is_specs) $ addSpecBinders $ bindersOfBinds bs + pure $ map setSpec bs + +addSpecBinders :: [Id] -> M () +addSpecBinders ids = do + mapM_ addSpec ids + mapM_ addDone ids + return () + +doBind :: Env -> CoreBind -> M (CoreBind, Bool) +doBind env bind = do + to_spec <- spec_set <$> get + let bs = bindersOf bind + rhss = rhssOfBind bind + spec_id = any idHasSpecRec bs + spec_rhs = any (is_spec_expr to_spec) rhss + spec_unf = any (is_spec_unf to_spec . realIdUnfolding) bs + spec_rules = any (is_spec_rules to_spec . idCoreRules) bs + + if spec_id || spec_rhs || spec_unf || spec_rules + -- If the rhs, unfolding or a rule rhs mentions a spec-rec function + -- we must make the function itself spec-rec + then pure (setSpec bind, True) + -- Otherwise another binding might still become spec-rec in the future + else pure (bind, False) + + where + is_spec_rules spec_set rules = + let fvs = rulesRhsSomeFVs (\v -> isId v && idHasSpecRec v || elemVarSet v spec_set) rules + in not (isEmptyVarSet fvs) + + is_spec_expr :: VarSet -> CoreExpr -> Bool + is_spec_expr spec_set expr = + let fvs = exprSomeFreeVars (\v -> isId v && idHasSpecRec v || elemVarSet v spec_set) expr + in not (isEmptyVarSet fvs) + + is_spec_unf :: VarSet -> Unfolding -> Bool + is_spec_unf spec_set unf = do + case maybeUnfoldingSource unf of + -- We already look at the rhs and the unf is the same + Just VanillaSrc -> False + _ -> case maybeUnfoldingTemplate unf of + Just unf_tmpl -> do + is_spec_expr spec_set unf_tmpl + Nothing -> False + + -- TODO: Properly set activation + +setSpec :: Bind Id -> Bind Id +setSpec (NonRec b rhs) = NonRec (setHasSpecRec b (Just AlwaysActive)) rhs +setSpec (Rec pairs) = Rec $ map (\(b,rhs) -> (setHasSpecRec b (Just AlwaysActive), rhs)) pairs + + +-- doBind :: Env -> CoreBind -> M CoreBind +-- doBind env (NonRec b rhs) = NonRec b <$> doExpr (addParent b env) rhs +-- doBind env (Rec bs) = Rec <$> mapM doPair bs +-- where +-- doPair (b,rhs) = (b,) <$> doExpr (addParent b env) rhs + +-- doExpr :: Env -> CoreExpr -> M CoreExpr +-- doExpr env e@(Var v) +-- | needsCallSiteCostCentre env v = do +-- let nameDoc :: SDoc +-- nameDoc = withUserStyle alwaysQualify DefaultDepth $ +-- hcat (punctuate dot (map ppr (parents env))) <> parens (text "calling:" <> ppr v) + +-- ccName :: CcName +-- ccName = mkFastString $ renderWithContext defaultSDocContext nameDoc +-- ccIdx <- getCCIndex' ccName +-- let count = countEntries env +-- span = case revParents env of +-- top:_ -> nameSrcSpan $ varName top +-- _ -> noSrcSpan +-- cc = NormalCC (ExprCC ccIdx) ccName (thisModule env) span +-- tick :: CoreTickish +-- tick = ProfNote cc count True +-- pure $ Tick tick e +-- | otherwise = pure e +-- doExpr _env e@(Lit _) = pure e +-- doExpr env (f `App` x) = App <$> doExpr env f <*> doExpr env x +-- doExpr env (Lam b x) = Lam b <$> doExpr env x +-- doExpr env (Let b rhs) = Let <$> doBind env b <*> doExpr env rhs +-- doExpr env (Case scrut b ty alts) = +-- Case <$> doExpr env scrut <*> pure b <*> pure ty <*> mapM doAlt alts +-- where +-- doAlt (Alt con bs rhs) = Alt con bs <$> doExpr env rhs +-- doExpr env (Cast expr co) = Cast <$> doExpr env expr <*> pure co +-- doExpr env (Tick t e) = Tick t <$> doExpr env e +-- doExpr _env e@(Type _) = pure e +-- doExpr _env e@(Coercion _) = pure e + +data SpecState = SS + { spec_set :: !VarSet + , spec_done :: !VarSet + } + +type M = State SpecState + +addSpec :: Var -> M () +addSpec v = do + s <- get + put $! s { spec_set = extendVarSet (spec_set s) v } + +addDone :: Var -> M () +addDone v = do + s <- get + put $! s { spec_done = extendVarSet (spec_done s) v } + + + +data Env = Env + { thisModule :: Module + , orphanRules :: RuleBase + } + ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -34,6 +34,7 @@ import GHC.Core.Utils ( exprIsTrivial import GHC.Core.FVs import GHC.Core.TyCo.FVs ( tyCoVarsOfTypeList ) import GHC.Core.Opt.Arity( collectBindersPushingCo ) +import GHC.Core.Opt.SpecRec (transferSpecRecs) import GHC.Builtin.Types ( unboxedUnitTy ) @@ -52,6 +53,7 @@ import GHC.Types.Var ( PiTyBinder(..), isLocalVar, isInvisibleFunArg ) import GHC.Types.Var.Set import GHC.Types.Var.Env import GHC.Types.Id +import GHC.Types.Id.Info import GHC.Types.Error import GHC.Utils.Error ( mkMCDiagnostic ) @@ -636,10 +638,13 @@ Hence, the invariant is this: -- | Specialise calls to type-class overloaded functions occurring in a program. specProgram :: ModGuts -> CoreM ModGuts -specProgram guts@(ModGuts { mg_module = this_mod - , mg_rules = local_rules - , mg_binds = binds }) +specProgram guts_in = do { dflags <- getDynFlags + + ; let guts@(ModGuts { mg_module = this_mod + , mg_rules = local_rules + , mg_binds = binds }) = transferSpecRecs guts_in + ; rule_env <- initRuleEnv guts -- See Note [Fire rules in the specialiser] @@ -1613,6 +1618,7 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs | notNull calls_for_me -- And there are some calls to specialise , not (isNeverActive inl_act) || idHasInlineable fn -- Explicit INLINEABLE pragma + || idHasSpecRec fn -- SpecRec || gopt Opt_SpecialiseAggressively dflags -- -fspecialise-aggressively , not (isOpaquePragma inl_prag) -- Don't specialise NOINLINE things by default. @@ -1766,6 +1772,11 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs | otherwise = inl_prag + spec_inlineable = idHasInlineable fn + spec_rec = idSpecRec fn + + spec_prag_info = mkPragInfo spec_inl_prag spec_inlineable spec_rec + -------------------------------------- -- Adding arity information just propagates it a bit faster -- See Note [Arity decrease] in GHC.Core.Opt.Simplify @@ -1773,7 +1784,7 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs -- So if f has INLINE[1] so does spec_fn arity_decr = count isValArg rule_lhs_args - count isId spec_bndrs spec_f_w_arity = spec_fn `setIdArity` max 0 (fn_arity - arity_decr) - `setInlinePragma` spec_inl_prag + `setIdPragmaInfo` spec_prag_info `setIdUnfolding` spec_unf `asJoinId_maybe` spec_join_arity ===================================== compiler/GHC/Core/Opt/WorkWrap.hs ===================================== @@ -830,6 +830,7 @@ mkWWBindPair ww_opts fn_id fn_info fn_args fn_body work_uniq div -- inl_inline: copy from fn_id; see Note [Worker/wrapper for INLINABLE functions] -- inl_act: see Note [Worker activation] -- inl_rule: it does not make sense for workers to be constructorlike. + work_prag_info = mkPragInfo work_prag fn_has_inlineable fn_spec_rec work_join_arity | isJoinId fn_id = Just join_arity | otherwise = Nothing @@ -844,8 +845,7 @@ mkWWBindPair ww_opts fn_id fn_info fn_args fn_body work_uniq div -- Doesn't matter much, since we will simplify next, but -- seems right-er to do so - `setInlinePragma` work_prag - `setHasInlineable` fn_has_inlineable + `setIdPragmaInfo` work_prag_info `setIdUnfolding` mkWorkerUnfolding simpl_opts work_fn fn_unfolding -- See Note [Worker/wrapper for INLINABLE functions] @@ -874,6 +874,7 @@ mkWWBindPair ww_opts fn_id fn_info fn_args fn_body work_uniq div wrap_rhs = wrap_fn work_id wrap_prag = mkStrWrapperInlinePrag fn_inl_prag fn_rules + wrap_prag_info = mkPragInfo wrap_prag fn_has_inlineable fn_spec_rec wrap_unf = mkWrapperUnfolding (simpleOptExpr simpl_opts wrap_rhs) arity wrap_id = fn_id `setIdUnfolding` wrap_unf @@ -881,7 +882,7 @@ mkWWBindPair ww_opts fn_id fn_info fn_args fn_body work_uniq div `setIdOccInfo` noOccInfo -- We must keep hasInlineable to ensure wrappers can specialise -- if they are NOINLINE[final] - `setHasInlineable`fn_has_inlineable + `setIdPragmaInfo` wrap_prag_info -- Zap any loop-breaker-ness, to avoid bleating from Lint -- about a loop breaker with an INLINE rule @@ -890,6 +891,7 @@ mkWWBindPair ww_opts fn_id fn_info fn_args fn_body work_uniq div fn_unfolding = realUnfoldingInfo fn_info fn_has_inlineable = inlineableInfo fn_info fn_rules = ruleInfoRules (ruleInfo fn_info) + fn_spec_rec = specRecInfo fn_info mkStrWrapperInlinePrag :: InlinePragma -> [CoreRule] -> InlinePragma mkStrWrapperInlinePrag (InlinePragma { inl_inline = fn_inl ===================================== compiler/GHC/Core/Ppr.hs ===================================== @@ -489,6 +489,9 @@ pprIdBndrInfo info has_inlineable = inlineableInfo info && isNoInlinePragma prag_info -- The flag is redundant -- unless we have NOINLINE. + spec_rec = specRecInfo info + has_spec_rec = isJust spec_rec || True + occ_info = occInfo info dmd_info = demandInfo info @@ -502,6 +505,7 @@ pprIdBndrInfo info doc = showAttributes [ (has_prag, text "InlPrag=" <> pprInlineDebug prag_info) , (has_inlineable, text "Inlineable") + , (has_spec_rec, text "SpecRec:" <> ppr spec_rec) , (has_occ, text "Occ=" <> ppr occ_info) , (has_dmd, text "Dmd=" <> ppr dmd_info) , (has_lbv , text "OS=" <> ppr lbv_info) @@ -512,6 +516,7 @@ instance Outputable IdInfo where [ (has_prag, text "InlPrag=" <> pprInlineDebug prag_info) -- Todo: This is only interesting for NoInline pragmas , (has_inlineable, text "Inlineable") + , (has_spec_rec, text "SpecRec:" <> ppr spec_rec) , (has_occ, text "Occ=" <> ppr occ_info) , (has_dmd, text "Dmd=" <> ppr dmd_info) , (has_lbv , text "OS=" <> ppr lbv_info) @@ -525,6 +530,9 @@ instance Outputable IdInfo where where prag_info = inlinePragInfo info has_prag = not (isDefaultInlinePragma prag_info) + spec_rec = specRecInfo info + has_spec_rec = isJust spec_rec || True + occ_info = occInfo info has_occ = not (isManyOccs occ_info) ===================================== compiler/GHC/CoreToIface.hs ===================================== @@ -84,7 +84,7 @@ import GHC.Utils.Panic import GHC.Utils.Panic.Plain import GHC.Utils.Misc -import Data.Maybe ( isNothing, catMaybes ) +import Data.Maybe {- Note [Avoiding space leaks in toIface*] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -463,7 +463,7 @@ toIfaceIdDetails other = pprTrace "toIfaceIdDetails" (ppr other) toIfaceIdInfo :: IdInfo -> IfaceIdInfo toIfaceIdInfo id_info = catMaybes [arity_hsinfo, caf_hsinfo, strict_hsinfo, cpr_hsinfo, - inline_hsinfo, has_inlineable_hsinfo, unfold_hsinfo] + inline_hsinfo, has_inlineable_hsinfo, unfold_hsinfo, spec_rec_hsinfo] -- NB: strictness and arity must appear in the list before unfolding -- See GHC.IfaceToCore.tcUnfolding where @@ -503,6 +503,10 @@ toIfaceIdInfo id_info | has_inlineable = Just HsInlineable | otherwise = Nothing + ------------ SpecRec flag ------------ + spec_rec_hsinfo = maybe Nothing (Just . HsSpecRec) (specRecInfo id_info) + + toIfaceJoinInfo :: Maybe JoinArity -> IfaceJoinInfo toIfaceJoinInfo (Just ar) = IfaceJoinPoint ar ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -175,6 +175,7 @@ import GHC.Core.Multiplicity import GHC.Core.Utils ( exprType ) import GHC.Core.ConLike import GHC.Core.Opt.Pipeline +import GHC.Core.Opt.SpecRec import GHC.Core.Opt.Pipeline.Types ( CoreToDo (..)) import GHC.Core.TyCon import GHC.Core.InstEnv @@ -2488,11 +2489,16 @@ hscTidy hsc_env guts = do let logger = hsc_logger hsc_env let this_mod = mg_module guts + (specrec_guts) <- withTiming logger + (text "CoreTidy"<+>brackets (ppr this_mod)) + (const ()) + $! {-# SCC "CoreTidy" #-} (return $ transferSpecRecs guts) + opts <- initTidyOpts hsc_env (cgguts, details) <- withTiming logger (text "CoreTidy"<+>brackets (ppr this_mod)) (const ()) - $! {-# SCC "CoreTidy" #-} tidyProgram opts guts + $! {-# SCC "CoreTidy" #-} tidyProgram opts specrec_guts -- post tidy pretty-printing and linting... let tidy_rules = md_rules details ===================================== compiler/GHC/HsToCore.hs ===================================== @@ -57,6 +57,7 @@ import GHC.Core.DataCon ( dataConWrapId ) import GHC.Core.Make import GHC.Core.Rules import GHC.Core.Opt.Pipeline.Types ( CoreToDo(..) ) +import GHC.Core.Opt.SpecRec import GHC.Core.Ppr import GHC.Builtin.Names @@ -254,7 +255,7 @@ deSugar hsc_env ; docs <- extractDocs dflags tcg_env - ; let mod_guts = ModGuts { + ; let mod_guts = transferSpecRecs ModGuts { mg_module = mod, mg_hsc_src = hsc_src, mg_loc = mkFileSrcSpan mod_loc, @@ -284,6 +285,7 @@ deSugar hsc_env mg_complete_matches = complete_matches, mg_docs = docs } + ; return (msgs, Just mod_guts) }}}} ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -993,6 +993,8 @@ rep_sig (L loc (ClassOpSig _ is_deflt nms ty)) | otherwise = mapM (rep_ty_sig sigDName (locA loc) ty) nms rep_sig (L loc (FixSig _ fix_sig)) = rep_fix_d (locA loc) fix_sig rep_sig (L loc (InlineSig _ nm ispec))= rep_inline nm ispec (locA loc) +rep_sig (L loc (SpecRecSig _ nm act)) + = rep_specrec nm act (locA loc) rep_sig (L loc (SpecSig _ nm tys ispec)) = concatMapM (\t -> rep_specialise nm t ispec (locA loc)) tys rep_sig (L loc (SpecInstSig _ ty)) = rep_specialiseInst ty (locA loc) @@ -1097,6 +1099,8 @@ rep_inline nm ispec loc ; return [(loc, pragma)] } +rep_specrec = error "TODO" + rep_specialise :: LocatedN Name -> LHsSigType GhcRn -> InlinePragma -> SrcSpan -> MetaM [(SrcSpan, Core (M TH.Dec))] ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -1718,6 +1718,11 @@ instance HiePass p => ToHie (SigContext (LocatedA (Sig (GhcPass p)))) where InlineSig _ name _ -> [ toHie $ (C Use) name ] + SpecRecSig _ name act -> + [ toHie $ (C Use) name + -- TODO: activation + -- , toHie $ act + ] SpecSig _ name typs _ -> [ toHie $ (C Use) name , toHie $ map (TS (ResolvedScopes [])) typs ===================================== compiler/GHC/Iface/Recomp.hs ===================================== @@ -1035,9 +1035,14 @@ addFingerprints hsc_env iface0 -- See Note [Identity versus semantic module] | semantic_mod /= this_mod , not (isHoleModule semantic_mod) = global_hash_fn name - | otherwise = return (snd (lookupOccEnv local_env (getOccName name) - `orElse` pprPanic "urk! lookup local fingerprint" - (ppr name $$ ppr local_env))) + | otherwise = do + let fp = lookupOccEnv local_env (getOccName name) `orElse` + (pprTrace "urk! lookup local fingerprint" + (ppr (nameModule name) $$ ppr name $$ ppr local_env) + -- TODO: ??? + (undefined, fingerprint0) + ) + return $ snd fp -- This panic indicates that we got the dependency -- analysis wrong, because we needed a fingerprint for -- an entity that wasn't in the environment. To debug ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -358,6 +358,7 @@ data IfaceInfoItem | HsUnfold Bool -- True <=> isStrongLoopBreaker is true IfaceUnfolding -- See Note [Expose recursive functions] | HsInlineable + | HsSpecRec Activation | HsNoCafRefs | HsLFInfo IfaceLFInfo | HsTagSig TagSig @@ -1517,6 +1518,7 @@ instance Outputable IfaceInfoItem where <> colon <+> ppr unf ppr (HsInline prag) = text "Inline:" <+> ppr prag ppr (HsInlineable) = text "HasInlineable:True" + ppr (HsSpecRec act) = text "SpecRec:" <> ppr act ppr (HsArity arity) = text "Arity:" <+> int arity ppr (HsDmdSig str) = text "Strictness:" <+> ppr str ppr (HsCprSig cpr) = text "CPR:" <+> ppr cpr @@ -2287,7 +2289,8 @@ instance Binary IfaceInfoItem where put_ bh (HsCprSig cpr) = putByte bh 6 >> put_ bh cpr put_ bh (HsLFInfo lf_info) = putByte bh 7 >> put_ bh lf_info put_ bh (HsTagSig sig) = putByte bh 8 >> put_ bh sig - put_ bh (HsInlineable) = putByte bh 9 + put_ bh (HsInlineable) = putByte bh 9 + put_ bh (HsSpecRec act) = putByte bh 10 >> put_ bh act get bh = do h <- getByte bh @@ -2303,6 +2306,7 @@ instance Binary IfaceInfoItem where 7 -> HsLFInfo <$> get bh 8 -> HsTagSig <$> get bh 9 -> pure HsInlineable + 10 -> HsSpecRec <$> get bh _ -> error "Binary:IfaceInfoItem - Invalid byte" instance Binary IfaceUnfolding where @@ -2713,6 +2717,7 @@ instance NFData IfaceInfoItem where HsLFInfo lf_info -> lf_info `seq` () -- TODO: seq further? HsTagSig sig -> sig `seq` () HsInlineable -> () + HsSpecRec act -> rnf act instance NFData IfGuidance where rnf = \case ===================================== compiler/GHC/Iface/Tidy.hs ===================================== @@ -384,6 +384,8 @@ tidyProgram opts (ModGuts { mg_module = mod (unfold_env, tidy_occ_env) <- chooseExternalIds opts mod all_binds imp_rules let (trimmed_binds, trimmed_rules) = findExternalRules opts all_binds imp_rules unfold_env + -- pprTraceM "trimmed_binds" (ppr $ bindersOfBinds trimmed_binds) + (tidy_env, tidy_binds) <- tidyTopBinds unfold_env boot_exports tidy_occ_env trimmed_binds -- See Note [Grand plan for static forms] in GHC.Iface.Tidy.StaticPtrTable. @@ -652,7 +654,9 @@ chooseExternalIds :: TidyOpts chooseExternalIds opts mod binds imp_id_rules = do { (unfold_env1,occ_env1) <- search init_work_list emptyVarEnv init_occ_env + -- ; pprTraceM "unfoldEnv" (ppr unfold_env1) ; let internal_ids = filter (not . (`elemVarEnv` unfold_env1)) binders + -- ; pprTraceM "internals" (ppr internal_ids) ; tidy_internal internal_ids unfold_env1 occ_env1 } where name_cache = opt_name_cache opts @@ -717,7 +721,9 @@ chooseExternalIds opts mod binds imp_id_rules search [] unfold_env occ_env = return (unfold_env, occ_env) search ((idocc,referrer) : rest) unfold_env occ_env - | idocc `elemVarEnv` unfold_env = search rest unfold_env occ_env + | idocc `elemVarEnv` unfold_env = + -- pprTrace "search.1" (ppr idocc <+> ppr referrer) $ + search rest unfold_env occ_env | otherwise = do (occ_env', name') <- tidyTopName mod name_cache (Just referrer) occ_env idocc let @@ -733,6 +739,11 @@ chooseExternalIds opts mod binds imp_id_rules referrer' | isExportedId refined_id = refined_id | otherwise = referrer -- + -- pprTraceM "search.2" + -- (ppr idocc <+> ppr referrer $$ + -- text "show:" <> ppr show_unfold $$ + -- text "name',external:" <> ppr (name', isExternalName name') + -- ) search (zip new_ids (repeat referrer') ++ rest) unfold_env' occ_env' tidy_internal :: [Id] -> UnfoldEnv -> TidyOccEnv @@ -762,6 +773,7 @@ addExternal opts id loop_breaker = isStrongLoopBreaker (occInfo idinfo) bottoming_fn = isDeadEndSig (dmdSigInfo idinfo) inlineable = inlineableInfo idinfo + spec_rec = specRecInfo idinfo -- Stuff to do with the Id's unfolding -- We leave the unfolding there even if there is a worker @@ -776,6 +788,7 @@ addExternal opts id -- source is an inline rule || inlineable + || isJust spec_rec || not dont_inline where @@ -1033,7 +1046,11 @@ findExternalRules opts binds imp_id_rules unfold_env where stuff@(binds', bndr_set, needed_fvs, rules) = trim_binds binds - needed bndr = isExportedId bndr || bndr `elemVarSet` needed_fvs + shows_unf bndr = case lookupVarEnv unfold_env bndr of + Just (name, show_unf) + | isExternalName name || show_unf -> True + _ -> False + needed bndr = isExportedId bndr || bndr `elemVarSet` needed_fvs || shows_unf bndr bndrs = bindersOf bind rhss = rhssOfBind bind @@ -1281,7 +1298,7 @@ tidyTopIdInfo rhs_tidy_env name rhs_ty orig_rhs tidy_rhs idinfo show_unfold Nothing -> False Just (arity, _, _) -> not (isDeadEndAppSig id_sig arity) - prag_info = mkPragInfo (inlinePragInfo idinfo) (inlineableInfo idinfo) + prag_info = mkPragInfo (inlinePragInfo idinfo) (inlineableInfo idinfo) (specRecInfo idinfo) --------- Unfolding ------------ -- Force unfold_info (hence bangs), otherwise the old unfolding -- is retained during code generation. See #22071 ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -1725,6 +1725,7 @@ tcIdInfo ignore_prags toplvl name ty info = do tcPrag info (HsCprSig cpr) = return (info `setCprSigInfo` cpr) tcPrag info (HsInline prag) = return (info `setInlinePragInfo` prag) tcPrag info (HsInlineable) = return (info `setHasInlineableInfo` True) + tcPrag info (HsSpecRec act) = return (info `setHasSpecRecInfo` (Just act)) tcPrag info (HsLFInfo lf_info) = do lf_info <- tcLFInfo lf_info return (info `setLFInfo` lf_info) ===================================== compiler/GHC/Rename/Bind.hs ===================================== @@ -1054,6 +1054,10 @@ renameSig ctxt sig@(InlineSig _ v s) = do { new_v <- lookupSigOccRnN ctxt sig v ; return (InlineSig noAnn new_v s, emptyFVs) } +renameSig ctxt sig@(SpecRecSig _ v s) + = do { new_v <- lookupSigOccRnN ctxt sig v + ; return (SpecRecSig noAnn new_v s, emptyFVs) } + renameSig ctxt (FixSig _ fsig) = do { new_fsig <- rnSrcFixityDecl ctxt fsig ; return (FixSig noAnn new_fsig, emptyFVs) } @@ -1138,6 +1142,10 @@ okHsSig ctxt (L _ sig) (InlineSig {}, HsBootCtxt {}) -> False (InlineSig {}, _) -> True + (SpecRecSig {}, HsBootCtxt {}) -> False + (SpecRecSig {}, LocalBindCtxt {}) -> False + (SpecRecSig {}, _) -> True + (SpecSig {}, TopSigCtxt {}) -> True (SpecSig {}, LocalBindCtxt {}) -> True (SpecSig {}, InstDeclCtxt {}) -> True @@ -1176,10 +1184,11 @@ findDupSigs sigs expand_sig :: Sig GhcPs -> [(LocatedN RdrName, Sig GhcPs)] -- AZ expand_sig sig@(FixSig _ (FixitySig _ ns _)) = zip ns (repeat sig) expand_sig sig@(InlineSig _ n _) = [(n,sig)] + expand_sig sig@(SpecRecSig _ n _) = [(n,sig)] expand_sig sig@(TypeSig _ ns _) = [(n,sig) | n <- ns] expand_sig sig@(ClassOpSig _ _ ns _) = [(n,sig) | n <- ns] expand_sig sig@(PatSynSig _ ns _ ) = [(n,sig) | n <- ns] - expand_sig sig@(SCCFunSig (_, _) n _) = [(n,sig)] + expand_sig sig@(SCCFunSig (_, _) n _) = [(n,sig)] expand_sig _ = [] matching_sig :: (LocatedN RdrName, Sig GhcPs) -> (LocatedN RdrName, Sig GhcPs) -> Bool --AZ @@ -1194,6 +1203,7 @@ findDupSigs sigs mtch (ClassOpSig _ d1 _ _) (ClassOpSig _ d2 _ _) = d1 == d2 mtch (PatSynSig _ _ _) (PatSynSig _ _ _) = True mtch (SCCFunSig{}) (SCCFunSig{}) = True + mtch (SpecRecSig{}) (SpecRecSig{}) = True mtch _ _ = False -- Warn about multiple MINIMAL signatures ===================================== compiler/GHC/Tc/Gen/Bind.hs ===================================== @@ -637,6 +637,7 @@ tcPolyCheck prag_fn poly_id2 = mkLocalId mono_name (idMult poly_id) (idType poly_id) ; spec_prags <- tcSpecPrags poly_id prag_sigs ; poly_id <- addInlinePrags poly_id prag_sigs + ; poly_id <- addSpecRecPrags poly_id prag_sigs ; mod <- getModule ; tick <- funBindTicks (locA nm_loc) poly_id mod prag_sigs @@ -832,6 +833,7 @@ mkExport prag_fn residual insoluble qtvs theta -- NB: poly_id has a zonked type ; poly_id <- addInlinePrags poly_id prag_sigs + ; poly_id <- addSpecRecPrags poly_id prag_sigs ; spec_prags <- tcSpecPrags poly_id prag_sigs -- tcPrags requires a zonked poly_id @@ -1514,7 +1516,10 @@ tcLhsSigId no_gen (name, sig) newSigLetBndr :: LetBndrSpec -> Name -> TcIdSigInst -> TcM TcId newSigLetBndr (LetGblBndr prags) name (TISI { sig_inst_sig = id_sig }) | CompleteSig { sig_bndr = poly_id } <- id_sig - = addInlinePrags poly_id (lookupPragEnv prags name) + = do + poly_id <- addInlinePrags poly_id (lookupPragEnv prags name) + poly_id <- addSpecRecPrags poly_id (lookupPragEnv prags name) + return poly_id newSigLetBndr no_gen name (TISI { sig_inst_tau = tau }) = newLetBndr no_gen name ManyTy tau -- Binders with a signature are currently always of multiplicity ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -32,7 +32,7 @@ import GHC.Hs.Syn.Type import GHC.Rename.Utils import GHC.Tc.Errors.Types import GHC.Tc.Utils.Zonk -import GHC.Tc.Gen.Sig( TcPragEnv, lookupPragEnv, addInlinePrags ) +import GHC.Tc.Gen.Sig import GHC.Tc.Utils.Monad import GHC.Tc.Utils.Instantiate import GHC.Types.FieldLabel @@ -265,7 +265,11 @@ newLetBndr LetLclBndr name w ty = do { mono_name <- cloneLocalName name ; return (mkLocalId mono_name w ty) } newLetBndr (LetGblBndr prags) name w ty - = addInlinePrags (mkLocalId name w ty) (lookupPragEnv prags name) + = do { let prags' = (lookupPragEnv prags name) + ; bndr <- addInlinePrags (mkLocalId name w ty) prags' + ; bndr <- addSpecRecPrags bndr prags' + ; return bndr + } tc_sub_type :: PatEnv -> ExpSigmaType -> TcSigmaType -> TcM HsWrapper -- tcSubTypeET with the UserTypeCtxt specialised to GenSigCtxt ===================================== compiler/GHC/Tc/Gen/Sig.hs ===================================== @@ -22,7 +22,7 @@ module GHC.Tc.Gen.Sig( TcPragEnv, emptyPragEnv, lookupPragEnv, extendPragEnv, mkPragEnv, tcSpecPrags, tcSpecWrapper, tcImpPrags, - addInlinePrags, addInlinePragArity + addInlinePrags, addInlinePragArity, addSpecRecPrags ) where import GHC.Prelude @@ -56,8 +56,7 @@ import GHC.Core.TyCo.Rep( mkNakedFunTy ) import GHC.Types.Error import GHC.Types.Var ( TyVar, Specificity(..), tyVarKind, binderVars, invisArgTypeLike ) -import GHC.Types.Id ( Id, idName, idType, setIdPragmaInfo - , mkLocalId, realIdUnfolding ) +import GHC.Types.Id import GHC.Types.Id.Info import GHC.Types.Basic import GHC.Types.Name @@ -592,6 +591,7 @@ mkPragEnv sigs binds get_sig sig@(L _ (SpecSig _ (L _ nm) _ _)) = Just (nm, add_arity nm sig) get_sig sig@(L _ (InlineSig _ (L _ nm) _)) = Just (nm, add_arity nm sig) get_sig sig@(L _ (SCCFunSig _ (L _ nm) _)) = Just (nm, sig) + get_sig sig@(L _ (SpecRecSig _ (L _ nm) _)) = Just (nm, sig) get_sig _ = Nothing add_arity n sig -- Adjust inl_sat field to match visible arity of function @@ -633,7 +633,7 @@ computePragmaInfo info (prag:prags) -- INLINEABLE + NOINLINE | NoInline{} <- new_spec , isDefaultActivationPragma old_prag - -> computePragmaInfo (mkPragInfo prag True) prags + -> computePragmaInfo (mkPragInfo prag True spec_rec) prags | otherwise -> Nothing NoInline{} -- NOINLINE + INLINEABLE @@ -645,12 +645,13 @@ computePragmaInfo info (prag:prags) Opaque{} -> Nothing NoUserInlinePrag -> computePragmaInfo - (mkPragInfo prag (isInlinablePragma prag)) + (mkPragInfo prag (isInlinablePragma prag) spec_rec) prags where old_prag = pragInfoInline $ info old_spec = inl_inline old_prag new_spec = inl_inline prag + spec_rec = pragSpecRec info @@ -659,7 +660,7 @@ addInlinePrags :: TcId -> [LSig GhcRn] -> TcM TcId addInlinePrags poly_id prags_for_me | inl@(L _ inl_prag) : inls <- inl_prags = do { traceTc "addInlinePrag" (ppr poly_id $$ ppr inl_prag) - ; let init_info = (mkPragInfo inl_prag $ isInlinablePragma inl_prag) + ; let init_info = mkPragInfo inl_prag (isInlinablePragma inl_prag) (idSpecRec poly_id) m_prag_info = computePragmaInfo init_info (map unLoc inls) @@ -687,6 +688,15 @@ addInlinePrags poly_id prags_for_me let dia = TcRnMultipleInlinePragmas poly_id inl1 (inl2 NE.:| inls) in addDiagnosticTc dia +----------------- +addSpecRecPrags :: TcId -> [LSig GhcRn] -> TcM TcId +addSpecRecPrags poly_id prags_for_me + = case spec_rec of + [] -> return poly_id + [L _ act] -> return $ setHasSpecRec poly_id (Just act) + (_:_) -> error "TODO: Duplicate SpecRec" + where + spec_rec = [L loc act | L loc (SpecRecSig _ _ act) <- prags_for_me] {- Note [Pattern synonym inline arity] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -829,7 +839,7 @@ tcSpecPrags poly_id prag_sigs where spec_sigs = filter isSpecLSig prag_sigs bad_sigs = filter is_bad_sig prag_sigs - is_bad_sig s = not (isSpecLSig s || isInlineLSig s || isSCCFunSig s) + is_bad_sig s = not (isSpecLSig s || isSpecRecLSig s || isInlineLSig s || isSCCFunSig s) warn_discarded_sigs bad_sigs_ne = let dia = TcRnUnexpectedPragmas poly_id bad_sigs_ne ===================================== compiler/GHC/Tc/TyCl/Class.hs ===================================== @@ -253,6 +253,7 @@ tcDefMeth clas tyvars this_dict binds_in hs_sig_fn prag_fn global_dm_id <- tcLookupId dm_name ; global_dm_id <- addInlinePrags global_dm_id prags + ; global_dm_id <- addSpecRecPrags global_dm_id prags ; local_dm_name <- newNameAt (getOccName sel_name) bndr_loc -- Base the local_dm_name on the selector name, because -- type errors from tcInstanceMethodBody come from here ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -1900,6 +1900,7 @@ tcMethodBody clas tyvars dfun_ev_vars inst_tys tcMethodBodyHelp sig_fn sel_id local_meth_id (L bind_loc lm_bind) ; global_meth_id <- addInlinePrags global_meth_id prags + ; global_meth_id <- addSpecRecPrags global_meth_id prags ; spec_prags <- tcSpecPrags global_meth_id prags ; let specs = mk_meth_spec_prags global_meth_id spec_inst_prags spec_prags @@ -2113,7 +2114,11 @@ mkDefMethBind loc dfun_id clas sel_id dm_name = [] -- Copy the inline pragma (if any) from the default method -- to this version. Note [INLINE and default methods] - + spec_rec = idSpecRec dm_id + spec_rec_prag | Just act <- spec_rec + = [noLocA (SpecRecSig noAnn fn act)] + | otherwise + = [] fn = noLocA (idName sel_id) visible_inst_tys = [ ty | (tcb, ty) <- tyConBinders (classTyCon clas) `zip` inst_tys , tyConBinderForAllTyFlag tcb /= Inferred ] @@ -2127,7 +2132,7 @@ mkDefMethBind loc dfun_id clas sel_id dm_name (vcat [ppr clas <+> ppr inst_tys, nest 2 (ppr sel_id <+> equals <+> ppr rhs)])) - ; return (bind, inline_prags) } + ; return (bind, spec_rec_prag ++ inline_prags) } where (_, _, _, inst_tys) = tcSplitDFunTy (idType dfun_id) ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -26,8 +26,7 @@ import GHC.Tc.Utils.TcMType import GHC.Tc.Utils.Zonk import GHC.Tc.Errors.Types import GHC.Tc.Utils.Monad -import GHC.Tc.Gen.Sig ( TcPragEnv, emptyPragEnv, completeSigFromId, lookupPragEnv - , addInlinePrags, addInlinePragArity ) +import GHC.Tc.Gen.Sig import GHC.Tc.Solver import GHC.Tc.Utils.Unify import GHC.Tc.Utils.TcType @@ -851,9 +850,11 @@ tcPatSynMatcher (L loc ps_name) lpat prag_fn -- Add INLINE pragmas; see Note [Pragmas for pattern synonyms] -- NB: prag_fn is keyed by the PatSyn Name, not the (internal) matcher name - ; matcher_prag_id <- addInlinePrags matcher_id $ - map (addInlinePragArity matcher_arity) $ - lookupPragEnv prag_fn ps_name + ; let prags = map (addInlinePragArity matcher_arity) $ + lookupPragEnv prag_fn ps_name + + ; matcher_prag_id <- addInlinePrags matcher_id prags + ; matcher_prag_id <- addSpecRecPrags matcher_prag_id prags ; let bind = FunBind{ fun_id = L loc matcher_prag_id , fun_matches = mg @@ -949,9 +950,11 @@ tcPatSynBuilderBind prag_fn (PSB { psb_id = ps_lname@(L loc ps_name) -- Add INLINE pragmas; see Note [Pragmas for pattern synonyms] -- NB: prag_fn is keyed by the PatSyn Name, not the (internal) builder name - ; builder_id <- addInlinePrags builder_id $ - map (addInlinePragArity builder_arity) $ - lookupPragEnv prag_fn ps_name + ; let prags = map (addInlinePragArity builder_arity) $ + lookupPragEnv prag_fn ps_name + ; builder_id <- addInlinePrags builder_id prags + ; builder_id <- addSpecRecPrags builder_id prags + ; let match_group' | need_dummy_arg = add_dummy_arg match_group | otherwise = match_group ===================================== compiler/GHC/Types/Basic.hs ===================================== @@ -1711,6 +1711,15 @@ instance Binary Activation where ab <- get bh return (ActiveAfter src ab) +instance NFData Activation where + rnf act = case act of + AlwaysActive -> () + NeverActive -> () + ActiveBefore src phase -> src `deepseq` phase `deepseq` () + ActiveAfter src phase -> src `deepseq` phase `deepseq` () + FinalActive -> () + + instance Outputable RuleMatchInfo where ppr ConLike = text "CONLIKE" ppr FunLike = text "FUNLIKE" ===================================== compiler/GHC/Types/Id.hs ===================================== @@ -83,7 +83,8 @@ module GHC.Types.Id ( -- ** Inline pragma stuff idPragmaInfo, idInlinePragma, idHasInlineable, setInlinePragma, - setIdPragmaInfo, modifyInlinePragma, setHasInlineable, + idHasSpecRec, idSpecRec, + setIdPragmaInfo, modifyInlinePragma, setHasInlineable, setHasSpecRec, idInlineActivation, setInlineActivation, idRuleMatchInfo, -- ** One-shot lambdas @@ -176,6 +177,7 @@ infixl 1 `setIdUnfolding`, `setIdSpecialisation`, `setInlinePragma`, `setHasInlineable`, + `setHasSpecRec`, `setIdPragmaInfo`, `setInlineActivation`, `idCafInfo`, @@ -899,6 +901,12 @@ idInlinePragma id = inlinePragInfo (idInfo id) idHasInlineable :: Id -> Bool idHasInlineable id = inlineableInfo (idInfo id) +idHasSpecRec :: Id -> Bool +idHasSpecRec id = isJust $ specRecInfo (idInfo id) + +idSpecRec :: Id -> Maybe Activation +idSpecRec id = specRecInfo (idInfo id) + idPragmaInfo :: Id -> PragInfo idPragmaInfo id = pragInfo (idInfo id) @@ -908,6 +916,9 @@ setInlinePragma id prag = modifyIdInfo (`setInlinePragInfo` prag) id setHasInlineable :: Id -> Bool -> Id setHasInlineable id inlineable = modifyIdInfo (`setHasInlineableInfo` inlineable) id +setHasSpecRec :: Id -> (Maybe Activation) -> Id +setHasSpecRec id spec_rec = modifyIdInfo (`setHasSpecRecInfo` spec_rec) id + setIdPragmaInfo :: Id -> PragInfo -> Id setIdPragmaInfo id pragInfo = modifyIdInfo (`setPragInfo` pragInfo) id @@ -1053,6 +1064,7 @@ transferPolyIdInfo old_id abstract_wrt new_id old_arity = arityInfo old_info old_inline_prag = inlinePragInfo old_info old_unf_info = inlineableInfo old_info + old_spec_rec = specRecInfo old_info old_occ_info = occInfo old_info new_arity = old_arity + arity_increase new_occ_info = zapOccTailCallInfo old_occ_info @@ -1077,6 +1089,7 @@ transferPolyIdInfo old_id abstract_wrt new_id transfer new_info = new_info `setArityInfo` new_arity `setInlinePragInfo` old_inline_prag `setHasInlineableInfo` old_unf_info + `setHasSpecRecInfo` old_spec_rec `setOccInfo` new_occ_info `setDmdSigInfo` new_strictness `setCprSigInfo` new_cpr ===================================== compiler/GHC/Types/Id/Info.hs ===================================== @@ -49,10 +49,11 @@ module GHC.Types.Id.Info ( -- ** Unfolding Info realUnfoldingInfo, unfoldingInfo, setUnfoldingInfo, hasInlineUnfolding, inlinePragInfo, setInlinePragInfo, inlineableInfo, setHasInlineableInfo, + specRecInfo, setHasSpecRecInfo, -- ** The PragInfo type setPragInfo, pragInfo, PragInfo, mkPragInfo, - pragInfoInline, pragHasInlineable, + pragInfoInline, pragHasInlineable, pragSpecRec, setPragInfoInline, -- ** The OccInfo type @@ -117,6 +118,7 @@ infixl 1 `setRuleInfo`, `setArityInfo`, `setInlinePragInfo`, `setHasInlineableInfo`, + `setHasSpecRecInfo`, `setUnfoldingInfo`, `setOneShotInfo`, `setOccInfo`, @@ -439,6 +441,9 @@ inlinePragInfo = pragInfoInline . pragInfo inlineableInfo :: IdInfo -> Bool inlineableInfo = pragHasInlineable . pragInfo +specRecInfo :: IdInfo -> (Maybe Activation) +specRecInfo = pragSpecRec . pragInfo + -- | Info about a lambda-bound variable, if the 'Id' is one oneShotInfo :: IdInfo -> OneShotInfo oneShotInfo = bitfieldGetOneShotInfo . bitfield @@ -474,6 +479,9 @@ setInlinePragInfo :: IdInfo -> InlinePragma -> IdInfo setInlinePragInfo info pr = pr `seq` info { pragInfo = setPragInfoInline pr (pragInfo info) } setHasInlineableInfo :: IdInfo -> Bool -> IdInfo setHasInlineableInfo info pr = pr `seq` info { pragInfo = setPragInfoUnf pr (pragInfo info) } +setHasSpecRecInfo :: IdInfo -> (Maybe Activation) -> IdInfo +setHasSpecRecInfo info pr = pr `seq` info { pragInfo = setPragInfoSpecRec pr (pragInfo info) } + -- Try to avoid space leaks by seq'ing -- | Essentially returns the 'realUnfoldingInfo' field, but does not expose the @@ -641,18 +649,21 @@ ppArityInfo n = hsep [text "Arity", int n] -- entirely as a way to inhibit inlining until we want it data PragInfo = PragInfo { -- | INLINE etc info - pragInfoInline :: !InlinePragma + pragInfoInline :: InlinePragma , -- | Should we keep the unfolding? - pragHasInlineable :: !Bool + pragHasInlineable :: Bool + , -- | Allow specialisation transitively? + pragSpecRec :: (Maybe Activation) } deriving Eq instance Outputable PragInfo where ppr prag = text "PragInfo=" <> braces (ppr (pragInfoInline prag) <> comma <> - text "HasInlineable:" <> ppr (pragHasInlineable prag)) + text "HasInlineable:" <> ppr (pragHasInlineable prag) <> comma <> + text "SpecRec:" <> ppr (pragSpecRec prag)) --- | mkPragInfo inl_prag has_inlineable -mkPragInfo :: InlinePragma -> Bool -> PragInfo +-- | mkPragInfo inl_prag has_inlineable spec_rec +mkPragInfo :: InlinePragma -> Bool -> (Maybe Activation) -> PragInfo mkPragInfo = PragInfo setPragInfoInline :: InlinePragma -> PragInfo -> PragInfo @@ -661,14 +672,21 @@ setPragInfoInline inl prag_info = prag_info { pragInfoInline = inl } setPragInfoUnf :: Bool -> PragInfo -> PragInfo setPragInfoUnf keep prag_info = prag_info { pragHasInlineable = keep } +setPragInfoSpecRec :: (Maybe Activation) -> PragInfo -> PragInfo +setPragInfoSpecRec spec_rec prag_info = prag_info { pragSpecRec = spec_rec } + defaultPragInfo :: PragInfo defaultPragInfo = PragInfo { pragInfoInline = defaultInlinePragma - , pragHasInlineable = defaultHasInlineableInfo } + , pragHasInlineable = defaultHasInlineableInfo + , pragSpecRec = defaultSpecRecInfo } defaultHasInlineableInfo :: Bool defaultHasInlineableInfo = False +defaultSpecRecInfo :: Maybe Activation +defaultSpecRecInfo = Nothing + {- ************************************************************************ * * ===================================== compiler/GHC/Types/SourceText.hs ===================================== @@ -39,6 +39,8 @@ import Data.Data import GHC.Real ( Ratio(..) ) import GHC.Types.SrcLoc +import Control.DeepSeq + {- Note [Pragma source text] ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -121,6 +123,10 @@ instance Binary SourceText where return (SourceText s) _ -> panic $ "Binary SourceText:" ++ show h +instance NFData SourceText where + rnf NoSourceText = () + rnf (SourceText s) = rnf s + -- | Special combinator for showing string literals. pprWithSourceText :: SourceText -> SDoc -> SDoc pprWithSourceText NoSourceText d = d ===================================== compiler/Language/Haskell/Syntax/Binds.hs ===================================== @@ -36,7 +36,7 @@ import GHC.Data.Bag (Bag) import GHC.Types.Basic (InlinePragma, Activation) import GHC.Data.BooleanFormula (LBooleanFormula) -import GHC.Types.SourceText (StringLiteral, SourceText) +import GHC.Types.SourceText (StringLiteral) import Data.Void import Data.Bool @@ -482,6 +482,10 @@ isSpecLSig :: forall p. UnXRec p => LSig p -> Bool isSpecLSig (unXRec @p -> SpecSig {}) = True isSpecLSig _ = False +isSpecRecLSig :: forall p. UnXRec p => LSig p -> Bool +isSpecRecLSig (unXRec @p -> SpecRecSig {}) = True +isSpecRecLSig _ = False + isSpecInstLSig :: forall p. UnXRec p => LSig p -> Bool isSpecInstLSig (unXRec @p -> SpecInstSig {}) = True isSpecInstLSig _ = False @@ -491,6 +495,7 @@ isPragLSig :: forall p. UnXRec p => LSig p -> Bool isPragLSig (unXRec @p -> SpecSig {}) = True isPragLSig (unXRec @p -> InlineSig {}) = True isPragLSig (unXRec @p -> SCCFunSig {}) = True +isPragLSig (unXRec @p -> SpecRecSig {}) = True isPragLSig (unXRec @p -> CompleteMatchSig {}) = True isPragLSig _ = False ===================================== compiler/ghc.cabal.in ===================================== @@ -330,6 +330,7 @@ Library GHC.Core.Opt.Simplify.Utils GHC.Core.Opt.SpecConstr GHC.Core.Opt.Specialise + GHC.Core.Opt.SpecRec GHC.Core.Opt.StaticArgs GHC.Core.Opt.Stats GHC.Core.Opt.WorkWrap View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0366194bcfa263fa4013ac05d9795ffaba2c13a0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0366194bcfa263fa4013ac05d9795ffaba2c13a0 You're receiving 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 Jan 6 11:26:27 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Fri, 06 Jan 2023 06:26:27 -0500 Subject: [Git][ghc/ghc][wip/int-index/decl-invis-binders] 172 commits: Hadrian: fix ghcDebugAssertions off-by-one error Message-ID: <63b80563ea568_f192a1978bfa449023f@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/decl-invis-binders 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 - - - - - 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 - - - - - 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]. - - - - - 2eb0fb87 by Matthew Pickering at 2022-12-15T03:54:39-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 - - - - - 552b7908 by Ben Gamari at 2022-12-15T03:55:15-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. - - - - - 933d61a4 by Simon Peyton Jones at 2022-12-15T03:55:51-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. - - - - - 03ed0b95 by Ryan Scott at 2022-12-15T03:56:26-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. - - - - - ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/ThreadPaused: Ordering fixes - - - - - 914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00 eventlog: Silence spurious data race - - - - - fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts: Use fences instead of explicit barriers - - - - - 2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - 70999283 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 98689f77 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - 86f20258 by Ben Gamari at 2022-12-16T16:12:45-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. - - - - - f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate access to capabilities array - - - - - 7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate sched_state - - - - - 1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Style fix - - - - - 82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00 compiler: Use release store in eager blackholing - - - - - eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Fix ordering of makeStableName - - - - - ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Note race with wakeBlockingQueue - - - - - 5acf33dd by Bodigrim at 2022-12-16T16:13:22-05:00 Bump submodule directory to 1.3.8.0 and hpc to HEAD - - - - - 0dd95421 by Bodigrim at 2022-12-16T16:13:22-05:00 Accept allocations increase on Windows This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips between lists and ByteArray. See #22625 for discussion. Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T10547 T12150 T12227 T12234 T12425 T13035 T13253 T13253-spj T13701 T13719 T15703 T16875 T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T21839r T5837 T6048 T9198 T9961 TcPlugin_RewritePerf hard_hole_fits - - - - - ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00 testsuite: Mark T9405 as fragile instead of broken on Windows It's starting to pass again, and the unexpected pass blocks CI. - - - - - 1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: remove obsolete commented code in wasm NCG It was just a temporary hack to workaround a bug in the relooper, that bug has been fixed long before the wasm backend is merged. - - - - - e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm Also removes some unreachable code here. - - - - - 1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: change fallback function signature to Cmm function signature in wasm NCG In the wasm NCG, when handling a `CLabel` of undefined function without knowing its function signature, we used to fallback to `() -> ()` which is accepted by `wasm-ld`. This patch changes it to the signature of Cmm functions, which equally works, but would be required when we emit tail call instructions. - - - - - 8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add optional tail-call support in wasm NCG When the `-mtail-call` clang flag is passed at configure time, wasm tail-call extension is enabled, and the wasm NCG will emit `return_call`/`return_call_indirect` instructions to take advantage of it and avoid the `StgRun` trampoline overhead. Closes #22461. - - - - - d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00 base: add missing autoconf checks for waitpid/umask These are not present in wasi-libc. Required for fixing #22589 - - - - - da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00 compiler: make .wasm the default executable extension on wasm32 Following convention as in other wasm toolchains. Fixes #22594. - - - - - ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00 ci: support hello.wasm in ci.sh cross testing logic - - - - - 6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00 Correct `exitWith` Haddocks The `IOError`-specific `catch` in the Prelude is long gone. - - - - - b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-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. - - - - - 761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00 rts/libdw: Silence uninitialized usage warnings As noted in #22538, previously some GCC versions warned that various locals in Libdw.c may be used uninitialized. Although this wasn't strictly true (since they were initialized in an inline assembler block) we fix this by providing explicit empty initializers. Fixes #22538 - - - - - 5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00 testsuite: Mark T16392 as fragile on windows See #22649 - - - - - 703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00 Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`. - - - - - 9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05: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 - - - - - 7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Drop uses of AC_PROG_CC_C99 As noted in #22566, this macro is deprecated as of autoconf-2.70 `AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself. Closes #22566. - - - - - 36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Use AS_HELP_STRING instead of AC_HELP_STRING The latter has been deprecated. See #22566. - - - - - befe6ff8 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: fix various usages of head and tail - - - - - 666d0ba7 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: avoid head and tail in parseCallEscape and around - - - - - 5d96fd50 by Bodigrim at 2022-12-20T21:16:37-05:00 Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty - - - - - 3ce2ab94 by Bodigrim at 2022-12-21T06:17:56-05:00 Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian - - - - - 954de93a by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule haskeline to HEAD (to allow transformers-0.6) - - - - - cefbeec3 by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule transformers to 0.6.0.4 - - - - - b4730b62 by Bodigrim at 2022-12-21T06:17:56-05:00 Fix tests T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations Metric Increase: T13253 - - - - - 0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05: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. - - - - - df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00 rts: explicitly store return value of ccall checkClosure to prevent type error (#22617) - - - - - e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix shadowing lacuna in OccurAnal Issue #22623 demonstrated another lacuna in the implementation of wrinkle (BS3) in Note [The binder-swap substitution] in the occurrence analyser. I was failing to add TyVar lambda binders using addInScope/addOneInScope and that led to a totally bogus binder-swap transformation. Very easy to fix. - - - - - 3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix an assertion check in addToEqualCtList The old assertion saw that a constraint ct could rewrite itself (of course it can) and complained (stupid). Fixes #22645 - - - - - ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00 configure: Bump version to 9.6 - - - - - fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00 base: Bump version to 4.18 Requires various submodule bumps. - - - - - 93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00 ghc-boot: Fix bootstrapping - - - - - fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00 Bump GHC version to 9.7 - - - - - 914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05: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. - - - - - 32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00 hadrian bindist: Install manpages to share/man/man1/ghc.1 When the installation makefile was copied over the manpages were no longer installed in the correct place. Now we install it into share/man/man1/ghc.1 as the make build system did. Fixes #22371 - - - - - b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00 rts: Drop paths from configure from cabal file A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them. - - - - - b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00 Bump libffi-tarballs submodule We will now use libffi-3.4.4. - - - - - 3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00 EPA: Make EOF position part of AnnsModule Closes #20951 Closes #19697 - - - - - 99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00 JS: fix support for -outputdir (#22641) The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug. - - - - - 02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00 Refactor mkRuntimeError This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions. - - - - - 35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00 base: Fix event manager shutdown race on non-Linux platforms During shutdown it's possible that we will attempt to use a closed fd to wakeup another capability's event manager. On the Linux eventfd path we were careful to handle this. However on the non-Linux path we failed to do so. Fix this. - - - - - 317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00 Fix unifier bug: failing to decompose over-saturated type family This simple patch fixes #22647 - - - - - 14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00 rts/m32: Fix sanity checking Previously we would attempt to clear pages which were marked as read-only. Fix this. - - - - - 16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00 ci: Move wasm pipelines into nightly rather than master See #22664 for the changes which need to be made to bring one of these back to the validate pipeline. - - - - - 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-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). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Bodigrim at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - 541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - c9b108c6 by Vladislav Zavialov at 2023-01-06T12:06:25+03:00 WIP: Invisible binders in type declarations - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - compiler/CodeGen.Platform.h - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info/Build.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.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.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/CmmToAsm/Wasm.hs - compiler/GHC/CmmToAsm/Wasm/Asm.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4e16b559644efb6a7771d9ef56ac3cf898b20d07...c9b108c69f499e8df60fe8a161ad5fe67055edb5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4e16b559644efb6a7771d9ef56ac3cf898b20d07...c9b108c69f499e8df60fe8a161ad5fe67055edb5 You're receiving 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 Jan 6 13:06:21 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 06 Jan 2023 08:06:21 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: HsToken in TypeArg (#19623) Message-ID: <63b81ccd98999_f192a26c5c97c5103a5@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - 28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00 Add support for sized literals in the bytecode interpreter. The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945 - - - - - 6a592be4 by Matthew Pickering at 2023-01-06T08:06:15-05:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - 30 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Hs/Expr.hs - 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/StgToByteCode.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Match.hs-boot - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Utils/Outputable.hs - compiler/Language/Haskell/Syntax/Expr.hs - compiler/Language/Haskell/Syntax/Type.hs - configure.ac - distrib/configure.ac.in - + m4/fp_set_cflags_c99.m4 The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5748992a7480bb500eac10dde648c0c2fa760a43...6a592be40ef7315d995a090fd53f6d1b0183632c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5748992a7480bb500eac10dde648c0c2fa760a43...6a592be40ef7315d995a090fd53f6d1b0183632c You're receiving 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 Jan 6 13:12:37 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 06 Jan 2023 08:12:37 -0500 Subject: [Git][ghc/ghc][wip/t22599] darwin ci: Explicitly pass desired build triple to configure Message-ID: <63b81e45d657_f192a24acf41c5158a5@gitlab.mail> Matthew Pickering pushed to branch wip/t22599 at Glasgow Haskell Compiler / GHC Commits: 97dbbcc9 by Matthew Pickering at 2023-01-06T13:09:51+00:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 1 changed file: - .gitlab/darwin/toolchain.nix Changes: ===================================== .gitlab/darwin/toolchain.nix ===================================== @@ -113,6 +113,6 @@ pkgs.writeTextFile { export CABAL="$CABAL_INSTALL" sdk_path="$(xcrun --sdk macosx --show-sdk-path)" - export CONFIGURE_ARGS="$CONFIGURE_ARGS --with-ffi-libraries=$sdk_path/usr/lib --with-ffi-includes=$sdk_path/usr/include/ffi" + export CONFIGURE_ARGS="$CONFIGURE_ARGS --with-ffi-libraries=$sdk_path/usr/lib --with-ffi-includes=$sdk_path/usr/include/ffi --build=${targetTriple}" ''; } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97dbbcc947f2febb4a039d8d46afb07eab6a5f7f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97dbbcc947f2febb4a039d8d46afb07eab6a5f7f You're receiving 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 Jan 6 13:18:13 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Fri, 06 Jan 2023 08:18:13 -0500 Subject: [Git][ghc/ghc][wip/int-index/decl-invis-binders] 2 commits: WIP: Invisible binders in type declarations Message-ID: <63b81f95dafe1_f192a265243d051633f@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/decl-invis-binders at Glasgow Haskell Compiler / GHC Commits: 4c024382 by Vladislav Zavialov at 2023-01-06T15:50:37+03:00 WIP: Invisible binders in type declarations - - - - - ddfe2321 by Vladislav Zavialov at 2023-01-06T16:03:43+03:00 workaround: bump template-haskell - - - - - 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 - libraries/template-haskell/template-haskell.cabal.in - 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 The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c9b108c69f499e8df60fe8a161ad5fe67055edb5...ddfe2321bb4a0c5bfa2e1e502f01484d31247b54 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c9b108c69f499e8df60fe8a161ad5fe67055edb5...ddfe2321bb4a0c5bfa2e1e502f01484d31247b54 You're receiving 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 Jan 6 15:15:17 2023 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Fri, 06 Jan 2023 10:15:17 -0500 Subject: [Git][ghc/ghc][wip/req_smp] testsuite: req_host_smp --> req_ghc-smp Message-ID: <63b83b055cf52_f192a28ca3e60532110@gitlab.mail> doyougnu pushed to branch wip/req_smp at Glasgow Haskell Compiler / GHC Commits: 7bc02416 by doyougnu at 2023-01-06T10:14:49-05:00 testsuite: req_host_smp --> req_ghc-smp - - - - - 10 changed files: - testsuite/driver/testlib.py - testsuite/tests/codeGen/should_run/all.T - testsuite/tests/concurrent/should_run/all.T - testsuite/tests/driver/T14075/all.T - testsuite/tests/driver/T20030/test1/all.T - testsuite/tests/driver/j-space/all.T - testsuite/tests/driver/t22391/all.T - testsuite/tests/ffi/should_run/all.T - testsuite/tests/rts/all.T - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -296,7 +296,7 @@ def req_th( name, opts ): if ghc_dynamic(): return _omit_ways(name, opts, ['profasm', 'profthreaded']) -def req_host_smp( name, opts ): +def req_ghc_smp( name, opts ): """ Mark a test as requiring the host to be linked with an RTS that supports smp. Use this when the test needs to be compiled with smp support, but may ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -156,7 +156,7 @@ test('T10246', normal, compile_and_run, ['']) test('T9533', normal, compile_and_run, ['']) test('T9533b', normal, compile_and_run, ['']) test('T9533c', normal, compile_and_run, ['']) -test('T10414', [only_ways(['threaded2']), extra_ways(['threaded2']), req_target_smp, req_host_smp], +test('T10414', [only_ways(['threaded2']), extra_ways(['threaded2']), req_target_smp, req_ghc_smp], compile_and_run, ['-feager-blackholing']) test('T10521', normal, compile_and_run, ['']) test('T10521b', normal, compile_and_run, ['']) ===================================== testsuite/tests/concurrent/should_run/all.T ===================================== @@ -241,7 +241,7 @@ test('setnumcapabilities001', extra_run_opts('8 12 2000'), when(have_thread_sanitizer(), expect_broken(18808)), req_target_smp, - req_host_smp + req_ghc_smp ], compile_and_run, ['']) @@ -251,7 +251,7 @@ test('T21651', when(opsys('darwin'),extra_run_opts('8 12 2000 100')), unless(opsys('darwin'),extra_run_opts('8 12 2000 200')), # darwin runners complain of too many open files req_target_smp, - req_host_smp + req_ghc_smp ], compile_and_run, ['']) ===================================== testsuite/tests/driver/T14075/all.T ===================================== @@ -1,6 +1,6 @@ test('T14075', [ extra_files(['F.hs', 'F.hs-boot', 'O.hs', 'V.hs', 'V.hs-boot']) - , req_host_smp # uses ghc --make -j2 + , req_ghc_smp # uses ghc --make -j2 , js_broken(22261) ], makefile_test, []) ===================================== testsuite/tests/driver/T20030/test1/all.T ===================================== @@ -10,6 +10,6 @@ test('T20030_test1j', , 'D.hs' , 'E.hs-boot' , 'E.hs' , 'F.hs' , 'G.hs' , 'H.hs' , 'I.hs', 'J.hs-boot', 'J.hs', 'K.hs' ]) , req_target_smp - , req_host_smp + , req_ghc_smp ], multimod_compile, ['I.hs K.hs', '-v1 -j']) ===================================== testsuite/tests/driver/j-space/all.T ===================================== @@ -1 +1 @@ -test('jspace', [extra_files(['genJspace']), req_target_smp, req_host_smp], makefile_test, ['jspace']) +test('jspace', [extra_files(['genJspace']), req_target_smp, req_ghc_smp], makefile_test, ['jspace']) ===================================== testsuite/tests/driver/t22391/all.T ===================================== @@ -1,5 +1,5 @@ test('t22391', [extra_files(['src'])], multimod_compile, ['Lib', '-v1 -Wall -fhide-source-paths -isrc -fdefer-diagnostics']) -test('t22391j', [req_target_smp, req_host_smp, extra_files(['src'])], +test('t22391j', [req_target_smp, req_ghc_smp, extra_files(['src'])], multimod_compile, ['Lib', '-v1 -Wall -fhide-source-paths -isrc -fdefer-diagnostics -j2']) ===================================== testsuite/tests/ffi/should_run/all.T ===================================== @@ -235,7 +235,7 @@ test('T17471', [omit_ways(['ghci']), req_c], compile_and_run, ['T17471_c.c -optc-D -optcFOO']) test('IncallAffinity', - [req_target_smp, req_host_smp, only_ways(['threaded1', 'threaded2']), + [req_target_smp, req_ghc_smp, only_ways(['threaded1', 'threaded2']), # Unregisterised build doesn't support when(unregisterised(), skip), req_c], ===================================== testsuite/tests/rts/all.T ===================================== @@ -286,7 +286,7 @@ test('stablename001', expect_fail_for(['hpc']), compile_and_run, ['']) test('T7815', [ multi_cpu_race, extra_run_opts('50000 +RTS -N2 -RTS'), - req_target_smp, req_host_smp, + req_target_smp, req_ghc_smp, only_ways(['threaded1', 'threaded2']) ], compile_and_run, [''] ) # ignore_stderr because it contains a unique: @@ -305,10 +305,10 @@ test('T7919', [ when(fast(), skip) test('T8035', normal, compile_and_run, ['']) -test('T8209', [ req_target_smp, req_host_smp, only_ways(threaded_ways), ignore_stdout ], +test('T8209', [ req_target_smp, req_ghc_smp, only_ways(threaded_ways), ignore_stdout ], compile_and_run, ['']) -test('T8242', [ req_target_smp, req_host_smp, only_ways(threaded_ways), ignore_stdout ], +test('T8242', [ req_target_smp, req_ghc_smp, only_ways(threaded_ways), ignore_stdout ], compile_and_run, ['']) test('T8124', [ only_ways(threaded_ways), omit_ways(['ghci']), @@ -330,7 +330,7 @@ test('T9078', only_ways(['threaded1']), compile_and_run, ['']) test('T10017', [ when(opsys('mingw32'), skip) , when(unregisterised(), skip) , req_target_smp - , req_host_smp + , req_ghc_smp , only_ways(threaded_ways), extra_run_opts('+RTS -N2 -RTS') ], compile_and_run, ['']) test('T11108', normal, compile_and_run, ['']) @@ -403,7 +403,7 @@ test('T11788', [ when(ghc_dynamic(), skip) , req_interp ], makefile_test, ['T11788']) -test('T10296a', [req_host_smp], makefile_test, ['T10296a']) +test('T10296a', [req_ghc_smp], makefile_test, ['T10296a']) test('T10296b', [only_ways(['threaded2'])], compile_and_run, ['']) @@ -457,7 +457,7 @@ test('alloccounter1', js_broken(22261), compile_and_run, test('nursery-chunks1', [ extra_run_opts('4 100 +RTS -n32k -A1m -RTS') - , req_host_smp + , req_ghc_smp , req_target_smp , only_ways(['threaded1','threaded2']) ], ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -412,7 +412,7 @@ test('T11990a', normal, compile_fail, ['']) test('T11990b', normal, compile_fail, ['']) test('T12035', [], multimod_compile_fail, ['T12035', '-v0']) test('T12035j', [ extra_files(['T12035.hs', 'T12035a.hs', 'T12035.hs-boot']) - , req_host_smp + , req_ghc_smp , js_broken(22261) ], multimod_compile_fail, ['T12035', '-j2 -v0']) test('T12045b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7bc024169fb5c41a8d4508901b2f962af75dc445 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7bc024169fb5c41a8d4508901b2f962af75dc445 You're receiving 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 Jan 6 17:50:33 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 06 Jan 2023 12:50:33 -0500 Subject: [Git][ghc/ghc][wip/T20666] Add stuff for quantified constraints Message-ID: <63b85f69f2b4c_379b86526ac468a9@gitlab.mail> Simon Peyton Jones pushed to branch wip/T20666 at Glasgow Haskell Compiler / GHC Commits: 1e8add79 by Simon Peyton Jones at 2023-01-06T17:50:39+00:00 Add stuff for quantified constraints - - - - - 12 changed files: - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/InertSet.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types/Constraint.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcType.hs Changes: ===================================== compiler/GHC/Core/InstEnv.hs ===================================== @@ -232,10 +232,8 @@ pprInstances ispecs = vcat (map pprInstance ispecs) instanceHead :: ClsInst -> ([TyVar], Class, [Type]) -- Returns the head, using the fresh tyvars from the ClsInst -instanceHead (ClsInst { is_tvs = tvs, is_tys = tys, is_dfun = dfun }) +instanceHead (ClsInst { is_tvs = tvs, is_cls = cls, is_tys = tys }) = (tvs, cls, tys) - where - (_, _, cls, _) = tcSplitDFunTy (idType dfun) -- | Collects the names of concrete types and type constructors that make -- up the head of a class instance. For instance, given `class Foo a b`: ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -2691,7 +2691,7 @@ pprTcSolverReportMsg ctxt@(CEC {cec_encl = implics}) -- superclass constraints caught by the subtleties described by -- Note [Recursive superclasses] in GHC.TyCl.Instance naked_sc_fixes - | ScOrigin naked <- orig -- A superclass wanted + | ScOrigin _ naked <- orig -- A superclass wanted , naked -- No instance decls used yet , any non_tyvar_preds useful_givens -- Some non-tyvar givens = [vcat [ text "If the constraint looks soluble from a superclass of the instance context," ===================================== compiler/GHC/Tc/Solver/Canonical.hs ===================================== @@ -1,6 +1,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiWayIf #-} +{-# LANGUAGE RecursiveDo #-} module GHC.Tc.Solver.Canonical( canonicalize, @@ -600,8 +601,8 @@ mk_strict_superclasses rec_clss (CtGiven { ctev_evar = evar, ctev_loc = loc }) mk_sc_origin other_orig = pprPanic "Given constraint without given origin" $ ppr evar $$ ppr other_orig - newly_blocked (InstSkol head_size) = isJust (this_size `ltPatersonSize` head_size) - newly_blocked _ = False + newly_blocked (InstSkol _ head_size) = isJust (this_size `ltPatersonSize` head_size) + newly_blocked _ = False mk_strict_superclasses rec_clss ev tvs theta cls tys | all noFreeVarsOfType tys @@ -862,16 +863,26 @@ solveForAll ev@(CtWanted { ctev_dest = dest, ctev_rewriters = rewriters, ctev_lo -- This setLclEnv is important: the emitImplicationTcS uses that -- TcLclEnv for the implication, and that in turn sets the location -- for the Givens when solving the constraint (#21006) - do { skol_info <- mkSkolemInfo QuantCtxtSkol - ; let empty_subst = mkEmptySubst $ mkInScopeSet $ + do { let empty_subst = mkEmptySubst $ mkInScopeSet $ tyCoVarsOfTypes (pred:theta) `delVarSetList` tvs - ; (subst, skol_tvs) <- tcInstSkolTyVarsX skol_info empty_subst tvs - ; given_ev_vars <- mapM newEvVar (substTheta subst theta) + -- rec {..}: see Note [Keeping SkolemInfo inside a SkolemTv] + -- in GHC.Tc.Utils.TcType + -- Very like the code in tcSkolDFunType + ; rec { skol_info <- mkSkolemInfo skol_info_anon + ; (subst, skol_tvs) <- tcInstSkolTyVarsX skol_info empty_subst tvs + ; let inst_pred = substTy subst pred + inst_theta = substTheta subst theta + skol_info_anon = InstSkol IsQC (get_size inst_pred) } + + ; given_ev_vars <- mapM newEvVar inst_theta ; (lvl, (w_id, wanteds)) <- pushLevelNoWorkList (ppr skol_info) $ - do { wanted_ev <- newWantedEvVarNC loc rewriters $ - substTy subst pred + do { let loc' = setCtLocOrigin loc (ScOrigin IsQC False) + -- Set the thing to prove to have a ScOrigin, so we are + -- careful about its termination checks. + -- See (QC-INV) in Note [Solving a Wanted forall-constraint] + ; wanted_ev <- newWantedEvVarNC loc' rewriters inst_pred ; return ( ctEvEvId wanted_ev , unitBag (mkNonCanonical wanted_ev)) } @@ -883,6 +894,12 @@ solveForAll ev@(CtWanted { ctev_dest = dest, ctev_rewriters = rewriters, ctev_lo , et_binds = ev_binds, et_body = w_id } ; stopWith ev "Wanted forall-constraint" } + where + -- Getting the size of the head is a bit horrible + -- because of the special treament for class predicates + get_size pred = case classifyPredType pred of + ClassPred cls tys -> pSizeClassPred cls tys + _ -> pSizeType pred -- See Note [Solving a Given forall-constraint] solveForAll ev@(CtGiven {}) tvs _theta pred pend_sc @@ -903,6 +920,23 @@ and discharge df thus: where is filled in by solving the implication constraint. All the machinery is to hand; there is little to do. +The tricky point is about termination: see #19690. We want to maintain +the invariant (QC-INV): + + (QC-INV) Every quantified constraint returns a non-bottom dictionary + +just as every top-level instance declaration guarantees to return a non-bottom +dictionary. But as #19690 shows, it is possible to get a bottom dicionary +by superclass selection if we aren't careful. The situation is very similar +to that described in Note [Recursive superclasses] in GHC.Tc.TyCl.Instance; +and we use the same solution: + +* Give the Givens a CtOrigin of (GivenOrigin (InstSkol IsQC head_size)) +* Give the Wanted a CtOrigin of (ScOrigin IsQC False) + +Both of these things are done in solveForAll. Now the mechanism described +in Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance takes over. + Note [Solving a Given forall-constraint] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For a Given constraint ===================================== compiler/GHC/Tc/Solver/InertSet.hs ===================================== @@ -1639,7 +1639,7 @@ prohibitedSuperClassSolve :: CtLoc -- ^ is it loopy to use this one ... -- See Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance, (sc2) prohibitedSuperClassSolve given_loc wanted_loc | GivenSCOrigin _ _ blocked <- ctLocOrigin given_loc - , ScOrigin naked_sc <- ctLocOrigin wanted_loc + , ScOrigin _ naked_sc <- ctLocOrigin wanted_loc = naked_sc && blocked -- Prohibited if the Wanted is a superclass -- and the Given has come via a superclass selection from ===================================== compiler/GHC/Tc/Solver/Interact.hs ===================================== @@ -663,7 +663,10 @@ interactIrred inerts ct_w@(CIrredCan { cc_ev = ev_w, cc_reason = reason }) -- See Note [Multiple matching irreds] , let ev_i = ctEvidence ct_i = do { what_next <- solveOneFromTheOther ct_i ct_w - ; traceTcS "iteractIrred" (ppr ct_w $$ ppr what_next $$ ppr ct_i) + ; traceTcS "iteractIrred" $ + vcat [ text "wanted:" <+> (ppr ct_w $$ ppr (ctOrigin ct_w)) + , text "inert: " <+> (ppr ct_i $$ ppr (ctOrigin ct_i)) + , ppr what_next ] ; case what_next of KeepInert -> do { setEvBindIfWanted ev_w (swap_me swap ev_i) ; return (Stop ev_w (text "Irred equal" <+> parens (ppr what_next))) } @@ -2323,8 +2326,8 @@ checkInstanceOK loc what pred -- False, so that prohibitedSuperClassSolve never fires -- See Note [Solving superclass constraints] in -- GHC.Tc.TyCl.Instance, (sc1). - | ScOrigin {} <- origin - = setCtLocOrigin loc (ScOrigin False) + | ScOrigin what _ <- origin + = setCtLocOrigin loc (ScOrigin what False) | otherwise = loc ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -791,7 +791,11 @@ data TcSEnv } --------------- -newtype TcS a = TcS { unTcS :: TcSEnv -> TcM a } deriving (Functor) +newtype TcS a = TcS { unTcS :: TcSEnv -> TcM a } + deriving (Functor) + +instance MonadFix TcS where + mfix k = TcS $ \env -> mfix (\x -> unTcS (k x) env) -- | Smart constructor for 'TcS', as describe in Note [The one-shot state -- monad trick] in "GHC.Utils.Monad". ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -490,7 +490,7 @@ tcClsInstDecl (L loc (ClsInstDecl { cid_poly_ty = hs_ty, cid_binds = binds do { dfun_ty <- tcHsClsInstType (InstDeclCtxt False) hs_ty ; let (tyvars, theta, clas, inst_tys) = tcSplitDFunTy dfun_ty -- NB: tcHsClsInstType does checkValidInstance - ; skol_info <- mkSkolemInfo (mkInstSkol clas inst_tys) + ; skol_info <- mkSkolemInfo (mkClsInstSkol clas inst_tys) ; (subst, skol_tvs) <- tcInstSkolTyVars skol_info tyvars ; let tv_skol_prs = [ (tyVarName tv, skol_tv) | (tv, skol_tv) <- tyvars `zip` skol_tvs ] @@ -1232,7 +1232,7 @@ tcInstDecl2 (InstInfo { iSpec = ispec, iBinds = ibinds }) setSrcSpan loc $ addErrCtxt (instDeclCtxt2 dfun_ty) $ do { -- Instantiate the instance decl with skolem constants - (skol_info, inst_tyvars, dfun_theta, clas, inst_tys) <- tcSkolDFunType dfun_id + (skol_info, inst_tyvars, dfun_theta, clas, inst_tys) <- tcSkolDFunType dfun_ty ; dfun_ev_vars <- newEvVars dfun_theta ; let (class_tyvars, sc_theta, _, op_items) = classBigSig clas @@ -1457,8 +1457,9 @@ tcSuperClasses skol_info dfun_id cls tyvars dfun_evs dfun_ev_binds sc_theta loc = getSrcSpan dfun_id tc_super (sc_pred, n) = do { (sc_implic, ev_binds_var, sc_ev_tm) - <- checkInstConstraints skol_info $ emitWanted (ScOrigin True) sc_pred - -- ScOrigin True: see Note [Solving superclass constraints] + <- checkInstConstraints skol_info $ + emitWanted (ScOrigin IsClsInst True) sc_pred + -- ScOrigin IsClsInst True: see Note [Solving superclass constraints] ; sc_top_name <- newName (mkSuperDictAuxOcc n (getOccName cls)) ; sc_ev_id <- newEvVar sc_pred @@ -2388,9 +2389,9 @@ instDeclCtxt1 hs_inst_ty instDeclCtxt2 :: Type -> SDoc instDeclCtxt2 dfun_ty - = inst_decl_ctxt (ppr (mkClassPred cls tys)) + = inst_decl_ctxt (ppr head_ty) where - (_,_,cls,tys) = tcSplitDFunTy dfun_ty + (_,_,head_ty) = tcSplitQuantPredTy dfun_ty inst_decl_ctxt :: SDoc -> SDoc inst_decl_ctxt doc = hang (text "In the instance declaration for") ===================================== compiler/GHC/Tc/Types/Constraint.hs ===================================== @@ -1700,7 +1700,6 @@ checkSkolInfoAnon sk1 sk2 = go sk1 sk2 and (zipWith eq_pr ids1 ids2) go (UnifyForAllSkol t1) (UnifyForAllSkol t2) = t1 `tcEqType` t2 go ReifySkol ReifySkol = True - go QuantCtxtSkol QuantCtxtSkol = True go RuntimeUnkSkol RuntimeUnkSkol = True go ArrowReboundIfSkol ArrowReboundIfSkol = True go (UnkSkol _) (UnkSkol _) = True ===================================== compiler/GHC/Tc/Types/Origin.hs ===================================== @@ -13,7 +13,7 @@ module GHC.Tc.Types.Origin ( -- * SkolemInfo SkolemInfo(..), SkolemInfoAnon(..), mkSkolemInfo, getSkolemInfo, pprSigSkolInfo, pprSkolInfo, - unkSkol, unkSkolAnon, mkInstSkol, + unkSkol, unkSkolAnon, mkClsInstSkol, -- * CtOrigin CtOrigin(..), exprCtOrigin, lexprCtOrigin, matchesCtOrigin, grhssCtOrigin, @@ -28,7 +28,7 @@ module GHC.Tc.Types.Origin ( -- * FixedRuntimeRep origin FixedRuntimeRepOrigin(..), FixedRuntimeRepContext(..), pprFixedRuntimeRepContext, - StmtOrigin(..), RepPolyFun(..), ArgPos(..), + StmtOrigin(..), RepPolyFun(..), ArgPos(..), ClsInstOrQC(..), -- * Arrow command origin FRRArrowContext(..), pprFRRArrowContext, @@ -250,8 +250,9 @@ data SkolemInfoAnon | DerivSkol Type -- Bound by a 'deriving' clause; -- the type is the instance we are trying to derive - | InstSkol -- Bound at an instance decl - PatersonSize -- whose head has the given PatersonSize + | InstSkol -- Bound at an instance decl, or quantified constraint + ClsInstOrQC -- Whether class instance or quantified constraint + PatersonSize -- Head has the given PatersonSize | FamInstSkol -- Bound at a family instance decl | PatSkol -- An existential type variable bound by a pattern for @@ -283,9 +284,6 @@ data SkolemInfoAnon | ReifySkol -- Bound during Template Haskell reification - | QuantCtxtSkol -- Quantified context, e.g. - -- f :: forall c. (forall a. c a => c [a]) => blah - | RuntimeUnkSkol -- Runtime skolem from the GHCi debugger #14628 | ArrowReboundIfSkol -- Bound by the expected type of the rebound arrow ifThenElse command. @@ -315,8 +313,8 @@ mkSkolemInfo sk_anon = do getSkolemInfo :: SkolemInfo -> SkolemInfoAnon getSkolemInfo (SkolemInfo _ skol_anon) = skol_anon -mkInstSkol :: Class -> [Type] -> SkolemInfoAnon -mkInstSkol cls tys = InstSkol (pSizeClassPred cls tys) +mkClsInstSkol :: Class -> [Type] -> SkolemInfoAnon +mkClsInstSkol cls tys = InstSkol IsClsInst (pSizeClassPred cls tys) instance Outputable SkolemInfo where ppr (SkolemInfo _ sk_info ) = ppr sk_info @@ -332,7 +330,10 @@ pprSkolInfo (ForAllSkol tvs) = text "an explicit forall" <+> ppr tvs pprSkolInfo (IPSkol ips) = text "the implicit-parameter binding" <> plural ips <+> text "for" <+> pprWithCommas ppr ips pprSkolInfo (DerivSkol pred) = text "the deriving clause for" <+> quotes (ppr pred) -pprSkolInfo (InstSkol {}) = text "the instance declaration" +pprSkolInfo (InstSkol IsClsInst sz) = vcat [ text "the instance declaration" + , whenPprDebug (braces (ppr sz)) ] +pprSkolInfo (InstSkol IsQC sz) = vcat [ text "a quantified context" + , whenPprDebug (braces (ppr sz)) ] pprSkolInfo FamInstSkol = text "a family instance declaration" pprSkolInfo BracketSkol = text "a Template Haskell bracket" pprSkolInfo (RuleSkol name) = text "the RULE" <+> pprRuleName name @@ -346,7 +347,6 @@ pprSkolInfo (TyConSkol flav name) = text "the" <+> ppr flav <+> text "declaratio pprSkolInfo (DataConSkol name) = text "the type signature for" <+> quotes (ppr name) pprSkolInfo ReifySkol = text "the type being reified" -pprSkolInfo (QuantCtxtSkol {}) = text "a quantified context" pprSkolInfo RuntimeUnkSkol = text "Unknown type from GHCi runtime" pprSkolInfo ArrowReboundIfSkol = text "the expected type of a rebound if-then-else command" @@ -524,6 +524,7 @@ data CtOrigin -- | 'ScOrigin' is used only for the Wanted constraints for the -- superclasses of an instance declaration. | ScOrigin + ClsInstOrQC -- Whether class instance or quantified constraint Bool -- The boolean affects only GHC.Tc.Solver.InertSet.prohibitedSuperClassSolve -- * For the original superclass constraints we use (ScOrigin True) -- * But after using an instance declaration we use (ScOrigin False) @@ -596,6 +597,7 @@ data CtOrigin | CycleBreakerOrigin CtOrigin -- origin of the original constraint + -- See Detail (7) of Note [Type equality cycles] in GHC.Tc.Solver.Canonical | FRROrigin FixedRuntimeRepOrigin @@ -617,6 +619,8 @@ data CtOrigin -- like @sc_sel (sc_sel dg)@, where @dg@ is a Given. type ScDepth = Int +data ClsInstOrQC = IsClsInst | IsQC + -- An origin is visible if the place where the constraint arises is manifest -- in user code. Currently, all origins are visible except for invisible -- TypeEqOrigins. This is used when choosing which error of @@ -723,8 +727,12 @@ lGRHSCtOrigin _ = Shouldn'tHappenOrigin "multi-way GRHS" pprCtOrigin :: CtOrigin -> SDoc -- "arising from ..." -pprCtOrigin (GivenOrigin sk) = ctoHerald <+> ppr sk -pprCtOrigin (GivenSCOrigin sk _ _) = ctoHerald <+> pprSkolInfo sk +pprCtOrigin (GivenOrigin sk) + = ctoHerald <+> ppr sk + +pprCtOrigin (GivenSCOrigin sk d blk) + = vcat [ ctoHerald <+> pprSkolInfo sk + , whenPprDebug (braces (text "given-sc:" <+> ppr d <> comma <> ppr blk)) ] pprCtOrigin (SpecPragOrigin ctxt) = case ctxt of @@ -850,8 +858,10 @@ pprCtO (HasFieldOrigin f) = hsep [text "selecting the field", quotes (ppr f)] pprCtO AssocFamPatOrigin = text "the LHS of a family instance" pprCtO TupleOrigin = text "a tuple" pprCtO NegateOrigin = text "a use of syntactic negation" -pprCtO (ScOrigin n) = text "the superclasses of an instance declaration" - <> whenPprDebug (parens (ppr n)) +pprCtO (ScOrigin IsClsInst nkd) = vcat [ text "the superclasses of an instance declaration" + , whenPprDebug (braces (text "sc-origin:" <> ppr nkd)) ] +pprCtO (ScOrigin IsQC nkd) = vcat [ text "the head of a quantified constraint" + , whenPprDebug (braces (text "sc-origin:" <> ppr nkd)) ] pprCtO DerivClauseOrigin = text "the 'deriving' clause of a data type declaration" pprCtO StandAloneDerivOrigin = text "a 'deriving' declaration" pprCtO DefaultOrigin = text "a 'default' declaration" ===================================== compiler/GHC/Tc/Utils/Backpack.hs ===================================== @@ -34,6 +34,7 @@ import GHC.Types.Avail import GHC.Types.SrcLoc import GHC.Types.SourceFile import GHC.Types.Var +import GHC.Types.Id( idType ) import GHC.Types.Unique.DSet import GHC.Types.Name.Shape import GHC.Types.PkgQual @@ -228,7 +229,7 @@ check_inst sig_inst@(ClsInst { is_dfun = dfun_id }) = do -- Based off of 'simplifyDeriv' let origin = InstProvidedOrigin (tcg_semantic_mod tcg_env) sig_inst - (skol_info, tvs_skols, inst_theta, cls, inst_tys) <- tcSkolDFunType dfun_id + (skol_info, tvs_skols, inst_theta, cls, inst_tys) <- tcSkolDFunType (idType dfun_id) (tclvl,cts) <- pushTcLevelM $ do wanted <- newWanted origin (Just TypeLevel) (mkClassPred cls inst_tys) givens <- forM inst_theta $ \given -> do ===================================== compiler/GHC/Tc/Utils/Instantiate.hs ===================================== @@ -446,21 +446,21 @@ tcInstTypeBndrs poly_ty ; return (subst', Bndr tv' spec) } -------------------------- -tcSkolDFunType :: DFunId -> TcM (SkolemInfoAnon, [TcTyVar], TcThetaType, Class, [TcType]) +tcSkolDFunType :: Type -> TcM (SkolemInfoAnon, [TcTyVar], TcThetaType, Class, [TcType]) -- Instantiate a type signature with skolem constants. -- This freshens the names, but no need to do so -tcSkolDFunType dfun_id - = do { let (tvs, theta, cls, tys) = tcSplitDFunTy (idType dfun_id) +tcSkolDFunType dfun_ty + = do { let (tvs, theta, cls, tys) = tcSplitDFunTy dfun_ty -- rec {..}: see Note [Keeping SkolemInfo inside a SkolemTv] -- in GHC.Tc.Utils.TcType ; rec { skol_info <- mkSkolemInfo skol_info_anon ; (subst, inst_tvs) <- tcInstSuperSkolTyVars skol_info tvs - -- We instantiate the dfun_id with superSkolems. + -- We instantiate the dfun_tyd with superSkolems. -- See Note [Subtle interaction of recursion and overlap] -- and Note [Binding when looking up instances] ; let inst_tys = substTys subst tys - skol_info_anon = mkInstSkol cls inst_tys } + skol_info_anon = mkClsInstSkol cls inst_tys } ; let inst_theta = substTheta subst theta ; return (skol_info_anon, inst_tvs, inst_theta, cls, inst_tys) } ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -165,7 +165,7 @@ module GHC.Tc.Utils.TcType ( isClassPred, isEqPrimPred, isIPLikePred, isEqPred, isEqPredClass, mkClassPred, - tcSplitDFunTy, tcSplitDFunHead, tcSplitMethodTy, + tcSplitQuantPredTy, tcSplitDFunTy, tcSplitDFunHead, tcSplitMethodTy, isRuntimeRepVar, isFixedRuntimeRepKind, isVisiblePiTyBinder, isInvisiblePiTyBinder, @@ -1611,20 +1611,23 @@ tcIsTyVarTy (TyVarTy _) = True tcIsTyVarTy _ = False ----------------------- -tcSplitDFunTy :: Type -> ([TyVar], [Type], Class, [Type]) --- Split the type of a dictionary function --- We don't use tcSplitSigmaTy, because a DFun may (with NDP) --- have non-Pred arguments, such as --- df :: forall m. (forall b. Eq b => Eq (m b)) -> C m --- --- Also NB splitFunTys, not tcSplitFunTys; +tcSplitQuantPredTy :: Type -> ([TyVar], [Type], PredType) +-- Split up the type of a quantified predicate +-- forall tys, theta => head +-- NB splitFunTys, not tcSplitFunTys; -- the latter specifically stops at PredTy arguments, -- and we don't want to do that here -tcSplitDFunTy ty +tcSplitQuantPredTy ty = case tcSplitForAllInvisTyVars ty of { (tvs, rho) -> - case splitFunTys rho of { (theta, tau) -> - case tcSplitDFunHead tau of { (clas, tys) -> - (tvs, map scaledThing theta, clas, tys) }}} + case splitFunTys rho of { (theta, head) -> + (tvs, map scaledThing theta, head) }} + +tcSplitDFunTy :: Type -> ([TyVar], [Type], Class, [Type]) +-- Split the type of a dictionary function +tcSplitDFunTy ty + = case tcSplitQuantPredTy ty of { (tvs, theta, head) -> + case tcSplitDFunHead head of { (clas, tys) -> + (tvs, theta, clas, tys) }} tcSplitDFunHead :: Type -> (Class, [Type]) tcSplitDFunHead = getClassPredTys @@ -2452,7 +2455,7 @@ pSizeType = pSizeTypeX emptyVarSet pSizeTypes :: [Type] -> PatersonSize pSizeTypes = pSizeTypesX emptyVarSet pSizeZero --- Free variables of a type, retaining repetitions, and expanding synonyms +-- Paterson size of a type, retaining repetitions, and expanding synonyms -- This ignores coercions, as coercions aren't user-written pSizeTypeX :: VarSet -> Type -> PatersonSize pSizeTypeX bvs ty | Just exp_ty <- coreView ty = pSizeTypeX bvs exp_ty View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1e8add793017a235f0723a60be4cc605865fb688 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1e8add793017a235f0723a60be4cc605865fb688 You're receiving 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 Jan 6 18:46:50 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 06 Jan 2023 13:46:50 -0500 Subject: [Git][ghc/ghc][master] Add support for sized literals in the bytecode interpreter. Message-ID: <63b86c9a17b2e_379b8652738554e0@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00 Add support for sized literals in the bytecode interpreter. The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945 - - - - - 11 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/Utils/Outputable.hs - rts/Disassembler.c - rts/Interpreter.c - rts/include/rts/Bytecodes.h - + testsuite/tests/ghci/should_run/SizedLiterals.hs - + testsuite/tests/ghci/should_run/SizedLiterals.stdout - + testsuite/tests/ghci/should_run/SizedLiteralsA.hs - testsuite/tests/ghci/should_run/all.T Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -440,6 +440,38 @@ assembleI platform i = case i of emit bci_TESTLT_W [Op np, LabelOp l] TESTEQ_W w l -> do np <- word w emit bci_TESTEQ_W [Op np, LabelOp l] + TESTLT_I64 i l -> do np <- int64 i + emit bci_TESTLT_I64 [Op np, LabelOp l] + TESTEQ_I64 i l -> do np <- int64 i + emit bci_TESTEQ_I64 [Op np, LabelOp l] + TESTLT_I32 i l -> do np <- int (fromIntegral i) + emit bci_TESTLT_I32 [Op np, LabelOp l] + TESTEQ_I32 i l -> do np <- int (fromIntegral i) + emit bci_TESTEQ_I32 [Op np, LabelOp l] + TESTLT_I16 i l -> do np <- int (fromIntegral i) + emit bci_TESTLT_I16 [Op np, LabelOp l] + TESTEQ_I16 i l -> do np <- int (fromIntegral i) + emit bci_TESTEQ_I16 [Op np, LabelOp l] + TESTLT_I8 i l -> do np <- int (fromIntegral i) + emit bci_TESTLT_I8 [Op np, LabelOp l] + TESTEQ_I8 i l -> do np <- int (fromIntegral i) + emit bci_TESTEQ_I8 [Op np, LabelOp l] + TESTLT_W64 w l -> do np <- word64 w + emit bci_TESTLT_W64 [Op np, LabelOp l] + TESTEQ_W64 w l -> do np <- word64 w + emit bci_TESTEQ_W64 [Op np, LabelOp l] + TESTLT_W32 w l -> do np <- word (fromIntegral w) + emit bci_TESTLT_W32 [Op np, LabelOp l] + TESTEQ_W32 w l -> do np <- word (fromIntegral w) + emit bci_TESTEQ_W32 [Op np, LabelOp l] + TESTLT_W16 w l -> do np <- word (fromIntegral w) + emit bci_TESTLT_W16 [Op np, LabelOp l] + TESTEQ_W16 w l -> do np <- word (fromIntegral w) + emit bci_TESTEQ_W16 [Op np, LabelOp l] + TESTLT_W8 w l -> do np <- word (fromIntegral w) + emit bci_TESTLT_W8 [Op np, LabelOp l] + TESTEQ_W8 w l -> do np <- word (fromIntegral w) + emit bci_TESTEQ_W8 [Op np, LabelOp l] TESTLT_F f l -> do np <- float f emit bci_TESTLT_F [Op np, LabelOp l] TESTEQ_F f l -> do np <- float f @@ -505,6 +537,7 @@ assembleI platform i = case i of int16 = words . mkLitI64 platform int32 = words . mkLitI64 platform int64 = words . mkLitI64 platform + word64 = words . mkLitW64 platform words ws = lit (map BCONPtrWord ws) word w = words [w] @@ -590,6 +623,7 @@ mkLitI :: Int -> [Word] mkLitF :: Platform -> Float -> [Word] mkLitD :: Platform -> Double -> [Word] mkLitI64 :: Platform -> Int64 -> [Word] +mkLitW64 :: Platform -> Word64 -> [Word] mkLitF platform f = case platformWordSize platform of PW4 -> runST $ do @@ -636,13 +670,18 @@ mkLitI64 platform ii = case platformWordSize platform of w1 <- readArray d_arr 1 return [w0 :: Word,w1] ) - PW8 -> runST (do - arr <- newArray_ ((0::Int),0) - writeArray arr 0 ii + PW8 -> [fromIntegral ii :: Word] + +mkLitW64 platform ww = case platformWordSize platform of + PW4 -> runST (do + arr <- newArray_ ((0::Word),1) + writeArray arr 0 ww d_arr <- castSTUArray arr w0 <- readArray d_arr 0 - return [w0 :: Word] + w1 <- readArray d_arr 1 + return [w0 :: Word,w1] ) + PW8 -> [fromIntegral ww :: Word] mkLitI i = [fromIntegral i :: Word] ===================================== compiler/GHC/ByteCode/Instr.hs ===================================== @@ -24,7 +24,9 @@ import GHC.Core.DataCon import GHC.Builtin.PrimOps import GHC.Runtime.Heap.Layout +import Data.Int import Data.Word + import GHC.Stack.CCS (CostCentre) import GHC.Stg.Syntax @@ -141,6 +143,22 @@ data BCInstr | TESTEQ_I Int LocalLabel | TESTLT_W Word LocalLabel | TESTEQ_W Word LocalLabel + | TESTLT_I64 Int64 LocalLabel + | TESTEQ_I64 Int64 LocalLabel + | TESTLT_I32 Int32 LocalLabel + | TESTEQ_I32 Int32 LocalLabel + | TESTLT_I16 Int16 LocalLabel + | TESTEQ_I16 Int16 LocalLabel + | TESTLT_I8 Int8 LocalLabel + | TESTEQ_I8 Int16 LocalLabel + | TESTLT_W64 Word64 LocalLabel + | TESTEQ_W64 Word64 LocalLabel + | TESTLT_W32 Word32 LocalLabel + | TESTEQ_W32 Word32 LocalLabel + | TESTLT_W16 Word16 LocalLabel + | TESTEQ_W16 Word16 LocalLabel + | TESTLT_W8 Word8 LocalLabel + | TESTEQ_W8 Word8 LocalLabel | TESTLT_F Float LocalLabel | TESTEQ_F Float LocalLabel | TESTLT_D Double LocalLabel @@ -291,6 +309,22 @@ instance Outputable BCInstr where ppr (TESTEQ_I i lab) = text "TESTEQ_I" <+> int i <+> text "__" <> ppr lab ppr (TESTLT_W i lab) = text "TESTLT_W" <+> int (fromIntegral i) <+> text "__" <> ppr lab ppr (TESTEQ_W i lab) = text "TESTEQ_W" <+> int (fromIntegral i) <+> text "__" <> ppr lab + ppr (TESTLT_I64 i lab) = text "TESTLT_I64" <+> ppr i <+> text "__" <> ppr lab + ppr (TESTEQ_I64 i lab) = text "TESTEQ_I64" <+> ppr i <+> text "__" <> ppr lab + ppr (TESTLT_I32 i lab) = text "TESTLT_I32" <+> ppr i <+> text "__" <> ppr lab + ppr (TESTEQ_I32 i lab) = text "TESTEQ_I32" <+> ppr i <+> text "__" <> ppr lab + ppr (TESTLT_I16 i lab) = text "TESTLT_I16" <+> ppr i <+> text "__" <> ppr lab + ppr (TESTEQ_I16 i lab) = text "TESTEQ_I16" <+> ppr i <+> text "__" <> ppr lab + ppr (TESTLT_I8 i lab) = text "TESTLT_I8" <+> ppr i <+> text "__" <> ppr lab + ppr (TESTEQ_I8 i lab) = text "TESTEQ_I8" <+> ppr i <+> text "__" <> ppr lab + ppr (TESTLT_W64 i lab) = text "TESTLT_W64" <+> ppr i <+> text "__" <> ppr lab + ppr (TESTEQ_W64 i lab) = text "TESTEQ_W64" <+> ppr i <+> text "__" <> ppr lab + ppr (TESTLT_W32 i lab) = text "TESTLT_W32" <+> ppr i <+> text "__" <> ppr lab + ppr (TESTEQ_W32 i lab) = text "TESTEQ_W32" <+> ppr i <+> text "__" <> ppr lab + ppr (TESTLT_W16 i lab) = text "TESTLT_W16" <+> ppr i <+> text "__" <> ppr lab + ppr (TESTEQ_W16 i lab) = text "TESTEQ_W16" <+> ppr i <+> text "__" <> ppr lab + ppr (TESTLT_W8 i lab) = text "TESTLT_W8" <+> ppr i <+> text "__" <> ppr lab + ppr (TESTEQ_W8 i lab) = text "TESTEQ_W8" <+> ppr i <+> text "__" <> ppr lab ppr (TESTLT_F f lab) = text "TESTLT_F" <+> float f <+> text "__" <> ppr lab ppr (TESTEQ_F f lab) = text "TESTEQ_F" <+> float f <+> text "__" <> ppr lab ppr (TESTLT_D d lab) = text "TESTLT_D" <+> double d <+> text "__" <> ppr lab @@ -380,6 +414,22 @@ bciStackUse TESTLT_I{} = 0 bciStackUse TESTEQ_I{} = 0 bciStackUse TESTLT_W{} = 0 bciStackUse TESTEQ_W{} = 0 +bciStackUse TESTLT_I64{} = 0 +bciStackUse TESTEQ_I64{} = 0 +bciStackUse TESTLT_I32{} = 0 +bciStackUse TESTEQ_I32{} = 0 +bciStackUse TESTLT_I16{} = 0 +bciStackUse TESTEQ_I16{} = 0 +bciStackUse TESTLT_I8{} = 0 +bciStackUse TESTEQ_I8{} = 0 +bciStackUse TESTLT_W64{} = 0 +bciStackUse TESTEQ_W64{} = 0 +bciStackUse TESTLT_W32{} = 0 +bciStackUse TESTEQ_W32{} = 0 +bciStackUse TESTLT_W16{} = 0 +bciStackUse TESTEQ_W16{} = 0 +bciStackUse TESTLT_W8{} = 0 +bciStackUse TESTEQ_W8{} = 0 bciStackUse TESTLT_F{} = 0 bciStackUse TESTEQ_F{} = 0 bciStackUse TESTLT_D{} = 0 ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -936,12 +936,26 @@ doCase d s p scrut bndr alts | otherwise -> DiscrP (fromIntegral (dataConTag dc - fIRST_TAG)) LitAlt l -> case l of - LitNumber LitNumInt i -> DiscrI (fromInteger i) - LitNumber LitNumWord w -> DiscrW (fromInteger w) - LitFloat r -> DiscrF (fromRational r) - LitDouble r -> DiscrD (fromRational r) - LitChar i -> DiscrI (ord i) - _ -> pprPanic "schemeE(StgCase).my_discr" (ppr l) + LitNumber LitNumInt i -> DiscrI (fromInteger i) + LitNumber LitNumInt8 i -> DiscrI8 (fromInteger i) + LitNumber LitNumInt16 i -> DiscrI16 (fromInteger i) + LitNumber LitNumInt32 i -> DiscrI32 (fromInteger i) + LitNumber LitNumInt64 i -> DiscrI64 (fromInteger i) + LitNumber LitNumWord w -> DiscrW (fromInteger w) + LitNumber LitNumWord8 w -> DiscrW8 (fromInteger w) + LitNumber LitNumWord16 w -> DiscrW16 (fromInteger w) + LitNumber LitNumWord32 w -> DiscrW32 (fromInteger w) + LitNumber LitNumWord64 w -> DiscrW64 (fromInteger w) + LitNumber LitNumBigNat _ -> unsupported + LitFloat r -> DiscrF (fromRational r) + LitDouble r -> DiscrD (fromRational r) + LitChar i -> DiscrI (ord i) + LitString {} -> unsupported + LitRubbish {} -> unsupported + LitNullAddr {} -> unsupported + LitLabel {} -> unsupported + where + unsupported = pprPanic "schemeE(StgCase).my_discr:" (ppr l) maybe_ncons | not isAlgCase = Nothing @@ -1841,14 +1855,30 @@ mkMultiBranch maybe_ncons raw_ways = do notd_ways = sortBy (comparing fst) not_defaults testLT (DiscrI i) fail_label = TESTLT_I i fail_label + testLT (DiscrI8 i) fail_label = TESTLT_I8 (fromIntegral i) fail_label + testLT (DiscrI16 i) fail_label = TESTLT_I16 (fromIntegral i) fail_label + testLT (DiscrI32 i) fail_label = TESTLT_I32 (fromIntegral i) fail_label + testLT (DiscrI64 i) fail_label = TESTLT_I64 (fromIntegral i) fail_label testLT (DiscrW i) fail_label = TESTLT_W i fail_label + testLT (DiscrW8 i) fail_label = TESTLT_W8 (fromIntegral i) fail_label + testLT (DiscrW16 i) fail_label = TESTLT_W16 (fromIntegral i) fail_label + testLT (DiscrW32 i) fail_label = TESTLT_W32 (fromIntegral i) fail_label + testLT (DiscrW64 i) fail_label = TESTLT_W64 (fromIntegral i) fail_label testLT (DiscrF i) fail_label = TESTLT_F i fail_label testLT (DiscrD i) fail_label = TESTLT_D i fail_label testLT (DiscrP i) fail_label = TESTLT_P i fail_label testLT NoDiscr _ = panic "mkMultiBranch NoDiscr" testEQ (DiscrI i) fail_label = TESTEQ_I i fail_label + testEQ (DiscrI8 i) fail_label = TESTEQ_I8 (fromIntegral i) fail_label + testEQ (DiscrI16 i) fail_label = TESTEQ_I16 (fromIntegral i) fail_label + testEQ (DiscrI32 i) fail_label = TESTEQ_I32 (fromIntegral i) fail_label + testEQ (DiscrI64 i) fail_label = TESTEQ_I64 (fromIntegral i) fail_label testEQ (DiscrW i) fail_label = TESTEQ_W i fail_label + testEQ (DiscrW8 i) fail_label = TESTEQ_W8 (fromIntegral i) fail_label + testEQ (DiscrW16 i) fail_label = TESTEQ_W16 (fromIntegral i) fail_label + testEQ (DiscrW32 i) fail_label = TESTEQ_W32 (fromIntegral i) fail_label + testEQ (DiscrW64 i) fail_label = TESTEQ_W64 (fromIntegral i) fail_label testEQ (DiscrF i) fail_label = TESTEQ_F i fail_label testEQ (DiscrD i) fail_label = TESTEQ_D i fail_label testEQ (DiscrP i) fail_label = TESTEQ_P i fail_label @@ -1859,7 +1889,15 @@ mkMultiBranch maybe_ncons raw_ways = do [] -> panic "mkMultiBranch: awesome foursome" (discr, _):_ -> case discr of DiscrI _ -> ( DiscrI minBound, DiscrI maxBound ) + DiscrI8 _ -> ( DiscrI8 minBound, DiscrI8 maxBound ) + DiscrI16 _ -> ( DiscrI16 minBound, DiscrI16 maxBound ) + DiscrI32 _ -> ( DiscrI32 minBound, DiscrI32 maxBound ) + DiscrI64 _ -> ( DiscrI64 minBound, DiscrI64 maxBound ) DiscrW _ -> ( DiscrW minBound, DiscrW maxBound ) + DiscrW8 _ -> ( DiscrW8 minBound, DiscrW8 maxBound ) + DiscrW16 _ -> ( DiscrW16 minBound, DiscrW16 maxBound ) + DiscrW32 _ -> ( DiscrW32 minBound, DiscrW32 maxBound ) + DiscrW64 _ -> ( DiscrW64 minBound, DiscrW64 maxBound ) DiscrF _ -> ( DiscrF minF, DiscrF maxF ) DiscrD _ -> ( DiscrD minD, DiscrD maxD ) DiscrP _ -> ( DiscrP algMinBound, DiscrP algMaxBound ) @@ -1895,7 +1933,15 @@ mkMultiBranch maybe_ncons raw_ways = do -- Describes case alts data Discr = DiscrI Int + | DiscrI8 Int8 + | DiscrI16 Int16 + | DiscrI32 Int32 + | DiscrI64 Int64 | DiscrW Word + | DiscrW8 Word8 + | DiscrW16 Word16 + | DiscrW32 Word32 + | DiscrW64 Word64 | DiscrF Float | DiscrD Double | DiscrP Word16 @@ -1904,7 +1950,15 @@ data Discr instance Outputable Discr where ppr (DiscrI i) = int i + ppr (DiscrI8 i) = text (show i) + ppr (DiscrI16 i) = text (show i) + ppr (DiscrI32 i) = text (show i) + ppr (DiscrI64 i) = text (show i) ppr (DiscrW w) = text (show w) + ppr (DiscrW8 w) = text (show w) + ppr (DiscrW16 w) = text (show w) + ppr (DiscrW32 w) = text (show w) + ppr (DiscrW64 w) = text (show w) ppr (DiscrF f) = text (show f) ppr (DiscrD d) = text (show d) ppr (DiscrP i) = ppr i ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -896,6 +896,12 @@ instance Outputable Ordering where ppr EQ = text "EQ" ppr GT = text "GT" +instance Outputable Int8 where + ppr n = integer $ fromIntegral n + +instance Outputable Int16 where + ppr n = integer $ fromIntegral n + instance Outputable Int32 where ppr n = integer $ fromIntegral n @@ -908,6 +914,9 @@ instance Outputable Int where instance Outputable Integer where ppr n = integer n +instance Outputable Word8 where + ppr n = integer $ fromIntegral n + instance Outputable Word16 where ppr n = integer $ fromIntegral n ===================================== rts/Disassembler.c ===================================== @@ -254,26 +254,135 @@ disInstr ( StgBCO *bco, int pc ) debugBelch("TESTLT_I %" FMT_Int ", fail to %d\n", literals[discr], failto); break; } + + case bci_TESTLT_I64: { + unsigned int discr = BCO_NEXT; + int failto = BCO_GET_LARGE_ARG; + debugBelch("TESTLT_I64 %" FMT_Int64 ", fail to %d\n", *((StgInt64*)(literals+discr)), failto); + break; + } + + case bci_TESTLT_I32: { + unsigned int discr = BCO_NEXT; + int failto = BCO_GET_LARGE_ARG; + debugBelch("TESTLT_I32 %" FMT_Int ", fail to %d\n", literals[discr], failto); + break; + } + + case bci_TESTLT_I16: { + unsigned int discr = BCO_NEXT; + int failto = BCO_GET_LARGE_ARG; + debugBelch("TESTLT_I16 %" FMT_Int ", fail to %d\n", literals[discr], failto); + break; + } + + case bci_TESTLT_I8: { + unsigned int discr = BCO_NEXT; + int failto = BCO_GET_LARGE_ARG; + debugBelch("TESTLT_I8 %" FMT_Int ", fail to %d\n", literals[discr], failto); + break; + } + case bci_TESTEQ_I: debugBelch("TESTEQ_I %" FMT_Int ", fail to %d\n", literals[instrs[pc]], instrs[pc+1]); pc += 2; break; + case bci_TESTEQ_I64: + debugBelch("TESTEQ_I64 %" FMT_Int64 ", fail to %d\n", *((StgInt64*)(literals+instrs[pc])), + instrs[pc+1]); + pc += 2; break; + + case bci_TESTEQ_I32: + debugBelch("TESTEQ_I32 %" FMT_Int ", fail to %d\n", literals[instrs[pc]], + instrs[pc+1]); + pc += 2; break; + + case bci_TESTEQ_I16: + debugBelch("TESTEQ_I16 %" FMT_Int ", fail to %d\n", literals[instrs[pc]], + instrs[pc+1]); + pc += 2; break; + + case bci_TESTEQ_I8: + debugBelch("TESTEQ_I8 %" FMT_Int ", fail to %d\n", literals[instrs[pc]], + instrs[pc+1]); + pc += 2; break; + + case bci_TESTLT_W: { + unsigned int discr = BCO_NEXT; + int failto = BCO_GET_LARGE_ARG; + debugBelch("TESTLT_W %" FMT_Word ", fail to %d\n", literals[discr], failto); + break; + } + + case bci_TESTLT_W64: { + unsigned int discr = BCO_NEXT; + int failto = BCO_GET_LARGE_ARG; + debugBelch("TESTLT_W64 %" FMT_Word64 ", fail to %d\n", *((StgWord64*)(literals+discr)), failto); + break; + } + + case bci_TESTLT_W32: { + unsigned int discr = BCO_NEXT; + int failto = BCO_GET_LARGE_ARG; + debugBelch("TESTLT_W32 %" FMT_Word ", fail to %d\n", literals[discr], failto); + break; + } + + case bci_TESTLT_W16: { + unsigned int discr = BCO_NEXT; + int failto = BCO_GET_LARGE_ARG; + debugBelch("TESTLT_W16 %" FMT_Word ", fail to %d\n", literals[discr], failto); + break; + } + + case bci_TESTLT_W8: { + unsigned int discr = BCO_NEXT; + int failto = BCO_GET_LARGE_ARG; + debugBelch("TESTLT_W8 %" FMT_Word ", fail to %d\n", literals[discr], failto); + break; + } + + case bci_TESTEQ_W: + debugBelch("TESTEQ_W %" FMT_Word ", fail to %d\n", literals[instrs[pc]], + instrs[pc+1]); + pc += 2; break; + + case bci_TESTEQ_W64: + debugBelch("TESTEQ_W64 %" FMT_Word64 ", fail to %d\n", *((StgWord64*)(literals+instrs[pc])), + instrs[pc+1]); + pc += 2; break; + + case bci_TESTEQ_W32: + debugBelch("TESTEQ_W32 %" FMT_Word ", fail to %d\n", literals[instrs[pc]], + instrs[pc+1]); + pc += 2; break; + + case bci_TESTEQ_W16: + debugBelch("TESTEQ_W16 %" FMT_Word ", fail to %d\n", literals[instrs[pc]], + instrs[pc+1]); + pc += 2; break; + + case bci_TESTEQ_W8: + debugBelch("TESTEQ_W8 %" FMT_Word ", fail to %d\n", literals[instrs[pc]], + instrs[pc+1]); + pc += 2; break; + case bci_TESTLT_F: - debugBelch("TESTLT_F %" FMT_Int ", fail to %d\n", literals[instrs[pc]], + debugBelch("TESTLT_F %f, fail to %d\n", *((StgFloat*)literals+instrs[pc]), instrs[pc+1]); pc += 2; break; case bci_TESTEQ_F: - debugBelch("TESTEQ_F %" FMT_Int ", fail to %d\n", literals[instrs[pc]], + debugBelch("TESTEQ_F %f, fail to %d\n", *((StgFloat*)literals+instrs[pc]), instrs[pc+1]); pc += 2; break; case bci_TESTLT_D: - debugBelch("TESTLT_D %" FMT_Int ", fail to %d\n", literals[instrs[pc]], + debugBelch("TESTLT_D %f, fail to %d\n", *((StgDouble*)(literals+instrs[pc])), instrs[pc+1]); pc += 2; break; case bci_TESTEQ_D: - debugBelch("TESTEQ_D %" FMT_Int ", fail to %d\n", literals[instrs[pc]], + debugBelch("TESTEQ_D %f, fail to %d\n", *((StgDouble*)(literals+instrs[pc])), instrs[pc+1]); pc += 2; break; ===================================== rts/Interpreter.c ===================================== @@ -75,6 +75,8 @@ #define BCO_PTR(n) (W_)ptrs[n] #define BCO_LIT(n) literals[n] +#define BCO_LITW64(n) (*(StgWord64*)(literals+n)) +#define BCO_LITI64(n) (*(StgInt64*)(literals+n)) #define LOAD_STACK_POINTERS \ Sp = cap->r.rCurrentTSO->stackobj->sp; \ @@ -1728,6 +1730,46 @@ run_BCO: goto nextInsn; } + case bci_TESTLT_I64: { + // There should be an Int64 at SpW(1), and an info table at SpW(0). + int discr = BCO_GET_LARGE_ARG; + int failto = BCO_GET_LARGE_ARG; + StgInt64 stackInt = (*(StgInt64*)Sp_plusW(1)); + if (stackInt >= BCO_LITI64(discr)) + bciPtr = failto; + goto nextInsn; + } + + case bci_TESTLT_I32: { + // There should be an Int32 at SpW(1), and an info table at SpW(0). + int discr = BCO_GET_LARGE_ARG; + int failto = BCO_GET_LARGE_ARG; + StgInt32 stackInt = (*(StgInt32*)Sp_plusW(1)); + if (stackInt >= (StgInt32)BCO_LIT(discr)) + bciPtr = failto; + goto nextInsn; + } + + case bci_TESTLT_I16: { + // There should be an Int16 at SpW(1), and an info table at SpW(0). + int discr = BCO_GET_LARGE_ARG; + int failto = BCO_GET_LARGE_ARG; + StgInt16 stackInt = (*(StgInt16*)Sp_plusW(1)); + if (stackInt >= (StgInt16)BCO_LIT(discr)) + bciPtr = failto; + goto nextInsn; + } + + case bci_TESTLT_I8: { + // There should be an Int8 at SpW(1), and an info table at SpW(0). + int discr = BCO_GET_LARGE_ARG; + int failto = BCO_GET_LARGE_ARG; + StgInt8 stackInt = (*(StgInt8*)Sp_plusW(1)); + if (stackInt >= (StgInt8)BCO_LIT(discr)) + bciPtr = failto; + goto nextInsn; + } + case bci_TESTEQ_I: { // There should be an Int at SpW(1), and an info table at SpW(0). int discr = BCO_GET_LARGE_ARG; @@ -1739,8 +1781,52 @@ run_BCO: goto nextInsn; } + case bci_TESTEQ_I64: { + // There should be an Int64 at SpW(1), and an info table at SpW(0). + int discr = BCO_GET_LARGE_ARG; + int failto = BCO_GET_LARGE_ARG; + StgInt64 stackInt = (*(StgInt64*)Sp_plusW(1)); + if (stackInt != BCO_LITI64(discr)) { + bciPtr = failto; + } + goto nextInsn; + } + + case bci_TESTEQ_I32: { + // There should be an Int32 at SpW(1), and an info table at SpW(0). + int discr = BCO_GET_LARGE_ARG; + int failto = BCO_GET_LARGE_ARG; + StgInt32 stackInt = (*(StgInt32*)Sp_plusW(1)); + if (stackInt != (StgInt32)BCO_LIT(discr)) { + bciPtr = failto; + } + goto nextInsn; + } + + case bci_TESTEQ_I16: { + // There should be an Int16 at SpW(1), and an info table at SpW(0). + int discr = BCO_GET_LARGE_ARG; + int failto = BCO_GET_LARGE_ARG; + StgInt16 stackInt = (*(StgInt16*)Sp_plusW(1)); + if (stackInt != (StgInt16)BCO_LIT(discr)) { + bciPtr = failto; + } + goto nextInsn; + } + + case bci_TESTEQ_I8: { + // There should be an Int8 at SpW(1), and an info table at SpW(0). + int discr = BCO_GET_LARGE_ARG; + int failto = BCO_GET_LARGE_ARG; + StgInt8 stackInt = (*(StgInt8*)Sp_plusW(1)); + if (stackInt != (StgInt8)BCO_LIT(discr)) { + bciPtr = failto; + } + goto nextInsn; + } + case bci_TESTLT_W: { - // There should be an Int at SpW(1), and an info table at SpW(0). + // There should be a Word at SpW(1), and an info table at SpW(0). int discr = BCO_GET_LARGE_ARG; int failto = BCO_GET_LARGE_ARG; W_ stackWord = (W_)SpW(1); @@ -1749,8 +1835,48 @@ run_BCO: goto nextInsn; } + case bci_TESTLT_W64: { + // There should be a Word64 at SpW(1), and an info table at SpW(0). + int discr = BCO_GET_LARGE_ARG; + int failto = BCO_GET_LARGE_ARG; + StgWord64 stackWord = (*(StgWord64*)Sp_plusW(1)); + if (stackWord >= BCO_LITW64(discr)) + bciPtr = failto; + goto nextInsn; + } + + case bci_TESTLT_W32: { + // There should be a Word32 at SpW(1), and an info table at SpW(0). + int discr = BCO_GET_LARGE_ARG; + int failto = BCO_GET_LARGE_ARG; + StgWord32 stackWord = (*(StgWord32*)Sp_plusW(1)); + if (stackWord >= (StgWord32)BCO_LIT(discr)) + bciPtr = failto; + goto nextInsn; + } + + case bci_TESTLT_W16: { + // There should be a Word16 at SpW(1), and an info table at SpW(0). + int discr = BCO_GET_LARGE_ARG; + int failto = BCO_GET_LARGE_ARG; + StgWord16 stackWord = (*(StgWord16*)Sp_plusW(1)); + if (stackWord >= (StgWord16)BCO_LIT(discr)) + bciPtr = failto; + goto nextInsn; + } + + case bci_TESTLT_W8: { + // There should be a Word8 at SpW(1), and an info table at SpW(0). + int discr = BCO_GET_LARGE_ARG; + int failto = BCO_GET_LARGE_ARG; + StgWord8 stackWord = (*(StgWord8*)Sp_plusW(1)); + if (stackWord >= (StgWord8)BCO_LIT(discr)) + bciPtr = failto; + goto nextInsn; + } + case bci_TESTEQ_W: { - // There should be an Int at SpW(1), and an info table at SpW(0). + // There should be a Word at SpW(1), and an info table at SpW(0). int discr = BCO_GET_LARGE_ARG; int failto = BCO_GET_LARGE_ARG; W_ stackWord = (W_)SpW(1); @@ -1760,6 +1886,50 @@ run_BCO: goto nextInsn; } + case bci_TESTEQ_W64: { + // There should be a Word64 at SpW(1), and an info table at SpW(0). + int discr = BCO_GET_LARGE_ARG; + int failto = BCO_GET_LARGE_ARG; + StgWord64 stackWord = (*(StgWord64*)Sp_plusW(1)); + if (stackWord != BCO_LITW64(discr)) { + bciPtr = failto; + } + goto nextInsn; + } + + case bci_TESTEQ_W32: { + // There should be a Word32 at SpW(1), and an info table at SpW(0). + int discr = BCO_GET_LARGE_ARG; + int failto = BCO_GET_LARGE_ARG; + StgWord32 stackWord = (*(StgWord32*)Sp_plusW(1)); + if (stackWord != (StgWord32)BCO_LIT(discr)) { + bciPtr = failto; + } + goto nextInsn; + } + + case bci_TESTEQ_W16: { + // There should be a Word16 at SpW(1), and an info table at SpW(0). + int discr = BCO_GET_LARGE_ARG; + int failto = BCO_GET_LARGE_ARG; + StgWord16 stackWord = (*(StgWord16*)Sp_plusW(1)); + if (stackWord != (StgWord16)BCO_LIT(discr)) { + bciPtr = failto; + } + goto nextInsn; + } + + case bci_TESTEQ_W8: { + // There should be a Word8 at SpW(1), and an info table at SpW(0). + int discr = BCO_GET_LARGE_ARG; + int failto = BCO_GET_LARGE_ARG; + StgWord8 stackWord = (*(StgWord8*)Sp_plusW(1)); + if (stackWord != (StgWord8)BCO_LIT(discr)) { + bciPtr = failto; + } + goto nextInsn; + } + case bci_TESTLT_D: { // There should be a Double at SpW(1), and an info table at SpW(0). int discr = BCO_GET_LARGE_ARG; ===================================== rts/include/rts/Bytecodes.h ===================================== @@ -94,6 +94,24 @@ #define bci_RETURN_T 69 #define bci_PUSH_ALTS_T 70 + +#define bci_TESTLT_I64 71 +#define bci_TESTEQ_I64 72 +#define bci_TESTLT_I32 73 +#define bci_TESTEQ_I32 74 +#define bci_TESTLT_I16 75 +#define bci_TESTEQ_I16 76 +#define bci_TESTLT_I8 77 +#define bci_TESTEQ_I8 78 +#define bci_TESTLT_W64 79 +#define bci_TESTEQ_W64 80 +#define bci_TESTLT_W32 81 +#define bci_TESTEQ_W32 82 +#define bci_TESTLT_W16 83 +#define bci_TESTEQ_W16 84 +#define bci_TESTLT_W8 85 +#define bci_TESTEQ_W8 86 + /* If you need to go past 255 then you will run into the flags */ /* If you need to go below 0x0100 then you will run into the instructions */ ===================================== testsuite/tests/ghci/should_run/SizedLiterals.hs ===================================== @@ -0,0 +1,117 @@ +{-# LANGUAGE TemplateHaskell #-} + +import SizedLiteralsA +import Language.Haskell.TH + +{- + + This file is compiled with the GHC flags: + + -O -fbyte-code-and-object-code -fprefer-byte-code + + This makes sure that the Template Haskell runs in the bytecode + interpreter with optimized bytecode, allowing us to test the + sized unboxed literals. + + Running the test in GHCi directly would disable optimization. + + -} + +main :: IO () +main = do + print $(pure $ ListE [ ie (fibw8 5) + , ie (fibw16 5) + , ie (fibw32 5) + , ie (fibw64 5) + ]) + + print $(pure $ ListE [ ie (fibi8 5) + , ie (fibi16 5) + , ie (fibi32 5) + , ie (fibi64 5) + ]) + + print $(pure $ ListE [ ie (branchi8 0) + , ie (branchi8 1) + , ie (branchi8 (-1)) + , ie (branchi8 126) + , ie (branchi8 127) + , ie (branchi8 (-127)) + , ie (branchi8 (-128)) + , ie (branchi8 2) + ]) + + print $(pure $ ListE [ ie (branchi16 0) + , ie (branchi16 1) + , ie (branchi16 (-1)) + , ie (branchi16 32767) + , ie (branchi16 32766) + , ie (branchi16 (-32768)) + , ie (branchi16 (-32767)) + , ie (branchi16 2) + ]) + + print $(pure $ ListE [ ie (branchi32 0) + , ie (branchi32 1) + , ie (branchi32 (-1)) + , ie (branchi32 2147483646) + , ie (branchi32 2147483647) + , ie (branchi32 (-2147483648)) + , ie (branchi32 (-2147483647)) + , ie (branchi32 2) + ]) + + print $(pure $ ListE [ ie (branchi64 0) + , ie (branchi64 1) + , ie (branchi64 (-1)) + , ie (branchi64 2147483647) + , ie (branchi64 2147483648) + , ie (branchi64 4294967297) + , ie (branchi64 (-2147483648)) + , ie (branchi64 (-2147483649)) + , ie (branchi64 (-4294967295)) + , ie (branchi64 9223372036854775807) + , ie (branchi64 9223372036854775806) + , ie (branchi64 (-9223372036854775808)) + , ie (branchi64 (-9223372036854775807)) + , ie (branchi64 2) + ]) + + print $(pure $ ListE [ ie (branchw8 0) + , ie (branchw8 1) + , ie (branchw8 254) + , ie (branchw8 255) + , ie (branchw8 2) + ]) + + print $(pure $ ListE [ ie (branchw16 0) + , ie (branchw16 1) + , ie (branchw16 255) + , ie (branchw16 256) + , ie (branchw16 65534) + , ie (branchw16 65535) + , ie (branchw16 2) + ]) + + print $(pure $ ListE [ ie (branchw32 0) + , ie (branchw32 1) + , ie (branchw32 65534) + , ie (branchw32 65535) + , ie (branchw32 65536) + , ie (branchw32 4294967295) + , ie (branchw32 4294967294) + , ie (branchw32 4294967293) + , ie (branchw32 2) + ]) + + print $(pure $ ListE [ ie (branchw64 0) + , ie (branchw64 1) + , ie (branchw64 65536) + , ie (branchw64 4294967295) + , ie (branchw64 4294967296) + , ie (branchw64 4294967297) + , ie (branchw64 18446744073709551615) + , ie (branchw64 18446744073709551614) + , ie (branchw64 18446744073709551613) + , ie (branchw64 2) + ]) \ No newline at end of file ===================================== testsuite/tests/ghci/should_run/SizedLiterals.stdout ===================================== @@ -0,0 +1,10 @@ +[5,5,5,5] +[5,5,5,5] +[1,2,3,4,5,6,7,0] +[1,2,3,255,256,65534,65535,0] +[1,2,3,65535,65536,4294967294,4294967295,0] +[18446744073709551615,2147483648,4294967296,4294967297,9,1,18446744073709551614,3,4,5,6,7,8,0] +[1,-1,2,-2,0] +[256,-256,32767,-32768,-1,1,0] +[2147483647,-2147483648,65535,65536,-1,-65536,-65537,1,0] +[9223372036854775807,2147483648,4294967296,4294967297,-1,9223372036854775806,-9223372036854775808,-9223372036854775807,1,0] ===================================== testsuite/tests/ghci/should_run/SizedLiteralsA.hs ===================================== @@ -0,0 +1,139 @@ +module SizedLiteralsA where + +import GHC.Word +import GHC.Int +import Language.Haskell.TH.Syntax + +fibw8 :: Word8 -> Word8 +fibw8 0 = 0 +fibw8 1 = 1 +fibw8 n = fibw8 (n-1) + fibw8 (n-2) + +fibw16 :: Word16 -> Word16 +fibw16 0 = 0 +fibw16 1 = 1 +fibw16 n = fibw16 (n-1) + fibw16 (n-2) + +fibw32 :: Word32 -> Word32 +fibw32 0 = 0 +fibw32 1 = 1 +fibw32 n = fibw32 (n-1) + fibw32 (n-2) + +fibw64 :: Word64 -> Word64 +fibw64 0 = 0 +fibw64 1 = 1 +fibw64 n = fibw64 (n-1) + fibw64 (n-2) + +-- + +fibi8 :: Int8 -> Int8 +fibi8 0 = 0 +fibi8 1 = 1 +fibi8 n = fibi8 (n-1) + fibi8 (n-2) + +fibi16 :: Int16 -> Int16 +fibi16 0 = 0 +fibi16 1 = 1 +fibi16 n = fibi16 (n-1) + fibi16 (n-2) + +fibi32 :: Int32 -> Int32 +fibi32 0 = 0 +fibi32 1 = 1 +fibi32 n = fibi32 (n-1) + fibi32 (n-2) + +fibi64 :: Int64 -> Int64 +fibi64 0 = 0 +fibi64 1 = 1 +fibi64 n = fibi64 (n-1) + fibi64 (n-2) + +-- + +branchi8 :: Int8 -> Word8 +branchi8 0 = 1 +branchi8 1 = 2 +branchi8 (-1) = 3 +branchi8 126 = 4 +branchi8 127 = 5 +branchi8 (-127) = 6 +branchi8 (-128) = 7 +branchi8 _ = 0 + +branchi16 :: Int16 -> Word16 +branchi16 0 = 1 +branchi16 1 = 2 +branchi16 (-1) = 3 +branchi16 32767 = 255 +branchi16 32766 = 256 +branchi16 (-32768) = 65534 +branchi16 (-32767) = 65535 +branchi16 _ = 0 + +branchi32 :: Int32 -> Word32 +branchi32 0 = 1 +branchi32 1 = 2 +branchi32 (-1) = 3 +branchi32 2147483646 = 65535 +branchi32 2147483647 = 65536 +branchi32 (-2147483648) = 4294967294 +branchi32 (-2147483647) = 4294967295 +branchi32 _ = 0 + +branchi64 :: Int64 -> Word64 +branchi64 0 = 18446744073709551615 +branchi64 1 = 2147483648 +branchi64 (-1) = 4294967296 +branchi64 2147483647 = 4294967297 +branchi64 2147483648 = 9 +branchi64 4294967297 = 1 +branchi64 (-2147483648) = 18446744073709551614 +branchi64 (-2147483649) = 3 +branchi64 (-4294967295) = 4 +branchi64 9223372036854775807 = 5 +branchi64 9223372036854775806 = 6 +branchi64 (-9223372036854775808) = 7 +branchi64 (-9223372036854775807) = 8 +branchi64 _ = 0 + +branchw8 :: Word8 -> Int8 +branchw8 0 = 1 +branchw8 1 = (-1) +branchw8 254 = 2 +branchw8 255 = (-2) +branchw8 _ = 0 + +branchw16 :: Word16 -> Int16 +branchw16 0 = 256 +branchw16 1 = (-256) +branchw16 255 = 32767 +branchw16 256 = (-32768) +branchw16 65534 = (-1) +branchw16 65535 = 1 +branchw16 _ = 0 + +branchw32 :: Word32 -> Int32 +branchw32 0 = 2147483647 +branchw32 1 = (-2147483648) +branchw32 65534 = 65535 +branchw32 65535 = 65536 +branchw32 65536 = (-1) +branchw32 4294967295 = (-65536) +branchw32 4294967294 = (-65537) +branchw32 4294967293 = 1 +branchw32 _ = 0 + +branchw64 :: Word64 -> Int64 +branchw64 0 = 9223372036854775807 +branchw64 1 = 2147483648 +branchw64 65536 = 4294967296 +branchw64 4294967295 = 4294967297 +branchw64 4294967296 = (-1) +branchw64 4294967297 = 9223372036854775806 +branchw64 18446744073709551615 = (-9223372036854775808) +branchw64 18446744073709551614 = (-9223372036854775807) +branchw64 18446744073709551613 = 1 +branchw64 _ = 0 + +-- + +ie :: Integral a => a -> Exp +ie x = LitE (IntegerL (toInteger x)) ===================================== testsuite/tests/ghci/should_run/all.T ===================================== @@ -85,3 +85,5 @@ test('T19628', [extra_files(['T19628a.hs']), only_ways(['ghci']) ], compile_and_ test('T21052', just_ghci, ghci_script, ['T21052.script']) test('T21300', just_ghci, ghci_script, ['T21300.script']) test('UnliftedDataType2', just_ghci, compile_and_run, ['']) +test('SizedLiterals', [req_interp, extra_files(["SizedLiteralsA.hs"]),extra_hc_opts("-O -fbyte-code-and-object-code -fprefer-byte-code")], compile_and_run, ['']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/28f8c0ebbfe623784988745af75dcf3fdbdd3ca5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/28f8c0ebbfe623784988745af75dcf3fdbdd3ca5 You're receiving 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 Jan 6 18:47:36 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 06 Jan 2023 13:47:36 -0500 Subject: [Git][ghc/ghc][master] Only store Name in FunRhs rather than Id with knot-tied fields Message-ID: <63b86cc89c898_379b865281462510@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - 18 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Match.hs-boot - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/Language/Haskell/Syntax/Expr.hs - + testsuite/tests/ghci/scripts/T22695.script - + testsuite/tests/ghci/scripts/T22695.stderr - testsuite/tests/ghci/scripts/all.T - testsuite/tests/module/mod63.stderr - testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr - testsuite/tests/parser/should_fail/ParserNoBinaryLiterals1.stderr - testsuite/tests/rename/should_fail/rnfail045.stderr Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -2002,7 +2002,7 @@ matchSeparator ThPatSplice = panic "unused" matchSeparator ThPatQuote = panic "unused" matchSeparator PatSyn = panic "unused" -pprMatchContext :: (Outputable (IdP p), UnXRec p) +pprMatchContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContext ctxt | want_an ctxt = text "an" <+> pprMatchContextNoun ctxt @@ -2013,10 +2013,10 @@ pprMatchContext ctxt want_an (ArrowMatchCtxt KappaExpr) = True want_an _ = False -pprMatchContextNoun :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNoun :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNoun (FunRhs {mc_fun=fun}) = text "equation for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNoun CaseAlt = text "case alternative" pprMatchContextNoun (LamCaseAlt lc_variant) = lamCaseKeyword lc_variant <+> text "alternative" @@ -2032,10 +2032,10 @@ pprMatchContextNoun (StmtCtxt ctxt) = text "pattern binding in" $$ pprAStmtContext ctxt pprMatchContextNoun PatSyn = text "pattern synonym declaration" -pprMatchContextNouns :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNouns :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNouns (FunRhs {mc_fun=fun}) = text "equations for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNouns PatBindGuards = text "pattern binding guards" pprMatchContextNouns (ArrowMatchCtxt c) = pprArrowMatchContextNouns c pprMatchContextNouns (StmtCtxt ctxt) = text "pattern bindings in" @@ -2056,7 +2056,7 @@ pprArrowMatchContextNouns (ArrowLamCaseAlt lc_variant) = lamCaseKeyword lc_varia pprArrowMatchContextNouns ctxt = pprArrowMatchContextNoun ctxt <> char 's' ----------------- -pprAStmtContext, pprStmtContext :: (Outputable (IdP p), UnXRec p) +pprAStmtContext, pprStmtContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsStmtContext p -> SDoc pprAStmtContext (HsDoStmt flavour) = pprAHsDoFlavour flavour pprAStmtContext ctxt = text "a" <+> pprStmtContext ctxt ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -863,7 +863,7 @@ mkSimpleGeneratedFunBind loc fun pats expr emptyLocalBinds] -- | Make a prefix, non-strict function 'HsMatchContext' -mkPrefixFunRhs :: LIdP p -> HsMatchContext p +mkPrefixFunRhs :: LIdP (NoGhcTc p) -> HsMatchContext p mkPrefixFunRhs n = FunRhs { mc_fun = n , mc_fixity = Prefix , mc_strictness = NoSrcStrict } ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -957,7 +957,7 @@ instance HiePass p => ToHie (HsMatchContext (GhcPass p)) where name' :: LocatedN Name name' = case hiePass @p of HieRn -> name - HieTc -> fmap varName name + HieTc -> name toHie (StmtCtxt a) = toHie a toHie _ = pure [] ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -927,14 +927,10 @@ instance Diagnostic TcRnMessage where same_rec_group_msg = text "it is defined and used in the same recursive group" TcRnMatchesHaveDiffNumArgs argsContext (MatchArgMatches match1 bad_matches) -> mkSimpleDecorated $ - (vcat [ pprArgsContext argsContext <+> + (vcat [ pprMatchContextNouns argsContext <+> text "have different numbers of arguments" , nest 2 (ppr (getLocA match1)) , nest 2 (ppr (getLocA (NE.head bad_matches)))]) - where - pprArgsContext = \case - EquationArgs name -> (text "Equations for" <+>) . quotes $ ppr name - PatternArgs matchCtx -> pprMatchContextNouns matchCtx TcRnCannotBindScopedTyVarInPatSig sig_tvs -> mkSimpleDecorated $ hang (text "You cannot bind scoped type variable" ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2094,7 +2094,7 @@ data TcRnMessage where typecheck/should_fail/T20768_fail -} TcRnMatchesHaveDiffNumArgs - :: !MatchArgsContext + :: !(HsMatchContext GhcTc) -- ^ Pattern match specifics -> !MatchArgBadMatches -> TcRnMessage ===================================== compiler/GHC/Tc/Gen/Arrow.hs ===================================== @@ -172,7 +172,7 @@ tc_cmd env in_cmd@(HsCmdCase x scrut matches) (stk, res_ty) tc_cmd env cmd@(HsCmdLamCase x lc_variant match) cmd_ty = addErrCtxt (cmdCtxt cmd) do { let match_ctxt = ArrowLamCaseAlt lc_variant - ; checkPatCounts (ArrowMatchCtxt match_ctxt) match + ; checkArgCounts (ArrowMatchCtxt match_ctxt) match ; (wrap, match') <- tcCmdMatchLambda env match_ctxt match cmd_ty ; return (mkHsCmdWrap wrap (HsCmdLamCase x lc_variant match')) } ===================================== compiler/GHC/Tc/Gen/Bind.hs ===================================== @@ -624,7 +624,7 @@ tcPolyCheck prag_fn -- See Note [Relevant bindings and the binder stack] setSrcSpanA bind_loc $ - tcMatchesFun (L nm_loc mono_id) matches + tcMatchesFun (L nm_loc (idName mono_id)) matches (mkCheckExpType rho_ty) -- We make a funny AbsBinds, abstracting over nothing, @@ -1263,18 +1263,14 @@ tcMonoBinds is_rec sig_fn no_gen | NonRecursive <- is_rec -- ...binder isn't mentioned in RHS , Nothing <- sig_fn name -- ...with no type signature = setSrcSpanA b_loc $ - do { ((co_fn, matches'), mono_id, _) <- fixM $ \ ~(_, _, rhs_ty) -> - -- See Note [fixM for rhs_ty in tcMonoBinds] - do { mono_id <- newLetBndr no_gen name ManyTy rhs_ty - ; (matches', rhs_ty') - <- tcInfer $ \ exp_ty -> + do { ((co_fn, matches'), rhs_ty') + <- tcInfer $ \ exp_ty -> tcExtendBinderStack [TcIdBndr_ExpType name exp_ty NotTopLevel] $ -- We extend the error context even for a non-recursive -- function so that in type error messages we show the -- type of the thing whose rhs we are type checking - tcMatchesFun (L nm_loc mono_id) matches exp_ty - ; return (matches', mono_id, rhs_ty') - } + tcMatchesFun (L nm_loc name) matches exp_ty + ; mono_id <- newLetBndr no_gen name ManyTy rhs_ty' ; return (unitBag $ L b_loc $ FunBind { fun_id = L nm_loc mono_id, @@ -1388,19 +1384,6 @@ correctly elaborate 'id'. But we want to /infer/ q's higher rank type. There seems to be no way to do this. So currently we only switch to inference when we have no signature for any of the binders. -Note [fixM for rhs_ty in tcMonoBinds] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -In order to create mono_id we need rhs_ty but we don't have it yet, -we only get it from tcMatchesFun later (which needs mono_id to put -into HsMatchContext for pretty printing). To solve this, create -a thunk of rhs_ty with fixM that we fill in later. - -This is fine only because neither newLetBndr or tcMatchesFun look -at the varType field of the Id. tcMatchesFun only looks at idName -of mono_id. - -Also see #20415 for the bigger picture of why tcMatchesFun needs -mono_id in the first place. -} @@ -1528,7 +1511,7 @@ tcRhs (TcFunBind info@(MBI { mbi_sig = mb_sig, mbi_mono_id = mono_id }) = tcExtendIdBinderStackForRhs [info] $ tcExtendTyVarEnvForRhs mb_sig $ do { traceTc "tcRhs: fun bind" (ppr mono_id $$ ppr (idType mono_id)) - ; (co_fn, matches') <- tcMatchesFun (L (noAnnSrcSpan loc) mono_id) + ; (co_fn, matches') <- tcMatchesFun (L (noAnnSrcSpan loc) (idName mono_id)) matches (mkCheckExpType $ idType mono_id) ; return ( FunBind { fun_id = L (noAnnSrcSpan loc) mono_id , fun_matches = matches' ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -31,7 +31,7 @@ module GHC.Tc.Gen.Match , tcBody , tcDoStmt , tcGuardStmt - , checkPatCounts + , checkArgCounts ) where @@ -93,12 +93,12 @@ is used in error messages. It checks that all the equations have the same number of arguments before using @tcMatches@ to do the work. -} -tcMatchesFun :: LocatedN Id -- MatchContext Id +tcMatchesFun :: LocatedN Name -- MatchContext Id -> MatchGroup GhcRn (LHsExpr GhcRn) -> ExpRhoType -- Expected type of function -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) -- Returns type of body -tcMatchesFun fun_id matches exp_ty +tcMatchesFun fun_name matches exp_ty = do { -- Check that they all have the same no of arguments -- Location is in the monad, set the caller so that -- any inter-equation error messages get some vaguely @@ -106,9 +106,7 @@ tcMatchesFun fun_id matches exp_ty -- ann-grabbing, because we don't always have annotations in -- hand when we call tcMatchesFun... traceTc "tcMatchesFun" (ppr fun_name $$ ppr exp_ty) - -- We can't easily call checkPatCounts here because fun_id can be an - -- unfilled thunk - ; checkArgCounts fun_name matches + ; checkArgCounts what matches ; matchExpectedFunTys herald ctxt arity exp_ty $ \ pat_tys rhs_ty -> -- NB: exp_type may be polymorphic, but @@ -122,17 +120,11 @@ tcMatchesFun fun_id matches exp_ty -- a multiplicity argument, and scale accordingly. tcMatches match_ctxt pat_tys rhs_ty matches } where - fun_name = idName (unLoc fun_id) arity = matchGroupArity matches - herald = ExpectedFunTyMatches (NameThing fun_name) matches + herald = ExpectedFunTyMatches (NameThing (unLoc fun_name)) matches ctxt = GenSigCtxt -- Was: FunSigCtxt fun_name True -- But that's wrong for f :: Int -> forall a. blah - what = FunRhs { mc_fun = fun_id, mc_fixity = Prefix, mc_strictness = strictness } - -- Careful: this fun_id could be an unfilled - -- thunk from fixM in tcMonoBinds, so we're - -- not allowed to look at it, except for - -- idName. - -- See Note [fixM for rhs_ty in tcMonoBinds] + what = FunRhs { mc_fun = fun_name, mc_fixity = Prefix, mc_strictness = strictness } match_ctxt = MC { mc_what = what, mc_body = tcBody } strictness | [L _ match] <- unLoc $ mg_alts matches @@ -164,7 +156,7 @@ tcMatchLambda :: ExpectedFunTyOrigin -- see Note [Herald for matchExpectedFunTys -> ExpRhoType -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) tcMatchLambda herald match_ctxt match res_ty - = do { checkPatCounts (mc_what match_ctxt) match + = do { checkArgCounts (mc_what match_ctxt) match ; matchExpectedFunTys herald GenSigCtxt n_pats res_ty $ \ pat_tys rhs_ty -> do -- checking argument counts since this is also used for \cases tcMatches match_ctxt pat_tys rhs_ty match } @@ -1136,28 +1128,16 @@ the variables they bind into scope, and typecheck the thing_inside. \subsection{Errors and contexts} * * ************************************************************************ - - at checkArgCounts@ takes a @[RenamedMatch]@ and decides whether the same -number of args are used in each equation. -} +-- | @checkArgCounts@ takes a @[RenamedMatch]@ and decides whether the same +-- number of args are used in each equation. checkArgCounts :: AnnoBody body - => Name -> MatchGroup GhcRn (LocatedA (body GhcRn)) -> TcM () -checkArgCounts = check_match_pats . EquationArgs - --- @checkPatCounts@ takes a @[RenamedMatch]@ and decides whether the same --- number of patterns are used in each alternative -checkPatCounts :: AnnoBody body - => HsMatchContext GhcTc -> MatchGroup GhcRn (LocatedA (body GhcRn)) - -> TcM () -checkPatCounts = check_match_pats . PatternArgs - -check_match_pats :: AnnoBody body - => MatchArgsContext -> MatchGroup GhcRn (LocatedA (body GhcRn)) - -> TcM () -check_match_pats _ (MG { mg_alts = L _ [] }) + => HsMatchContext GhcTc -> MatchGroup GhcRn (LocatedA (body GhcRn)) + -> TcM () +checkArgCounts _ (MG { mg_alts = L _ [] }) = return () -check_match_pats matchContext (MG { mg_alts = L _ (match1:matches) }) +checkArgCounts matchContext (MG { mg_alts = L _ (match1:matches) }) | Just bad_matches <- mb_bad_matches = failWithTc $ TcRnMatchesHaveDiffNumArgs matchContext $ MatchArgMatches match1 bad_matches ===================================== compiler/GHC/Tc/Gen/Match.hs-boot ===================================== @@ -5,13 +5,13 @@ import GHC.Tc.Utils.TcType( ExpSigmaType, ExpRhoType ) import GHC.Tc.Types ( TcM ) import GHC.Hs.Extension ( GhcRn, GhcTc ) import GHC.Parser.Annotation ( LocatedN ) -import GHC.Types.Id (Id) +import GHC.Types.Name (Name) tcGRHSsPat :: GRHSs GhcRn (LHsExpr GhcRn) -> ExpRhoType -> TcM (GRHSs GhcTc (LHsExpr GhcTc)) -tcMatchesFun :: LocatedN Id +tcMatchesFun :: LocatedN Name -> MatchGroup GhcRn (LHsExpr GhcRn) -> ExpSigmaType -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -838,7 +838,7 @@ tcPatSynMatcher (L loc ps_name) lpat prag_fn args body] , mg_ext = MatchGroupTc (map unrestricted [pat_ty, cont_ty, fail_ty]) res_ty Generated } - match = mkMatch (mkPrefixFunRhs (L loc patsyn_id)) [] + match = mkMatch (mkPrefixFunRhs (L loc (idName patsyn_id))) [] (mkHsLams (rr_tv:res_tv:univ_tvs) req_dicts body') (EmptyLocalBinds noExtField) ===================================== compiler/Language/Haskell/Syntax/Expr.hs ===================================== @@ -1533,7 +1533,10 @@ data HsMatchContext p = FunRhs -- ^ A pattern matching on an argument of a -- function binding - { mc_fun :: LIdP p -- ^ function binder of @f@ + { mc_fun :: LIdP (NoGhcTc p) -- ^ function binder of @f@ + -- See Note [mc_fun field of FunRhs] + -- See #20415 for a long discussion about + -- this field and why it uses NoGhcTc. , mc_fixity :: LexicalFixity -- ^ fixing of @f@ , mc_strictness :: SrcStrictness -- ^ was @f@ banged? -- See Note [FunBind vs PatBind] @@ -1560,6 +1563,21 @@ data HsMatchContext p | ThPatQuote -- ^A Template Haskell pattern quotation [p| (a,b) |] | PatSyn -- ^A pattern synonym declaration +{- +Note [mc_fun field of FunRhs] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The mc_fun field of FunRhs has type `LIdP (NoGhcTc p)`, which means it will be +a `RdrName` in pass `GhcPs`, a `Name` in `GhcRn`, and (importantly) still a +`Name` in `GhcTc` -- not an `Id`. See Note [NoGhcTc] in GHC.Hs.Extension. + +Why a `Name` in the typechecker phase? Because: +* A `Name` is all we need, as it turns out. +* Using an `Id` involves knot-tying in the monad, which led to #22695. + +See #20415 for a long discussion. + +-} + isPatSynCtxt :: HsMatchContext p -> Bool isPatSynCtxt ctxt = case ctxt of ===================================== testsuite/tests/ghci/scripts/T22695.script ===================================== @@ -0,0 +1 @@ +test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/T22695.stderr ===================================== @@ -0,0 +1,8 @@ + +:1:10: error: + • The constructor ‘Just’ should have 1 argument, but has been given none + • In the pattern: Just + In a stmt of a pattern guard for + an equation for ‘test’: + Just <- x + In an equation for ‘test’: test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -370,3 +370,4 @@ test('T21110', [extra_files(['T21110A.hs'])], ghci_script, test('T17830', [filter_stdout_lines(r'======.*')], ghci_script, ['T17830.script']) test('T21294a', normal, ghci_script, ['T21294a.script']) test('T21507', normal, ghci_script, ['T21507.script']) +test('T22695', normal, ghci_script, ['T22695.script']) ===================================== testsuite/tests/module/mod63.stderr ===================================== @@ -1,5 +1,5 @@ mod63.hs:3:1: error: [GHC-91938] - Equations for ‘f’ have different numbers of arguments + equations for ‘f’ have different numbers of arguments mod63.hs:3:1-8 mod63.hs:4:1-11 ===================================== testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr ===================================== @@ -1560,7 +1560,7 @@ (FunRhs (L (SrcSpanAnn (EpAnnNotUsed) { DumpTypecheckedAst.hs:19:1-4 }) - {Var: main}) + {Name: main}) (Prefix) (NoSrcStrict)) [] ===================================== testsuite/tests/parser/should_fail/ParserNoBinaryLiterals1.stderr ===================================== @@ -1,5 +1,5 @@ ParserNoBinaryLiterals1.hs:5:1: error: [GHC-91938] - Equations for ‘f’ have different numbers of arguments + equations for ‘f’ have different numbers of arguments ParserNoBinaryLiterals1.hs:5:1-10 ParserNoBinaryLiterals1.hs:6:1-10 ===================================== testsuite/tests/rename/should_fail/rnfail045.stderr ===================================== @@ -1,10 +1,10 @@ rnfail045.hs:5:1: error: [GHC-91938] - Equations for ‘op1’ have different numbers of arguments + equations for ‘op1’ have different numbers of arguments rnfail045.hs:5:1-16 rnfail045.hs:6:1-13 rnfail045.hs:8:1: error: [GHC-91938] - Equations for ‘op2’ have different numbers of arguments + equations for ‘op2’ have different numbers of arguments rnfail045.hs:8:1-13 rnfail045.hs:9:1-16 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ac39e8e97fbb69e4a786c1c29d6e477e7944f998 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ac39e8e97fbb69e4a786c1c29d6e477e7944f998 You're receiving 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 Jan 6 19:32:58 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 06 Jan 2023 14:32:58 -0500 Subject: [Git][ghc/ghc][ghc-9.6] 33 commits: Don't consider large byte arrays/compact regions pinned. Message-ID: <63b8776a988ee_379b86528286696b@gitlab.mail> Matthew Pickering pushed to branch ghc-9.6 at Glasgow Haskell Compiler / GHC Commits: 611e686b by Andreas Klebinger at 2023-01-06T15:12:40+00: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. (cherry picked from commit 914f7fe3756734714a6795fc4bbca96442b01f92) - - - - - d98db93c by Ben Gamari at 2023-01-06T15:21:48+00:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. (cherry picked from commit 18d2acd2791a751c0b1894fd72dd0317583619cd) - - - - - a169f7a8 by Ben Gamari at 2023-01-06T15:21:48+00:00 nonmoving: Fix segment list races (cherry picked from commit 11241efa3422fae97aed0abb1857baab2f9018fb) - - - - - d276bb54 by Ben Gamari at 2023-01-06T15:21:48+00:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. (cherry picked from commit 602455c9ae6e5a2746f43b1811bb3c54efb0a6f5) - - - - - 63525f89 by Ben Gamari at 2023-01-06T15:21:48+00: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. (cherry picked from commit 9d63b160287eb8edfe7ab0b1715f21c1b831bfa5) - - - - - e91352e2 by Ben Gamari at 2023-01-06T15:21:48+00:00 nonmoving: Ensure that mutable fields have acquire barrier (cherry picked from commit 26837523f5a9cdb33a206f8b22eea88ef75c874b) - - - - - 84bb3747 by Ben Gamari at 2023-01-06T15:21:48+00: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. (cherry picked from commit 8093264a448940133fc2f1899bab8757eabe4b85) - - - - - 5922a583 by Ben Gamari at 2023-01-06T15:21:48+00:00 nonmoving: Make segment state updates atomic (cherry picked from commit 387d4fcc29441098d41340c12e56d9693b5e4c94) - - - - - d6eb8ba1 by Ben Gamari at 2023-01-06T15:21:48+00: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. (cherry picked from commit 543cae0084a72ca767a443d857f9e65a5a79f71d) - - - - - 40317135 by Ben Gamari at 2023-01-06T15:21:48+00:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. (cherry picked from commit c99367180e49d903f8be649bfdc11e95649c7d1a) - - - - - d86a40bc by Ben Gamari at 2023-01-06T15:21:48+00: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. (cherry picked from commit 0cd31f7d2c8baea0489770c765a7b8dd5c79679f) - - - - - ce02950d by Ben Gamari at 2023-01-06T15:21:48+00: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. (cherry picked from commit d3fe110aaf7c40c5a4b2ff460abe33ee7fac6d93) - - - - - 98ec2167 by Ben Gamari at 2023-01-06T15:21:48+00: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. (cherry picked from commit ab6cf893037f073fd3daf619579c84e58362b499) - - - - - 61f96bb4 by Ben Gamari at 2023-01-06T15:21:48+00:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). (cherry picked from commit 36c9f23c9dc52928b5d2971f38f6e0b15e38528e) - - - - - 4af109cf by Ben Gamari at 2023-01-06T15:25:59+00: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). - - - - - a5118fc5 by Ben Gamari at 2023-01-06T15:28:08+00:00 Bump libffi-tarballs submodule We will now use libffi-3.4.4. (cherry picked from commit b2c7523d8987bedf13a7dd682d836ffb76cbe09d) - - - - - 42ea9cea by Sylvain Henry at 2023-01-06T15:28:38+00:00 JS: fix support for -outputdir (#22641) The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug. (cherry picked from commit 99757ce8e32d9809c71b09583aa881943a450086) - - - - - b11a4111 by Matthew Pickering at 2023-01-06T15:29:29+00:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 (cherry picked from commit b2a2db04b24a4654261db8e0db6ad7bac1b3d7cf) - - - - - 246176a0 by Ben Gamari at 2023-01-06T15:32:27+00:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. (cherry picked from commit 6d7d4393e15a6d0a2b42ec986ec6bd3df27baaa7) - - - - - 15014bce by Matthew Pickering at 2023-01-06T15:32:32+00: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. (cherry picked from commit 32255d055b768d51deb9d1f49681164cf7492011) - - - - - 0561d8f2 by Matthew Pickering at 2023-01-06T15:32:32+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b (cherry picked from commit e640940c55a88d10537682baf530f3772e55459a) - - - - - c45ce0f1 by Matthew Pickering at 2023-01-06T15:32:32+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 (cherry picked from commit 15bee1239877a4629a245fe457f06e5f96668423) - - - - - 123adfba by Matthew Pickering at 2023-01-06T15:32:32+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. (cherry picked from commit fec6638e2468c78f136f2363d8b3239a9bfd4f91) - - - - - 6fad57b3 by Matthew Pickering at 2023-01-06T15:32:32+00:00 check-exact: Fix build with -Werror (cherry picked from commit 3dc05726dca7e38ca8de8e1175c8f1489b96653e) - - - - - 2bfb6270 by Matthew Pickering at 2023-01-06T15:32:32+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 (cherry picked from commit 53a6ae7a8f819d1105aa190dc9cce215cdbcc6dc) - - - - - a9bcd226 by Matthew Pickering at 2023-01-06T15:32:32+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 (cherry picked from commit 32e264c1a11e6356bb045371b87a3736df19e792) - - - - - be78e321 by Matthew Pickering at 2023-01-06T15:36:14+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 (cherry picked from commit be9dd9b03479070ba6387c251541f4569392c4bb) - - - - - 81e37370 by Matthew Pickering at 2023-01-06T15:38:30+00:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 (cherry picked from commit 00dc51060881df81258ba3b3bdf447294618a4de) - - - - - a7d72a7c by Zubin Duggal at 2023-01-06T15:38:42+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. (cherry picked from commit 62b9a7b23b20f5cf0a2de14251c2096098009f10) - - - - - 86133736 by Matthew Pickering at 2023-01-06T15:39:01+00:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 (cherry picked from commit 6d62f6bfbb5a86131e7cbc30993f3fa510d8b3ab) - - - - - fd285b98 by Simon Peyton Jones at 2023-01-06T15:40:45+00:00 Fix unifier bug: failing to decompose over-saturated type family This simple patch fixes #22647 (cherry picked from commit 317f45c154f6fe25d50ef2f3febcc5883ff1b1ca) - - - - - 6378106a by Simon Peyton Jones at 2023-01-06T15:40:56+00:00 Refactor mkRuntimeError This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions. (cherry picked from commit 02ed7d783244bd95ee897825650426de6f5fb3e2) - - - - - d5985060 by Matthew Pickering at 2023-01-06T15:41:20+00:00 hadrian bindist: Install manpages to share/man/man1/ghc.1 When the installation makefile was copied over the manpages were no longer installed in the correct place. Now we install it into share/man/man1/ghc.1 as the make build system did. Fixes #22371 (cherry picked from commit 32b32d7fbc5544ad6c435a1ea26e6353ec567a9b) - - - - - 30 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/Core/Make.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/EnumSet.hs - compiler/GHC/Driver/Flags.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/Hs/Doc.hs - compiler/GHC/Hs/DocString.hs - compiler/GHC/HsToCore/Pmc/Solver.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/Tc/Errors.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ad8f5f60407b57747c66c59643dd714e52617020...d5985060ed1c136073ae82e98261b47ff6a48bc1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ad8f5f60407b57747c66c59643dd714e52617020...d5985060ed1c136073ae82e98261b47ff6a48bc1 You're receiving 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 Jan 6 20:25:53 2023 From: gitlab at gitlab.haskell.org (access (@project_1_bot3)) Date: Fri, 06 Jan 2023 15:25:53 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/darwin-fixes-mp Message-ID: <63b883d1bf2b5_c35a15512c416e2@gitlab.mail> access pushed new branch wip/darwin-fixes-mp at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/darwin-fixes-mp You're receiving 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 Jan 6 20:32:57 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 06 Jan 2023 15:32:57 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/darwin-fixes-2 Message-ID: <63b88579472b9_c35a15510442083@gitlab.mail> Matthew Pickering pushed new branch wip/darwin-fixes-2 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/darwin-fixes-2 You're receiving 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 Jan 6 20:36:17 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 06 Jan 2023 15:36:17 -0500 Subject: [Git][ghc/ghc][wip/darwin-fixes-2] debugging: Get ld version from from CI runners *ninja* Message-ID: <63b886413e93f_c35a1542b84392d@gitlab.mail> Matthew Pickering pushed to branch wip/darwin-fixes-2 at Glasgow Haskell Compiler / GHC Commits: 4081f8db by Matthew Pickering at 2023-01-06T20:35:56+00:00 debugging: Get ld version from from CI runners *ninja* - - - - - 1 changed file: - .gitlab/ci.sh Changes: ===================================== .gitlab/ci.sh ===================================== @@ -216,6 +216,7 @@ function set_toolchain_paths() { nix build -f .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh cat toolchain.sh fi + ld -v source toolchain.sh ;; env) # These are generally set by the Docker image but View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4081f8db14722b5c88f1e84627eb4d81f26997bf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4081f8db14722b5c88f1e84627eb4d81f26997bf You're receiving 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 Jan 6 21:18:41 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 06 Jan 2023 16:18:41 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Only store Name in FunRhs rather than Id with knot-tied fields Message-ID: <63b89031b920_c35a1550f056277@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - 9b1dd02a by Matthew Pickering at 2023-01-06T16:18:26-05:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 24633a6f by Matthew Pickering at 2023-01-06T16:18:26-05:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 1f4b9155 by Ben Gamari at 2023-01-06T16:18:26-05:00 rts: MUT_VAR is not a StgMutArrPtrs There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs. - - - - - 23 changed files: - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Match.hs-boot - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/Language/Haskell/Syntax/Expr.hs - rts/include/rts/storage/Closures.h - + testsuite/tests/ghci/scripts/T22695.script - + testsuite/tests/ghci/scripts/T22695.stderr - testsuite/tests/ghci/scripts/all.T - testsuite/tests/module/mod63.stderr - testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr - testsuite/tests/parser/should_fail/ParserNoBinaryLiterals1.stderr - testsuite/tests/rename/should_fail/rnfail045.stderr Changes: ===================================== .gitlab/ci.sh ===================================== @@ -213,10 +213,14 @@ function set_toolchain_paths() { x86_64-darwin|aarch64-darwin) ;; *) fail "unknown NIX_SYSTEM" ;; esac - nix build -f .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh + info "Building toolchain for $NIX_SYSTEM" + nix-build .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh cat toolchain.sh fi - source toolchain.sh ;; + source toolchain.sh + info "--info for GHC for $NIX_SYSTEM" + $GHC --info + ;; env) # These are generally set by the Docker image but # we provide these handy fallbacks in case the @@ -320,7 +324,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 = [ @@ -38,6 +38,21 @@ let ]; buildPhase = "true"; + # This is a horrible hack because the configure script invokes /usr/bin/clang + # without a `--target` flag. Then depending on whether the `nix` binary itself is + # a native x86 or arm64 binary means that /usr/bin/clang thinks it needs to run in + # x86 or arm64 mode. + + # The correct answer for the check in question is the first one we try, so by replacing + # the condition to true; we select the right C++ standard library still. + preConfigure = '' + sed "s/\"\$CC\" -o actest actest.o \''${1} 2>\/dev\/null/true/i" configure > configure.new + mv configure.new configure + chmod +x configure + cat configure + + ''; + # N.B. Work around #20253. nativeBuildInputs = [ pkgs.gnused ]; postInstallPhase = '' @@ -98,6 +113,6 @@ pkgs.writeTextFile { export CABAL="$CABAL_INSTALL" sdk_path="$(xcrun --sdk macosx --show-sdk-path)" - export CONFIGURE_ARGS="$CONFIGURE_ARGS --with-ffi-libraries=$sdk_path/usr/lib --with-ffi-includes=$sdk_path/usr/include/ffi" + export CONFIGURE_ARGS="$CONFIGURE_ARGS --with-ffi-libraries=$sdk_path/usr/lib --with-ffi-includes=$sdk_path/usr/include/ffi --build=${targetTriple}" ''; } ===================================== .gitlab/gen_ci.hs ===================================== @@ -349,8 +349,8 @@ 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" - , "CABAL_INSTALL_VERSION" =: "3.6.2.0" + , "GHC_VERSION" =: "9.4.3" + , "CABAL_INSTALL_VERSION" =: "3.8.1.0" ] opsysVariables _ (Linux distro) = distroVariables distro opsysVariables AArch64 (Darwin {}) = @@ -378,8 +378,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 ===================================== @@ -594,9 +594,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.6.2.0", + "CABAL_INSTALL_VERSION": "3.8.1.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" @@ -1793,9 +1793,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", @@ -1852,9 +1852,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", @@ -2225,9 +2225,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-release", "BUILD_FLAVOUR": "release", - "CABAL_INSTALL_VERSION": "3.6.2.0", + "CABAL_INSTALL_VERSION": "3.8.1.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", @@ -2957,9 +2957,9 @@ "BIGNUM_BACKEND": "native", "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", + "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", @@ -3017,9 +3017,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-release+no_split_sections", "BUILD_FLAVOUR": "release+no_split_sections", - "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", @@ -3145,9 +3145,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.6.2.0", + "CABAL_INSTALL_VERSION": "3.8.1.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" } @@ -4326,9 +4326,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", @@ -4384,9 +4384,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", ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -2002,7 +2002,7 @@ matchSeparator ThPatSplice = panic "unused" matchSeparator ThPatQuote = panic "unused" matchSeparator PatSyn = panic "unused" -pprMatchContext :: (Outputable (IdP p), UnXRec p) +pprMatchContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContext ctxt | want_an ctxt = text "an" <+> pprMatchContextNoun ctxt @@ -2013,10 +2013,10 @@ pprMatchContext ctxt want_an (ArrowMatchCtxt KappaExpr) = True want_an _ = False -pprMatchContextNoun :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNoun :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNoun (FunRhs {mc_fun=fun}) = text "equation for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNoun CaseAlt = text "case alternative" pprMatchContextNoun (LamCaseAlt lc_variant) = lamCaseKeyword lc_variant <+> text "alternative" @@ -2032,10 +2032,10 @@ pprMatchContextNoun (StmtCtxt ctxt) = text "pattern binding in" $$ pprAStmtContext ctxt pprMatchContextNoun PatSyn = text "pattern synonym declaration" -pprMatchContextNouns :: forall p. (Outputable (IdP p), UnXRec p) +pprMatchContextNouns :: forall p. (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsMatchContext p -> SDoc pprMatchContextNouns (FunRhs {mc_fun=fun}) = text "equations for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr (unXRec @(NoGhcTc p) fun)) pprMatchContextNouns PatBindGuards = text "pattern binding guards" pprMatchContextNouns (ArrowMatchCtxt c) = pprArrowMatchContextNouns c pprMatchContextNouns (StmtCtxt ctxt) = text "pattern bindings in" @@ -2056,7 +2056,7 @@ pprArrowMatchContextNouns (ArrowLamCaseAlt lc_variant) = lamCaseKeyword lc_varia pprArrowMatchContextNouns ctxt = pprArrowMatchContextNoun ctxt <> char 's' ----------------- -pprAStmtContext, pprStmtContext :: (Outputable (IdP p), UnXRec p) +pprAStmtContext, pprStmtContext :: (Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) => HsStmtContext p -> SDoc pprAStmtContext (HsDoStmt flavour) = pprAHsDoFlavour flavour pprAStmtContext ctxt = text "a" <+> pprStmtContext ctxt ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -863,7 +863,7 @@ mkSimpleGeneratedFunBind loc fun pats expr emptyLocalBinds] -- | Make a prefix, non-strict function 'HsMatchContext' -mkPrefixFunRhs :: LIdP p -> HsMatchContext p +mkPrefixFunRhs :: LIdP (NoGhcTc p) -> HsMatchContext p mkPrefixFunRhs n = FunRhs { mc_fun = n , mc_fixity = Prefix , mc_strictness = NoSrcStrict } ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -957,7 +957,7 @@ instance HiePass p => ToHie (HsMatchContext (GhcPass p)) where name' :: LocatedN Name name' = case hiePass @p of HieRn -> name - HieTc -> fmap varName name + HieTc -> name toHie (StmtCtxt a) = toHie a toHie _ = pure [] ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -927,14 +927,10 @@ instance Diagnostic TcRnMessage where same_rec_group_msg = text "it is defined and used in the same recursive group" TcRnMatchesHaveDiffNumArgs argsContext (MatchArgMatches match1 bad_matches) -> mkSimpleDecorated $ - (vcat [ pprArgsContext argsContext <+> + (vcat [ pprMatchContextNouns argsContext <+> text "have different numbers of arguments" , nest 2 (ppr (getLocA match1)) , nest 2 (ppr (getLocA (NE.head bad_matches)))]) - where - pprArgsContext = \case - EquationArgs name -> (text "Equations for" <+>) . quotes $ ppr name - PatternArgs matchCtx -> pprMatchContextNouns matchCtx TcRnCannotBindScopedTyVarInPatSig sig_tvs -> mkSimpleDecorated $ hang (text "You cannot bind scoped type variable" ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2094,7 +2094,7 @@ data TcRnMessage where typecheck/should_fail/T20768_fail -} TcRnMatchesHaveDiffNumArgs - :: !MatchArgsContext + :: !(HsMatchContext GhcTc) -- ^ Pattern match specifics -> !MatchArgBadMatches -> TcRnMessage ===================================== compiler/GHC/Tc/Gen/Arrow.hs ===================================== @@ -172,7 +172,7 @@ tc_cmd env in_cmd@(HsCmdCase x scrut matches) (stk, res_ty) tc_cmd env cmd@(HsCmdLamCase x lc_variant match) cmd_ty = addErrCtxt (cmdCtxt cmd) do { let match_ctxt = ArrowLamCaseAlt lc_variant - ; checkPatCounts (ArrowMatchCtxt match_ctxt) match + ; checkArgCounts (ArrowMatchCtxt match_ctxt) match ; (wrap, match') <- tcCmdMatchLambda env match_ctxt match cmd_ty ; return (mkHsCmdWrap wrap (HsCmdLamCase x lc_variant match')) } ===================================== compiler/GHC/Tc/Gen/Bind.hs ===================================== @@ -624,7 +624,7 @@ tcPolyCheck prag_fn -- See Note [Relevant bindings and the binder stack] setSrcSpanA bind_loc $ - tcMatchesFun (L nm_loc mono_id) matches + tcMatchesFun (L nm_loc (idName mono_id)) matches (mkCheckExpType rho_ty) -- We make a funny AbsBinds, abstracting over nothing, @@ -1263,18 +1263,14 @@ tcMonoBinds is_rec sig_fn no_gen | NonRecursive <- is_rec -- ...binder isn't mentioned in RHS , Nothing <- sig_fn name -- ...with no type signature = setSrcSpanA b_loc $ - do { ((co_fn, matches'), mono_id, _) <- fixM $ \ ~(_, _, rhs_ty) -> - -- See Note [fixM for rhs_ty in tcMonoBinds] - do { mono_id <- newLetBndr no_gen name ManyTy rhs_ty - ; (matches', rhs_ty') - <- tcInfer $ \ exp_ty -> + do { ((co_fn, matches'), rhs_ty') + <- tcInfer $ \ exp_ty -> tcExtendBinderStack [TcIdBndr_ExpType name exp_ty NotTopLevel] $ -- We extend the error context even for a non-recursive -- function so that in type error messages we show the -- type of the thing whose rhs we are type checking - tcMatchesFun (L nm_loc mono_id) matches exp_ty - ; return (matches', mono_id, rhs_ty') - } + tcMatchesFun (L nm_loc name) matches exp_ty + ; mono_id <- newLetBndr no_gen name ManyTy rhs_ty' ; return (unitBag $ L b_loc $ FunBind { fun_id = L nm_loc mono_id, @@ -1388,19 +1384,6 @@ correctly elaborate 'id'. But we want to /infer/ q's higher rank type. There seems to be no way to do this. So currently we only switch to inference when we have no signature for any of the binders. -Note [fixM for rhs_ty in tcMonoBinds] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -In order to create mono_id we need rhs_ty but we don't have it yet, -we only get it from tcMatchesFun later (which needs mono_id to put -into HsMatchContext for pretty printing). To solve this, create -a thunk of rhs_ty with fixM that we fill in later. - -This is fine only because neither newLetBndr or tcMatchesFun look -at the varType field of the Id. tcMatchesFun only looks at idName -of mono_id. - -Also see #20415 for the bigger picture of why tcMatchesFun needs -mono_id in the first place. -} @@ -1528,7 +1511,7 @@ tcRhs (TcFunBind info@(MBI { mbi_sig = mb_sig, mbi_mono_id = mono_id }) = tcExtendIdBinderStackForRhs [info] $ tcExtendTyVarEnvForRhs mb_sig $ do { traceTc "tcRhs: fun bind" (ppr mono_id $$ ppr (idType mono_id)) - ; (co_fn, matches') <- tcMatchesFun (L (noAnnSrcSpan loc) mono_id) + ; (co_fn, matches') <- tcMatchesFun (L (noAnnSrcSpan loc) (idName mono_id)) matches (mkCheckExpType $ idType mono_id) ; return ( FunBind { fun_id = L (noAnnSrcSpan loc) mono_id , fun_matches = matches' ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -31,7 +31,7 @@ module GHC.Tc.Gen.Match , tcBody , tcDoStmt , tcGuardStmt - , checkPatCounts + , checkArgCounts ) where @@ -93,12 +93,12 @@ is used in error messages. It checks that all the equations have the same number of arguments before using @tcMatches@ to do the work. -} -tcMatchesFun :: LocatedN Id -- MatchContext Id +tcMatchesFun :: LocatedN Name -- MatchContext Id -> MatchGroup GhcRn (LHsExpr GhcRn) -> ExpRhoType -- Expected type of function -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) -- Returns type of body -tcMatchesFun fun_id matches exp_ty +tcMatchesFun fun_name matches exp_ty = do { -- Check that they all have the same no of arguments -- Location is in the monad, set the caller so that -- any inter-equation error messages get some vaguely @@ -106,9 +106,7 @@ tcMatchesFun fun_id matches exp_ty -- ann-grabbing, because we don't always have annotations in -- hand when we call tcMatchesFun... traceTc "tcMatchesFun" (ppr fun_name $$ ppr exp_ty) - -- We can't easily call checkPatCounts here because fun_id can be an - -- unfilled thunk - ; checkArgCounts fun_name matches + ; checkArgCounts what matches ; matchExpectedFunTys herald ctxt arity exp_ty $ \ pat_tys rhs_ty -> -- NB: exp_type may be polymorphic, but @@ -122,17 +120,11 @@ tcMatchesFun fun_id matches exp_ty -- a multiplicity argument, and scale accordingly. tcMatches match_ctxt pat_tys rhs_ty matches } where - fun_name = idName (unLoc fun_id) arity = matchGroupArity matches - herald = ExpectedFunTyMatches (NameThing fun_name) matches + herald = ExpectedFunTyMatches (NameThing (unLoc fun_name)) matches ctxt = GenSigCtxt -- Was: FunSigCtxt fun_name True -- But that's wrong for f :: Int -> forall a. blah - what = FunRhs { mc_fun = fun_id, mc_fixity = Prefix, mc_strictness = strictness } - -- Careful: this fun_id could be an unfilled - -- thunk from fixM in tcMonoBinds, so we're - -- not allowed to look at it, except for - -- idName. - -- See Note [fixM for rhs_ty in tcMonoBinds] + what = FunRhs { mc_fun = fun_name, mc_fixity = Prefix, mc_strictness = strictness } match_ctxt = MC { mc_what = what, mc_body = tcBody } strictness | [L _ match] <- unLoc $ mg_alts matches @@ -164,7 +156,7 @@ tcMatchLambda :: ExpectedFunTyOrigin -- see Note [Herald for matchExpectedFunTys -> ExpRhoType -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) tcMatchLambda herald match_ctxt match res_ty - = do { checkPatCounts (mc_what match_ctxt) match + = do { checkArgCounts (mc_what match_ctxt) match ; matchExpectedFunTys herald GenSigCtxt n_pats res_ty $ \ pat_tys rhs_ty -> do -- checking argument counts since this is also used for \cases tcMatches match_ctxt pat_tys rhs_ty match } @@ -1136,28 +1128,16 @@ the variables they bind into scope, and typecheck the thing_inside. \subsection{Errors and contexts} * * ************************************************************************ - - at checkArgCounts@ takes a @[RenamedMatch]@ and decides whether the same -number of args are used in each equation. -} +-- | @checkArgCounts@ takes a @[RenamedMatch]@ and decides whether the same +-- number of args are used in each equation. checkArgCounts :: AnnoBody body - => Name -> MatchGroup GhcRn (LocatedA (body GhcRn)) -> TcM () -checkArgCounts = check_match_pats . EquationArgs - --- @checkPatCounts@ takes a @[RenamedMatch]@ and decides whether the same --- number of patterns are used in each alternative -checkPatCounts :: AnnoBody body - => HsMatchContext GhcTc -> MatchGroup GhcRn (LocatedA (body GhcRn)) - -> TcM () -checkPatCounts = check_match_pats . PatternArgs - -check_match_pats :: AnnoBody body - => MatchArgsContext -> MatchGroup GhcRn (LocatedA (body GhcRn)) - -> TcM () -check_match_pats _ (MG { mg_alts = L _ [] }) + => HsMatchContext GhcTc -> MatchGroup GhcRn (LocatedA (body GhcRn)) + -> TcM () +checkArgCounts _ (MG { mg_alts = L _ [] }) = return () -check_match_pats matchContext (MG { mg_alts = L _ (match1:matches) }) +checkArgCounts matchContext (MG { mg_alts = L _ (match1:matches) }) | Just bad_matches <- mb_bad_matches = failWithTc $ TcRnMatchesHaveDiffNumArgs matchContext $ MatchArgMatches match1 bad_matches ===================================== compiler/GHC/Tc/Gen/Match.hs-boot ===================================== @@ -5,13 +5,13 @@ import GHC.Tc.Utils.TcType( ExpSigmaType, ExpRhoType ) import GHC.Tc.Types ( TcM ) import GHC.Hs.Extension ( GhcRn, GhcTc ) import GHC.Parser.Annotation ( LocatedN ) -import GHC.Types.Id (Id) +import GHC.Types.Name (Name) tcGRHSsPat :: GRHSs GhcRn (LHsExpr GhcRn) -> ExpRhoType -> TcM (GRHSs GhcTc (LHsExpr GhcTc)) -tcMatchesFun :: LocatedN Id +tcMatchesFun :: LocatedN Name -> MatchGroup GhcRn (LHsExpr GhcRn) -> ExpSigmaType -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -838,7 +838,7 @@ tcPatSynMatcher (L loc ps_name) lpat prag_fn args body] , mg_ext = MatchGroupTc (map unrestricted [pat_ty, cont_ty, fail_ty]) res_ty Generated } - match = mkMatch (mkPrefixFunRhs (L loc patsyn_id)) [] + match = mkMatch (mkPrefixFunRhs (L loc (idName patsyn_id))) [] (mkHsLams (rr_tv:res_tv:univ_tvs) req_dicts body') (EmptyLocalBinds noExtField) ===================================== compiler/Language/Haskell/Syntax/Expr.hs ===================================== @@ -1533,7 +1533,10 @@ data HsMatchContext p = FunRhs -- ^ A pattern matching on an argument of a -- function binding - { mc_fun :: LIdP p -- ^ function binder of @f@ + { mc_fun :: LIdP (NoGhcTc p) -- ^ function binder of @f@ + -- See Note [mc_fun field of FunRhs] + -- See #20415 for a long discussion about + -- this field and why it uses NoGhcTc. , mc_fixity :: LexicalFixity -- ^ fixing of @f@ , mc_strictness :: SrcStrictness -- ^ was @f@ banged? -- See Note [FunBind vs PatBind] @@ -1560,6 +1563,21 @@ data HsMatchContext p | ThPatQuote -- ^A Template Haskell pattern quotation [p| (a,b) |] | PatSyn -- ^A pattern synonym declaration +{- +Note [mc_fun field of FunRhs] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The mc_fun field of FunRhs has type `LIdP (NoGhcTc p)`, which means it will be +a `RdrName` in pass `GhcPs`, a `Name` in `GhcRn`, and (importantly) still a +`Name` in `GhcTc` -- not an `Id`. See Note [NoGhcTc] in GHC.Hs.Extension. + +Why a `Name` in the typechecker phase? Because: +* A `Name` is all we need, as it turns out. +* Using an `Id` involves knot-tying in the monad, which led to #22695. + +See #20415 for a long discussion. + +-} + isPatSynCtxt :: HsMatchContext p -> Bool isPatSynCtxt ctxt = case ctxt of ===================================== rts/include/rts/storage/Closures.h ===================================== @@ -211,8 +211,7 @@ typedef struct { // An array of heap objects, ie Array# v and MutableArray# v // // Closure types: MUT_ARR_PTRS_CLEAN, MUT_ARR_PTRS_DIRTY, -// MUT_ARR_PTRS_FROZEN_DIRTY, MUT_ARR_PTRS_FROZEN_CLEAN, MUT_VAR_CLEAN, -// MUT_VAR_DIRTY +// MUT_ARR_PTRS_FROZEN_DIRTY, MUT_ARR_PTRS_FROZEN_CLEAN typedef struct _StgMutArrPtrs { StgHeader header; StgWord ptrs; ===================================== testsuite/tests/ghci/scripts/T22695.script ===================================== @@ -0,0 +1 @@ +test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/T22695.stderr ===================================== @@ -0,0 +1,8 @@ + +:1:10: error: + • The constructor ‘Just’ should have 1 argument, but has been given none + • In the pattern: Just + In a stmt of a pattern guard for + an equation for ‘test’: + Just <- x + In an equation for ‘test’: test x | Just <- x = x ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -370,3 +370,4 @@ test('T21110', [extra_files(['T21110A.hs'])], ghci_script, test('T17830', [filter_stdout_lines(r'======.*')], ghci_script, ['T17830.script']) test('T21294a', normal, ghci_script, ['T21294a.script']) test('T21507', normal, ghci_script, ['T21507.script']) +test('T22695', normal, ghci_script, ['T22695.script']) ===================================== testsuite/tests/module/mod63.stderr ===================================== @@ -1,5 +1,5 @@ mod63.hs:3:1: error: [GHC-91938] - Equations for ‘f’ have different numbers of arguments + equations for ‘f’ have different numbers of arguments mod63.hs:3:1-8 mod63.hs:4:1-11 ===================================== testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr ===================================== @@ -1560,7 +1560,7 @@ (FunRhs (L (SrcSpanAnn (EpAnnNotUsed) { DumpTypecheckedAst.hs:19:1-4 }) - {Var: main}) + {Name: main}) (Prefix) (NoSrcStrict)) [] ===================================== testsuite/tests/parser/should_fail/ParserNoBinaryLiterals1.stderr ===================================== @@ -1,5 +1,5 @@ ParserNoBinaryLiterals1.hs:5:1: error: [GHC-91938] - Equations for ‘f’ have different numbers of arguments + equations for ‘f’ have different numbers of arguments ParserNoBinaryLiterals1.hs:5:1-10 ParserNoBinaryLiterals1.hs:6:1-10 ===================================== testsuite/tests/rename/should_fail/rnfail045.stderr ===================================== @@ -1,10 +1,10 @@ rnfail045.hs:5:1: error: [GHC-91938] - Equations for ‘op1’ have different numbers of arguments + equations for ‘op1’ have different numbers of arguments rnfail045.hs:5:1-16 rnfail045.hs:6:1-13 rnfail045.hs:8:1: error: [GHC-91938] - Equations for ‘op2’ have different numbers of arguments + equations for ‘op2’ have different numbers of arguments rnfail045.hs:8:1-13 rnfail045.hs:9:1-16 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6a592be40ef7315d995a090fd53f6d1b0183632c...1f4b9155d2e90c343bf3edc4e8ec2eb7e18c2560 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6a592be40ef7315d995a090fd53f6d1b0183632c...1f4b9155d2e90c343bf3edc4e8ec2eb7e18c2560 You're receiving 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 Jan 6 23:59:22 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 06 Jan 2023 18:59:22 -0500 Subject: [Git][ghc/ghc][wip/T22404] Wibbles Message-ID: <63b8b5da19561_c35a1550c8731ee@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22404 at Glasgow Haskell Compiler / GHC Commits: bf9bf5d9 by Simon Peyton Jones at 2023-01-06T23:59:03+00:00 Wibbles - - - - - 1 changed file: - compiler/GHC/Core/Opt/OccurAnal.hs Changes: ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -744,24 +744,62 @@ occAnalBind env lvl ire (Rec pairs) thing_inside combine occAnalBind !env lvl ire (NonRec bndr rhs) thing_inside combine | isTyVar bndr -- A type let; we don't gather usage info - = WithUsageDetails body_uds (combine [NonRec bndr rhs] body') + = let !(WithUsageDetails body_uds res) = addInScope env [bndr] thing_inside + in WithUsageDetails body_uds (combine [NonRec bndr rhs] res) - | isDeadBinder tagged_bndr - = WithUsageDetails body_uds body' -- Drop dead code + -- Non-recursive join points + | NotTopLevel <- lvl + , mb_join@(Just {}) <- isJoinId_maybe bndr + , not (isStableUnfolding (realIdUnfolding bndr)) + , not (idHasRules bndr) + = let -- Analyse the rhs first, generating rhs_uds + rhs_env = setRhsCtxt OccVanilla env + WithUsageDetails rhs_uds rhs' = occAnalRhs rhs_env NonRecursive mb_join rhs + + -- Now analyse the body, adding the + -- join-point into the environment with addJoinPoint + (tagged_bndr, body_wuds) + = occAnalNonRecBody env lvl bndr $ \env -> + thing_inside (addJoinPoint env bndr rhs_uds) + + -- Build the WithUsageDetails for the join-point binding + bind_wuds = WithUsageDetails emptyDetails [NonRec tagged_bndr rhs'] + in + finishNonRec combine tagged_bndr bind_wuds body_wuds + -- The normal case | otherwise - = WithUsageDetails (bind_uds `andUDs` body_uds) (combine binds' body') + = let -- Analyse the body first, generating tagged_bndr + (tagged_bndr, body_wuds) = occAnalNonRecBody env lvl bndr thing_inside - where - -- Analyse the body - WithUsageDetails body_uds (tagged_bndr, body') + -- Analyse the binding itself + bind_wuds = occAnalNonRecIdBind env ire tagged_bndr rhs + in + finishNonRec combine tagged_bndr bind_wuds body_wuds + +----------------- +occAnalNonRecBody :: OccEnv -> TopLevelFlag -> Id + -> (OccEnv -> WithUsageDetails r) -- Scope of the bind + -> (Id, WithUsageDetails r) +occAnalNonRecBody env lvl bndr thing_inside + = let !(WithUsageDetails uds (tagged_bndr, res)) = addInScope env [bndr] $ \env -> - let WithUsageDetails usage res = thing_inside env - tagged_bndr = tagNonRecBinder lvl usage bndr - in WithUsageDetails usage (tagged_bndr, res) + let !(WithUsageDetails inner_uds res) = thing_inside env + tagged_bndr = tagNonRecBinder lvl inner_uds bndr + in WithUsageDetails inner_uds (tagged_bndr, res) + in (tagged_bndr, WithUsageDetails uds res) - -- Analyse the binding itself - WithUsageDetails bind_uds binds' = occAnalNonRecIdBind env ire tagged_bndr rhs +----------------- +finishNonRec :: ([CoreBind] -> r -> r) -- How to combine the scope with new binds + -> Id -> WithUsageDetails [CoreBind] -> WithUsageDetails r + -> WithUsageDetails r +finishNonRec combine tagged_bndr + (WithUsageDetails bind_uds binds) + (WithUsageDetails body_uds body) + | isDeadBinder tagged_bndr + = WithUsageDetails body_uds body -- Drop dead code + | otherwise + = WithUsageDetails (bind_uds `andUDs` body_uds) (combine binds body) ----------------- @@ -770,8 +808,8 @@ occAnalNonRecIdBind :: OccEnv -> ImpRuleEdges -> Id -> CoreExpr occAnalNonRecIdBind !env imp_rule_edges tagged_bndr rhs = WithUsageDetails rhs_usage [NonRec final_bndr rhs'] where - final_bndr = tagged_bndr `setIdUnfolding` unf' - `setIdSpecialisation` mkRuleInfo rules' + final_bndr = tagged_bndr `setIdUnfolding` unf' + `setIdSpecialisation` mkRuleInfo rules' rhs_usage = rhs_uds `andUDs` unf_uds `andUDs` rule_uds -- Get the join info from the *new* decision @@ -2229,7 +2267,7 @@ occAnal env (Case scrut bndr ty alts) WithUsageDetails alts_usage (tagged_bndr, alts') = addInScope env [bndr] $ \env -> let alt_env = addBndrSwap scrut' bndr $ - env { occ_encl = OccVanilla } + setRhsCtxt OccVanilla env WithUsageDetails alts_usage alts' = do_alts alt_env alts tagged_bndr = tagLamBinder alts_usage bndr in WithUsageDetails alts_usage (tagged_bndr, alts') @@ -2254,22 +2292,6 @@ occAnal env (Case scrut bndr ty alts) WithUsageDetails rhs_usage (Alt con tagged_bndrs rhs') occAnal env (Let bind body) - | NonRec bndr rhs <- bind - , mb_join@(Just {}) <- isJoinId_maybe bndr - , not (isStableUnfolding (realIdUnfolding bndr)) - , not (idHasRules bndr) - = -- This is where we extend occ_join_points! - let WithUsageDetails rhs_usage rhs' = occAnalRhs env NonRecursive mb_join rhs - in addInScope env [bndr] $ \ body_env -> - let body_env1 = body_env { occ_join_points = extendVarEnv (occ_join_points env) - bndr rhs_usage } - WithUsageDetails body_usage body' = occAnal body_env1 body - bndr' = tagNonRecBinder NotTopLevel body_usage bndr - in if (bndr `usedIn` body_usage) - then WithUsageDetails body_usage (Let (NonRec bndr' rhs') body') - else WithUsageDetails body_usage body' - - | otherwise = occAnalBind env NotTopLevel noImpRuleEdges bind (\env -> occAnal env body) mkLets @@ -2585,7 +2607,7 @@ isRhsEnv (OccEnv { occ_encl = cxt }) = case cxt of _ -> False addInScope :: OccEnv -> [Var] -> (OccEnv -> WithUsageDetails a) -> WithUsageDetails a --- Needed for all Vars not just Ids +-- Needed for all Vars not just Ids; a TyVar might have a CoVars in its kind addInScope env@(OccEnv { occ_join_points = join_points }) bndrs thing_inside = fix_up_uds $ thing_inside $ drop_shadowed_swaps $ drop_shadowed_joins env where @@ -2617,6 +2639,9 @@ addInScope env@(OccEnv { occ_join_points = join_points }) bndrs thing_inside bad_join_rhs :: UsageDetails -> Bool bad_join_rhs (UD { ud_env = rhs_usage }) = any (`elemVarEnv` rhs_usage) bndrs +addJoinPoint :: OccEnv -> Id -> UsageDetails -> OccEnv +addJoinPoint env bndr rhs_uds + = env { occ_join_points = extendVarEnv (occ_join_points env) bndr rhs_uds } -------------------- transClosureFV :: VarEnv VarSet -> VarEnv VarSet View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf9bf5d9e22e7587ef9b3975f54d8436294159db -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf9bf5d9e22e7587ef9b3975f54d8436294159db You're receiving 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 Jan 7 03:09:13 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 06 Jan 2023 22:09:13 -0500 Subject: [Git][ghc/ghc][master] 2 commits: ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Message-ID: <63b8e25980c92_c35a1550b4829e1@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 4 changed files: - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/ci.sh ===================================== @@ -213,10 +213,14 @@ function set_toolchain_paths() { x86_64-darwin|aarch64-darwin) ;; *) fail "unknown NIX_SYSTEM" ;; esac - nix build -f .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh + info "Building toolchain for $NIX_SYSTEM" + nix-build .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh cat toolchain.sh fi - source toolchain.sh ;; + source toolchain.sh + info "--info for GHC for $NIX_SYSTEM" + $GHC --info + ;; env) # These are generally set by the Docker image but # we provide these handy fallbacks in case the @@ -320,7 +324,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 = [ @@ -38,6 +38,21 @@ let ]; buildPhase = "true"; + # This is a horrible hack because the configure script invokes /usr/bin/clang + # without a `--target` flag. Then depending on whether the `nix` binary itself is + # a native x86 or arm64 binary means that /usr/bin/clang thinks it needs to run in + # x86 or arm64 mode. + + # The correct answer for the check in question is the first one we try, so by replacing + # the condition to true; we select the right C++ standard library still. + preConfigure = '' + sed "s/\"\$CC\" -o actest actest.o \''${1} 2>\/dev\/null/true/i" configure > configure.new + mv configure.new configure + chmod +x configure + cat configure + + ''; + # N.B. Work around #20253. nativeBuildInputs = [ pkgs.gnused ]; postInstallPhase = '' @@ -98,6 +113,6 @@ pkgs.writeTextFile { export CABAL="$CABAL_INSTALL" sdk_path="$(xcrun --sdk macosx --show-sdk-path)" - export CONFIGURE_ARGS="$CONFIGURE_ARGS --with-ffi-libraries=$sdk_path/usr/lib --with-ffi-includes=$sdk_path/usr/include/ffi" + export CONFIGURE_ARGS="$CONFIGURE_ARGS --with-ffi-libraries=$sdk_path/usr/lib --with-ffi-includes=$sdk_path/usr/include/ffi --build=${targetTriple}" ''; } ===================================== .gitlab/gen_ci.hs ===================================== @@ -349,8 +349,8 @@ 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" - , "CABAL_INSTALL_VERSION" =: "3.6.2.0" + , "GHC_VERSION" =: "9.4.3" + , "CABAL_INSTALL_VERSION" =: "3.8.1.0" ] opsysVariables _ (Linux distro) = distroVariables distro opsysVariables AArch64 (Darwin {}) = @@ -378,8 +378,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 ===================================== @@ -594,9 +594,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.6.2.0", + "CABAL_INSTALL_VERSION": "3.8.1.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" @@ -1793,9 +1793,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", @@ -1852,9 +1852,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", @@ -2225,9 +2225,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-release", "BUILD_FLAVOUR": "release", - "CABAL_INSTALL_VERSION": "3.6.2.0", + "CABAL_INSTALL_VERSION": "3.8.1.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", @@ -2957,9 +2957,9 @@ "BIGNUM_BACKEND": "native", "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", + "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", @@ -3017,9 +3017,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-release+no_split_sections", "BUILD_FLAVOUR": "release+no_split_sections", - "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", @@ -3145,9 +3145,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.6.2.0", + "CABAL_INSTALL_VERSION": "3.8.1.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" } @@ -4326,9 +4326,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", @@ -4384,9 +4384,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/-/compare/ac39e8e97fbb69e4a786c1c29d6e477e7944f998...0db496ff1e372b19429fee91a4a569f7021fe1d7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ac39e8e97fbb69e4a786c1c29d6e477e7944f998...0db496ff1e372b19429fee91a4a569f7021fe1d7 You're receiving 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 Jan 7 03:09:45 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 06 Jan 2023 22:09:45 -0500 Subject: [Git][ghc/ghc][master] rts: MUT_VAR is not a StgMutArrPtrs Message-ID: <63b8e279663e7_c35a15511886441@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00 rts: MUT_VAR is not a StgMutArrPtrs There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs. - - - - - 1 changed file: - rts/include/rts/storage/Closures.h Changes: ===================================== rts/include/rts/storage/Closures.h ===================================== @@ -211,8 +211,7 @@ typedef struct { // An array of heap objects, ie Array# v and MutableArray# v // // Closure types: MUT_ARR_PTRS_CLEAN, MUT_ARR_PTRS_DIRTY, -// MUT_ARR_PTRS_FROZEN_DIRTY, MUT_ARR_PTRS_FROZEN_CLEAN, MUT_VAR_CLEAN, -// MUT_VAR_DIRTY +// MUT_ARR_PTRS_FROZEN_DIRTY, MUT_ARR_PTRS_FROZEN_CLEAN typedef struct _StgMutArrPtrs { StgHeader header; StgWord ptrs; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2459c3587bfe8105c628f9733bf32d1d3c903375 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2459c3587bfe8105c628f9733bf32d1d3c903375 You're receiving 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 Jan 7 08:22:31 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Sat, 07 Jan 2023 03:22:31 -0500 Subject: [Git][ghc/ghc][wip/int-index/decl-invis-binders] 7 commits: Add support for sized literals in the bytecode interpreter. Message-ID: <63b92bc71f60_c35a1551181011be@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/decl-invis-binders at Glasgow Haskell Compiler / GHC Commits: 28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00 Add support for sized literals in the bytecode interpreter. The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945 - - - - - ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00 rts: MUT_VAR is not a StgMutArrPtrs There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs. - - - - - ecad5f5e by Vladislav Zavialov at 2023-01-07T10:58:14+03:00 workaround: bump template-haskell - - - - - 4c55e824 by Vladislav Zavialov at 2023-01-07T10:58:15+03:00 WIP: Invisible binders in type declarations - - - - - 30 changed files: - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Hs/Expr.hs - 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/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/StgToByteCode.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Match.hs-boot - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/PatSyn.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ddfe2321bb4a0c5bfa2e1e502f01484d31247b54...4c55e8248566f8e06a20ec0033aab0f12fd51421 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ddfe2321bb4a0c5bfa2e1e502f01484d31247b54...4c55e8248566f8e06a20ec0033aab0f12fd51421 You're receiving 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 Jan 7 11:15:37 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Sat, 07 Jan 2023 06:15:37 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/fixup-chains Message-ID: <63b95459b2a9c_c35a1550dc1122ce@gitlab.mail> Matthew Pickering pushed new branch wip/fixup-chains at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/fixup-chains You're receiving 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 Jan 7 11:32:31 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Sat, 07 Jan 2023 06:32:31 -0500 Subject: [Git][ghc/ghc][wip/darwin-fixes-2] Pass -Wl, -no_fixup_chains to ld64 when appropiate Message-ID: <63b9584f6a28a_c35a1550b4118224@gitlab.mail> Matthew Pickering pushed to branch wip/darwin-fixes-2 at Glasgow Haskell Compiler / GHC Commits: cf1ee2ef by Matthew Pickering at 2023-01-07T11:32:21+00:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - 2 changed files: - configure.ac - + m4/fp_ld_no_fixup_chains.m4 Changes: ===================================== configure.ac ===================================== @@ -658,6 +658,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) # Stage 3 won't be supported by cross-compilation +FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) +FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + GHC_LLVM_TARGET_SET_VAR # we intend to pass trough --targets to llvm as is. LLVMTarget_CPP=` echo "$LlvmTarget"` ===================================== m4/fp_ld_no_fixup_chains.m4 ===================================== @@ -0,0 +1,24 @@ +# FP_LD_NO_FIXUP_CHAINS +# -------------------- +# See if whether we are using a version of ld64 on darwin platforms which +# requires us to pass -no_fixup_chains +# +# $1 = the platform +# $2 = the name of the linker flags variable when linking with $CC +AC_DEFUN([FP_LD_NO_FIXUP_CHAINS], [ + case $$1 in + *-darwin) + AC_MSG_CHECKING([whether ld64 requires -no_fixup_chains]) + echo 'int main(void) {return 0;}' > conftest.c + if $CC -o conftest.o -Wl,-no_fixup_chains conftest.c > /dev/null 2>&1 + then + $2="-Wl,-no_fixup_chains" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + rm -f conftest.c conftest.o + ;; + + esac +]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cf1ee2ef7161514e641dc29cbe6e44f48ff72c82 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cf1ee2ef7161514e641dc29cbe6e44f48ff72c82 You're receiving 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 Jan 7 11:38:06 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Sat, 07 Jan 2023 06:38:06 -0500 Subject: [Git][ghc/ghc][ghc-9.6] Disable split sections on aarch64-deb10 build Message-ID: <63b9599e8a0b3_c35a1550b41207b@gitlab.mail> Matthew Pickering pushed to branch ghc-9.6 at Glasgow Haskell Compiler / GHC Commits: 80601b0e by Matthew Pickering at 2023-01-07T11:37:19+00:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 2 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -813,7 +813,7 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , standardBuilds Amd64 Darwin , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin - , standardBuilds AArch64 (Linux Debian10) + , standardBuildsWithConfig AArch64 (Linux Debian10) (splitSectionsBroken vanilla) , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla) , standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static) , disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt)) ===================================== .gitlab/jobs.yaml ===================================== @@ -1809,7 +1809,7 @@ "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release": { + "release-aarch64-linux-deb10-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1819,7 +1819,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release.tar.xz", + "ghc-aarch64-linux-deb10-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -1861,11 +1861,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release", + "TEST_ENV": "aarch64-linux-deb10-release+no_split_sections", "XZ_OPT": "-9" } }, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/80601b0e774003da257819ee722d2cfdf711c580 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/80601b0e774003da257819ee722d2cfdf711c580 You're receiving 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 Jan 7 11:41:12 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Sat, 07 Jan 2023 06:41:12 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/disable-split-sections-arch64 Message-ID: <63b95a5842cf3_c35a1550b4120967@gitlab.mail> Matthew Pickering pushed new branch wip/disable-split-sections-arch64 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/disable-split-sections-arch64 You're receiving 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 Jan 7 14:44:47 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 07 Jan 2023 09:44:47 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Message-ID: <63b9855f99879_c35a1551401309b2@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00 rts: MUT_VAR is not a StgMutArrPtrs There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs. - - - - - ed149ef4 by Simon Peyton Jones at 2023-01-07T09:44:35-05:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - 7d997a06 by Matthew Pickering at 2023-01-07T09:44:35-05:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s - - - - - 1a6174d4 by Matthew Pickering at 2023-01-07T09:44:35-05:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. - - - - - 857c2404 by Matthew Pickering at 2023-01-07T09:44:35-05:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - 12 changed files: - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Core/Opt/FloatIn.hs - configure.ac - + m4/fp_ld_no_fixup_chains.m4 - rts/include/rts/storage/Closures.h - testsuite/tests/ghci/linking/dyn/Makefile - testsuite/tests/rts/T18623/all.T - + testsuite/tests/simplCore/should_compile/T22662.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== .gitlab/ci.sh ===================================== @@ -213,10 +213,14 @@ function set_toolchain_paths() { x86_64-darwin|aarch64-darwin) ;; *) fail "unknown NIX_SYSTEM" ;; esac - nix build -f .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh + info "Building toolchain for $NIX_SYSTEM" + nix-build .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh cat toolchain.sh fi - source toolchain.sh ;; + source toolchain.sh + info "--info for GHC for $NIX_SYSTEM" + $GHC --info + ;; env) # These are generally set by the Docker image but # we provide these handy fallbacks in case the @@ -320,7 +324,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 = [ @@ -38,6 +38,21 @@ let ]; buildPhase = "true"; + # This is a horrible hack because the configure script invokes /usr/bin/clang + # without a `--target` flag. Then depending on whether the `nix` binary itself is + # a native x86 or arm64 binary means that /usr/bin/clang thinks it needs to run in + # x86 or arm64 mode. + + # The correct answer for the check in question is the first one we try, so by replacing + # the condition to true; we select the right C++ standard library still. + preConfigure = '' + sed "s/\"\$CC\" -o actest actest.o \''${1} 2>\/dev\/null/true/i" configure > configure.new + mv configure.new configure + chmod +x configure + cat configure + + ''; + # N.B. Work around #20253. nativeBuildInputs = [ pkgs.gnused ]; postInstallPhase = '' @@ -98,6 +113,6 @@ pkgs.writeTextFile { export CABAL="$CABAL_INSTALL" sdk_path="$(xcrun --sdk macosx --show-sdk-path)" - export CONFIGURE_ARGS="$CONFIGURE_ARGS --with-ffi-libraries=$sdk_path/usr/lib --with-ffi-includes=$sdk_path/usr/include/ffi" + export CONFIGURE_ARGS="$CONFIGURE_ARGS --with-ffi-libraries=$sdk_path/usr/lib --with-ffi-includes=$sdk_path/usr/include/ffi --build=${targetTriple}" ''; } ===================================== .gitlab/gen_ci.hs ===================================== @@ -349,8 +349,8 @@ 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" - , "CABAL_INSTALL_VERSION" =: "3.6.2.0" + , "GHC_VERSION" =: "9.4.3" + , "CABAL_INSTALL_VERSION" =: "3.8.1.0" ] opsysVariables _ (Linux distro) = distroVariables distro opsysVariables AArch64 (Darwin {}) = @@ -378,8 +378,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 ===================================== @@ -594,9 +594,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.6.2.0", + "CABAL_INSTALL_VERSION": "3.8.1.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" @@ -1793,9 +1793,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", @@ -1852,9 +1852,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", @@ -2225,9 +2225,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-release", "BUILD_FLAVOUR": "release", - "CABAL_INSTALL_VERSION": "3.6.2.0", + "CABAL_INSTALL_VERSION": "3.8.1.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", @@ -2957,9 +2957,9 @@ "BIGNUM_BACKEND": "native", "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", + "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", @@ -3017,9 +3017,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-release+no_split_sections", "BUILD_FLAVOUR": "release+no_split_sections", - "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", @@ -3145,9 +3145,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.6.2.0", + "CABAL_INSTALL_VERSION": "3.8.1.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" } @@ -4326,9 +4326,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", @@ -4384,9 +4384,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", ===================================== compiler/GHC/Core/Opt/FloatIn.hs ===================================== @@ -35,9 +35,12 @@ import GHC.Types.Var import GHC.Types.Var.Set import GHC.Utils.Misc -import GHC.Utils.Panic import GHC.Utils.Panic.Plain +import GHC.Utils.Outputable + +import Data.List ( mapAccumL ) + {- Top-level interface function, @floatInwards at . Note that we do not actually float any bindings downwards from the top-level. @@ -124,7 +127,7 @@ the closure for a is not built. ************************************************************************ -} -type FreeVarSet = DIdSet +type FreeVarSet = DVarSet type BoundVarSet = DIdSet data FloatInBind = FB BoundVarSet FreeVarSet FloatBind @@ -132,11 +135,17 @@ data FloatInBind = FB BoundVarSet FreeVarSet FloatBind -- of recursive bindings, the set doesn't include the bound -- variables. -type FloatInBinds = [FloatInBind] - -- In reverse dependency order (innermost binder first) +type FloatInBinds = [FloatInBind] -- In normal dependency order + -- (outermost binder first) +type RevFloatInBinds = [FloatInBind] -- In reverse dependency order + -- (innermost binder first) + +instance Outputable FloatInBind where + ppr (FB bvs fvs _) = text "FB" <> braces (sep [ text "bndrs =" <+> ppr bvs + , text "fvs =" <+> ppr fvs ]) fiExpr :: Platform - -> FloatInBinds -- Binds we're trying to drop + -> RevFloatInBinds -- Binds we're trying to drop -- as far "inwards" as possible -> CoreExprWithFVs -- Input expr -> CoreExpr -- Result @@ -147,13 +156,12 @@ fiExpr _ to_drop (_, AnnType ty) = assert (null to_drop) $ Type ty fiExpr _ to_drop (_, AnnVar v) = wrapFloats to_drop (Var v) fiExpr _ to_drop (_, AnnCoercion co) = wrapFloats to_drop (Coercion co) fiExpr platform to_drop (_, AnnCast expr (co_ann, co)) - = wrapFloats (drop_here ++ co_drop) $ + = wrapFloats drop_here $ Cast (fiExpr platform e_drop expr) co where - [drop_here, e_drop, co_drop] - = sepBindsByDropPoint platform False - [freeVarsOf expr, freeVarsOfAnn co_ann] - to_drop + (drop_here, [e_drop]) + = sepBindsByDropPoint platform False to_drop + (freeVarsOfAnn co_ann) [freeVarsOf expr] {- Applications: we do float inside applications, mainly because we @@ -162,7 +170,7 @@ pull out any silly ones. -} fiExpr platform to_drop ann_expr@(_,AnnApp {}) - = wrapFloats drop_here $ wrapFloats extra_drop $ + = wrapFloats drop_here $ mkTicks ticks $ mkApps (fiExpr platform fun_drop ann_fun) (zipWithEqual "fiExpr" (fiExpr platform) arg_drops ann_args) @@ -170,21 +178,19 @@ fiExpr platform to_drop ann_expr@(_,AnnApp {}) -- length ann_args = length arg_fvs = length arg_drops where (ann_fun, ann_args, ticks) = collectAnnArgsTicks tickishFloatable ann_expr - fun_ty = exprType (deAnnotate ann_fun) fun_fvs = freeVarsOf ann_fun - arg_fvs = map freeVarsOf ann_args - (drop_here : extra_drop : fun_drop : arg_drops) - = sepBindsByDropPoint platform False - (extra_fvs : fun_fvs : arg_fvs) - to_drop + (drop_here, fun_drop : arg_drops) + = sepBindsByDropPoint platform False to_drop + here_fvs (fun_fvs : arg_fvs) + -- Shortcut behaviour: if to_drop is empty, -- sepBindsByDropPoint returns a suitable bunch of empty -- lists without evaluating extra_fvs, and hence without -- peering into each argument - (_, extra_fvs) = foldl' add_arg (fun_ty, extra_fvs0) ann_args - extra_fvs0 = case ann_fun of + (here_fvs, arg_fvs) = mapAccumL add_arg here_fvs0 ann_args + here_fvs0 = case ann_fun of (_, AnnVar _) -> fun_fvs _ -> emptyDVarSet -- Don't float the binding for f into f x y z; see Note [Join points] @@ -192,14 +198,11 @@ fiExpr platform to_drop ann_expr@(_,AnnApp {}) -- join point, floating it in isn't especially harmful but it's -- useless since the simplifier will immediately float it back out.) - add_arg :: (Type,FreeVarSet) -> CoreExprWithFVs -> (Type,FreeVarSet) - add_arg (fun_ty, extra_fvs) (_, AnnType ty) - = (piResultTy fun_ty ty, extra_fvs) - add_arg (fun_ty, extra_fvs) (arg_fvs, arg) - | noFloatIntoArg arg - = (funResultTy fun_ty, extra_fvs `unionDVarSet` arg_fvs) - | otherwise - = (funResultTy fun_ty, extra_fvs) + add_arg :: FreeVarSet -> CoreExprWithFVs -> (FreeVarSet,FreeVarSet) + -- We can't float into some arguments, so put them into the here_fvs + add_arg here_fvs (arg_fvs, arg) + | noFloatIntoArg arg = (here_fvs `unionDVarSet` arg_fvs, emptyDVarSet) + | otherwise = (here_fvs, arg_fvs) {- Note [Dead bindings] ~~~~~~~~~~~~~~~~~~~~~~~ @@ -272,7 +275,6 @@ it's non-recursive, so we float only into non-recursive join points.) Urk! if all are tyvars, and we don't float in, we may miss an opportunity to float inside a nested case branch - Note [Floating coercions] ~~~~~~~~~~~~~~~~~~~~~~~~~ We could, in principle, have a coercion binding like @@ -292,6 +294,36 @@ of the types of all the drop points involved. If any of the floaters bind a coercion variable mentioned in any of the types, that binder must be dropped right away. +Note [Shadowing and name capture] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we have + let x = y+1 in + case p of + (y:ys) -> ...x... + [] -> blah +It is obviously bogus for FloatIn to transform to + case p of + (y:ys) -> ...(let x = y+1 in x)... + [] -> blah +because the y is captured. This doesn't happen much, because shadowing is +rare, but it did happen in #22662. + +One solution would be to clone as we go. But a simpler one is this: + + at a binding site (like that for (y:ys) above), abandon float-in for + any floating bindings that mention the binders (y, ys in this case) + +We achieve that by calling sepBindsByDropPoint with the binders in +the "used-here" set: + +* In fiExpr (AnnLam ...). For the body there is no need to delete + the lambda-binders from the body_fvs, because any bindings that + mention these binders will be dropped here anyway. + +* In fiExpr (AnnCase ...). Remember to include the case_bndr in the + binders. Again, no need to delete the alt binders from the rhs + free vars, beause any bindings mentioning them will be dropped + here unconditionally. -} fiExpr platform to_drop lam@(_, AnnLam _ _) @@ -300,10 +332,17 @@ fiExpr platform to_drop lam@(_, AnnLam _ _) = wrapFloats to_drop (mkLams bndrs (fiExpr platform [] body)) | otherwise -- Float inside - = mkLams bndrs (fiExpr platform to_drop body) + = wrapFloats drop_here $ + mkLams bndrs (fiExpr platform body_drop body) where (bndrs, body) = collectAnnBndrs lam + body_fvs = freeVarsOf body + + -- Why sepBindsByDropPoint? Because of potential capture + -- See Note [Shadowing and name capture] + (drop_here, [body_drop]) = sepBindsByDropPoint platform False to_drop + (mkDVarSet bndrs) [body_fvs] {- We don't float lets inwards past an SCC. @@ -443,16 +482,16 @@ fiExpr platform to_drop (_, AnnCase scrut case_bndr _ [AnnAlt con alt_bndrs rhs] = wrapFloats shared_binds $ fiExpr platform (case_float : rhs_binds) rhs where - case_float = FB (mkDVarSet (case_bndr : alt_bndrs)) scrut_fvs + case_float = FB all_bndrs scrut_fvs (FloatCase scrut' case_bndr con alt_bndrs) scrut' = fiExpr platform scrut_binds scrut - rhs_fvs = freeVarsOf rhs `delDVarSetList` (case_bndr : alt_bndrs) - scrut_fvs = freeVarsOf scrut + rhs_fvs = freeVarsOf rhs -- No need to delete alt_bndrs + scrut_fvs = freeVarsOf scrut -- See Note [Shadowing and name capture] + all_bndrs = mkDVarSet alt_bndrs `extendDVarSet` case_bndr - [shared_binds, scrut_binds, rhs_binds] - = sepBindsByDropPoint platform False - [scrut_fvs, rhs_fvs] - to_drop + (shared_binds, [scrut_binds, rhs_binds]) + = sepBindsByDropPoint platform False to_drop + all_bndrs [scrut_fvs, rhs_fvs] fiExpr platform to_drop (_, AnnCase scrut case_bndr ty alts) = wrapFloats drop_here1 $ @@ -462,39 +501,43 @@ fiExpr platform to_drop (_, AnnCase scrut case_bndr ty alts) -- use zipWithEqual, we should have length alts_drops_s = length alts where -- Float into the scrut and alts-considered-together just like App - [drop_here1, scrut_drops, alts_drops] - = sepBindsByDropPoint platform False - [scrut_fvs, all_alts_fvs] - to_drop + (drop_here1, [scrut_drops, alts_drops]) + = sepBindsByDropPoint platform False to_drop + all_alt_bndrs [scrut_fvs, all_alt_fvs] + -- all_alt_bndrs: see Note [Shadowing and name capture] -- Float into the alts with the is_case flag set - (drop_here2 : alts_drops_s) - | [ _ ] <- alts = [] : [alts_drops] - | otherwise = sepBindsByDropPoint platform True alts_fvs alts_drops - - scrut_fvs = freeVarsOf scrut - alts_fvs = map alt_fvs alts - all_alts_fvs = unionDVarSets alts_fvs - alt_fvs (AnnAlt _con args rhs) - = foldl' delDVarSet (freeVarsOf rhs) (case_bndr:args) - -- Delete case_bndr and args from free vars of rhs - -- to get free vars of alt + (drop_here2, alts_drops_s) + = sepBindsByDropPoint platform True alts_drops emptyDVarSet alts_fvs + + scrut_fvs = freeVarsOf scrut + + all_alt_bndrs = foldr (unionDVarSet . ann_alt_bndrs) (unitDVarSet case_bndr) alts + ann_alt_bndrs (AnnAlt _ bndrs _) = mkDVarSet bndrs + + alts_fvs :: [DVarSet] + alts_fvs = [freeVarsOf rhs | AnnAlt _ _ rhs <- alts] + -- No need to delete binders + -- See Note [Shadowing and name capture] + + all_alt_fvs :: DVarSet + all_alt_fvs = foldr unionDVarSet (unitDVarSet case_bndr) alts_fvs fi_alt to_drop (AnnAlt con args rhs) = Alt con args (fiExpr platform to_drop rhs) ------------------ fiBind :: Platform - -> FloatInBinds -- Binds we're trying to drop - -- as far "inwards" as possible - -> CoreBindWithFVs -- Input binding - -> DVarSet -- Free in scope of binding - -> ( FloatInBinds -- Land these before - , FloatInBind -- The binding itself - , FloatInBinds) -- Land these after + -> RevFloatInBinds -- Binds we're trying to drop + -- as far "inwards" as possible + -> CoreBindWithFVs -- Input binding + -> DVarSet -- Free in scope of binding + -> ( RevFloatInBinds -- Land these before + , FloatInBind -- The binding itself + , RevFloatInBinds) -- Land these after fiBind platform to_drop (AnnNonRec id ann_rhs@(rhs_fvs, rhs)) body_fvs - = ( extra_binds ++ shared_binds -- Land these before - -- See Note [extra_fvs (1)] and Note [extra_fvs (2)] + = ( shared_binds -- Land these before + -- See Note [extra_fvs (1)] and Note [extra_fvs (2)] , FB (unitDVarSet id) rhs_fvs' -- The new binding itself (FloatLet (NonRec id rhs')) , body_binds ) -- Land these after @@ -512,10 +555,9 @@ fiBind platform to_drop (AnnNonRec id ann_rhs@(rhs_fvs, rhs)) body_fvs -- We *can't* float into ok-for-speculation unlifted RHSs -- But do float into join points - [shared_binds, extra_binds, rhs_binds, body_binds] - = sepBindsByDropPoint platform False - [extra_fvs, rhs_fvs, body_fvs2] - to_drop + (shared_binds, [rhs_binds, body_binds]) + = sepBindsByDropPoint platform False to_drop + extra_fvs [rhs_fvs, body_fvs2] -- Push rhs_binds into the right hand side of the binding rhs' = fiRhs platform rhs_binds id ann_rhs @@ -523,7 +565,7 @@ fiBind platform to_drop (AnnNonRec id ann_rhs@(rhs_fvs, rhs)) body_fvs -- Don't forget the rule_fvs; the binding mentions them! fiBind platform to_drop (AnnRec bindings) body_fvs - = ( extra_binds ++ shared_binds + = ( shared_binds , FB (mkDVarSet ids) rhs_fvs' (FloatLet (Rec (fi_bind rhss_binds bindings))) , body_binds ) @@ -537,17 +579,16 @@ fiBind platform to_drop (AnnRec bindings) body_fvs unionDVarSets [ rhs_fvs | (bndr, (rhs_fvs, rhs)) <- bindings , noFloatIntoRhs Recursive bndr rhs ] - (shared_binds:extra_binds:body_binds:rhss_binds) - = sepBindsByDropPoint platform False - (extra_fvs:body_fvs:rhss_fvs) - to_drop + (shared_binds, body_binds:rhss_binds) + = sepBindsByDropPoint platform False to_drop + extra_fvs (body_fvs:rhss_fvs) rhs_fvs' = unionDVarSets rhss_fvs `unionDVarSet` unionDVarSets (map floatedBindsFVs rhss_binds) `unionDVarSet` rule_fvs -- Don't forget the rule variables! -- Push rhs_binds into the right hand side of the binding - fi_bind :: [FloatInBinds] -- one per "drop pt" conjured w/ fvs_of_rhss + fi_bind :: [RevFloatInBinds] -- One per "drop pt" conjured w/ fvs_of_rhss -> [(Id, CoreExprWithFVs)] -> [(Id, CoreExpr)] @@ -556,7 +597,7 @@ fiBind platform to_drop (AnnRec bindings) body_fvs | ((binder, rhs), to_drop) <- zipEqual "fi_bind" pairs to_drops ] ------------------ -fiRhs :: Platform -> FloatInBinds -> CoreBndr -> CoreExprWithFVs -> CoreExpr +fiRhs :: Platform -> RevFloatInBinds -> CoreBndr -> CoreExprWithFVs -> CoreExpr fiRhs platform to_drop bndr rhs | Just join_arity <- isJoinId_maybe bndr , let (bndrs, body) = collectNAnnBndrs join_arity rhs @@ -656,68 +697,84 @@ point. We have to maintain the order on these drop-point-related lists. -} --- pprFIB :: FloatInBinds -> SDoc +-- pprFIB :: RevFloatInBinds -> SDoc -- pprFIB fibs = text "FIB:" <+> ppr [b | FB _ _ b <- fibs] sepBindsByDropPoint :: Platform - -> Bool -- True <=> is case expression - -> [FreeVarSet] -- One set of FVs per drop point - -- Always at least two long! - -> FloatInBinds -- Candidate floaters - -> [FloatInBinds] -- FIRST one is bindings which must not be floated - -- inside any drop point; the rest correspond - -- one-to-one with the input list of FV sets + -> Bool -- True <=> is case expression + -> RevFloatInBinds -- Candidate floaters + -> FreeVarSet -- here_fvs: if these vars are free in a binding, + -- don't float that binding inside any drop point + -> [FreeVarSet] -- fork_fvs: one set of FVs per drop point + -> ( RevFloatInBinds -- Bindings which must not be floated inside + , [RevFloatInBinds] ) -- Corresponds 1-1 with the input list of FV sets -- Every input floater is returned somewhere in the result; -- none are dropped, not even ones which don't seem to be -- free in *any* of the drop-point fvs. Why? Because, for example, -- a binding (let x = E in B) might have a specialised version of -- x (say x') stored inside x, but x' isn't free in E or B. +-- +-- The here_fvs argument is used for two things: +-- * Avoid shadowing bugs: see Note [Shadowing and name capture] +-- * Drop some of the bindings at the top, e.g. of an application type DropBox = (FreeVarSet, FloatInBinds) -sepBindsByDropPoint platform is_case drop_pts floaters +dropBoxFloats :: DropBox -> RevFloatInBinds +dropBoxFloats (_, floats) = reverse floats + +usedInDropBox :: DIdSet -> DropBox -> Bool +usedInDropBox bndrs (db_fvs, _) = db_fvs `intersectsDVarSet` bndrs + +initDropBox :: DVarSet -> DropBox +initDropBox fvs = (fvs, []) + +sepBindsByDropPoint platform is_case floaters here_fvs fork_fvs | null floaters -- Shortcut common case - = [] : [[] | _ <- drop_pts] + = ([], [[] | _ <- fork_fvs]) | otherwise - = assert (drop_pts `lengthAtLeast` 2) $ - go floaters (map (\fvs -> (fvs, [])) (emptyDVarSet : drop_pts)) + = go floaters (initDropBox here_fvs) (map initDropBox fork_fvs) where - n_alts = length drop_pts + n_alts = length fork_fvs - go :: FloatInBinds -> [DropBox] -> [FloatInBinds] - -- The *first* one in the argument list is the drop_here set - -- The FloatInBinds in the lists are in the reverse of - -- the normal FloatInBinds order; that is, they are the right way round! + go :: RevFloatInBinds -> DropBox -> [DropBox] + -> (RevFloatInBinds, [RevFloatInBinds]) + -- The *first* one in the pair is the drop_here set - go [] drop_boxes = map (reverse . snd) drop_boxes + go [] here_box fork_boxes + = (dropBoxFloats here_box, map dropBoxFloats fork_boxes) - go (bind_w_fvs@(FB bndrs bind_fvs bind) : binds) drop_boxes@(here_box : fork_boxes) - = go binds new_boxes + go (bind_w_fvs@(FB bndrs bind_fvs bind) : binds) here_box fork_boxes + | drop_here = go binds (insert here_box) fork_boxes + | otherwise = go binds here_box new_fork_boxes where -- "here" means the group of bindings dropped at the top of the fork - (used_here : used_in_flags) = [ fvs `intersectsDVarSet` bndrs - | (fvs, _) <- drop_boxes] + used_here = bndrs `usedInDropBox` here_box + used_in_flags = case fork_boxes of + [] -> [] + [_] -> [True] -- Push all bindings into a single branch + -- No need to look at its free vars + _ -> map (bndrs `usedInDropBox`) fork_boxes + -- Short-cut for the singleton case; + -- used for lambdas and singleton cases drop_here = used_here || cant_push n_used_alts = count id used_in_flags -- returns number of Trues in list. cant_push - | is_case = n_used_alts == n_alts -- Used in all, don't push - -- Remember n_alts > 1 + | is_case = (n_alts > 1 && n_used_alts == n_alts) + -- Used in all, muliple branches, don't push || (n_used_alts > 1 && not (floatIsDupable platform bind)) -- floatIsDupable: see Note [Duplicating floats] | otherwise = floatIsCase bind || n_used_alts > 1 -- floatIsCase: see Note [Floating primops] - new_boxes | drop_here = (insert here_box : fork_boxes) - | otherwise = (here_box : new_fork_boxes) - new_fork_boxes = zipWithEqual "FloatIn.sepBinds" insert_maybe fork_boxes used_in_flags @@ -727,8 +784,6 @@ sepBindsByDropPoint platform is_case drop_pts floaters insert_maybe box True = insert box insert_maybe box False = box - go _ _ = panic "sepBindsByDropPoint/go" - {- Note [Duplicating floats] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -745,14 +800,14 @@ If the thing is used in all RHSs there is nothing gained, so we don't duplicate then. -} -floatedBindsFVs :: FloatInBinds -> FreeVarSet +floatedBindsFVs :: RevFloatInBinds -> FreeVarSet floatedBindsFVs binds = mapUnionDVarSet fbFVs binds fbFVs :: FloatInBind -> DVarSet fbFVs (FB _ fvs _) = fvs -wrapFloats :: FloatInBinds -> CoreExpr -> CoreExpr --- Remember FloatInBinds is in *reverse* dependency order +wrapFloats :: RevFloatInBinds -> CoreExpr -> CoreExpr +-- Remember RevFloatInBinds is in *reverse* dependency order wrapFloats [] e = e wrapFloats (FB _ _ fl : bs) e = wrapFloats bs (wrapFloat fl e) ===================================== configure.ac ===================================== @@ -658,6 +658,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) # Stage 3 won't be supported by cross-compilation +FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) +FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + GHC_LLVM_TARGET_SET_VAR # we intend to pass trough --targets to llvm as is. LLVMTarget_CPP=` echo "$LlvmTarget"` ===================================== m4/fp_ld_no_fixup_chains.m4 ===================================== @@ -0,0 +1,24 @@ +# FP_LD_NO_FIXUP_CHAINS +# -------------------- +# See if whether we are using a version of ld64 on darwin platforms which +# requires us to pass -no_fixup_chains +# +# $1 = the platform +# $2 = the name of the linker flags variable when linking with $CC +AC_DEFUN([FP_LD_NO_FIXUP_CHAINS], [ + case $$1 in + *-darwin) + AC_MSG_CHECKING([whether ld64 requires -no_fixup_chains]) + echo 'int main(void) {return 0;}' > conftest.c + if $CC -o conftest.o -Wl,-no_fixup_chains conftest.c > /dev/null 2>&1 + then + $2="-Wl,-no_fixup_chains" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + rm -f conftest.c conftest.o + ;; + + esac +]) ===================================== rts/include/rts/storage/Closures.h ===================================== @@ -211,8 +211,7 @@ typedef struct { // An array of heap objects, ie Array# v and MutableArray# v // // Closure types: MUT_ARR_PTRS_CLEAN, MUT_ARR_PTRS_DIRTY, -// MUT_ARR_PTRS_FROZEN_DIRTY, MUT_ARR_PTRS_FROZEN_CLEAN, MUT_VAR_CLEAN, -// MUT_VAR_DIRTY +// MUT_ARR_PTRS_FROZEN_DIRTY, MUT_ARR_PTRS_FROZEN_CLEAN typedef struct _StgMutArrPtrs { StgHeader header; StgWord ptrs; ===================================== testsuite/tests/ghci/linking/dyn/Makefile ===================================== @@ -84,7 +84,7 @@ compile_libAB_dyn: '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_dyn" -shared B.c -o "bin_dyn/$(call DLL,B)" $(call DEF,B) -lA -L"./bin_dyn" rm -f bin_dyn/*.a '$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -v0 -o "bin_dyn/$(call EXE,T10955dyn)" -L./bin_dyn -lB -lA T10955dyn.hs -v0 - LD_LIBRARY_PATH=./bin_dyn ./bin_dyn/$(call EXE,T10955dyn) + DYLD_LIBRARY_PATH=./bin_dyn LD_LIBRARY_PATH=./bin_dyn ./bin_dyn/$(call EXE,T10955dyn) .PHONY: compile_libAS_impl_gcc compile_libAS_impl_gcc: ===================================== testsuite/tests/rts/T18623/all.T ===================================== @@ -5,6 +5,8 @@ test('T18623', # This keeps failing on aarch64-linux for reasons that are not # fully clear. Maybe it needs a higher limit due to LLVM? when(arch('aarch64'), skip), + # Recent versions of osx report an error when running `ulimit -v` + when(arch('darwin'), skip), when(arch('powerpc64le'), skip), cmd_prefix('ulimit -v ' + str(1024 ** 2) + ' && '), ignore_stdout], ===================================== testsuite/tests/simplCore/should_compile/T22662.hs ===================================== @@ -0,0 +1,6 @@ +module T22662 where + +import Data.Set + +foo x = sequence_ [ f y | y <- x ] + where f _ = return (fromList [0]) ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -461,3 +461,4 @@ 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, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) +test('T22662', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1f4b9155d2e90c343bf3edc4e8ec2eb7e18c2560...857c2404e892725cd344889b177cc732571d84cc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1f4b9155d2e90c343bf3edc4e8ec2eb7e18c2560...857c2404e892725cd344889b177cc732571d84cc You're receiving 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 Jan 7 16:26:15 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sat, 07 Jan 2023 11:26:15 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-hsdocty Message-ID: <63b99d27181f5_c35a155104141772@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-hsdocty at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-hsdocty You're receiving 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 Jan 7 16:29:56 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sat, 07 Jan 2023 11:29:56 -0500 Subject: [Git][ghc/ghc][wip/az/epa-hsdocty] EPA: exact print HsDocTy Message-ID: <63b99e0491a1a_c35a1d15f65014191@gitlab.mail> Alan Zimmerman pushed to branch wip/az/epa-hsdocty at Glasgow Haskell Compiler / GHC Commits: 9f18df76 by Alan Zimmerman at 2023-01-07T16:29:41+00:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 5 changed files: - + testsuite/tests/printer/HsDocTy.hs - testsuite/tests/printer/Makefile - testsuite/tests/printer/all.T - utils/check-exact/ExactPrint.hs - utils/check-exact/Main.hs Changes: ===================================== testsuite/tests/printer/HsDocTy.hs ===================================== @@ -0,0 +1,6 @@ +{-# OPTIONS_GHC -haddock #-} +module HsDocTy where + +class C1 a where + f1 :: a -> Int + -- ^ comment on Int ===================================== testsuite/tests/printer/Makefile ===================================== @@ -769,3 +769,9 @@ Test21355: Test21805: $(CHECK_PPR) $(LIBDIR) Test21805.hs $(CHECK_EXACT) $(LIBDIR) Test21805.hs + +.PHONY: HsDocTy +HsDocTy: + # See comment on pprWithDocString, this won't round trip + # $(CHECK_PPR) $(LIBDIR) HsDocTy.hs + $(CHECK_EXACT) $(LIBDIR) HsDocTy.hs ===================================== testsuite/tests/printer/all.T ===================================== @@ -185,4 +185,5 @@ test('Test21805', [ignore_stderr, req_ppr_deps], makefile_test, ['Test21805']) test('T22488', normal, ghci_script, ['T22488.script']) test('T22488_docHead', normal, compile_and_run, ['-package ghc']) test('T20531', extra_files(['T20531_defs.hs']), ghci_script, ['T20531.script']) -test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) \ No newline at end of file +test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) +test('HsDocTy', [ignore_stderr, req_ppr_deps], makefile_test, ['HsDocTy']) \ No newline at end of file ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -3898,6 +3898,10 @@ instance ExactPrint (HsType GhcPs) where exact (HsSpliceTy a splice) = do splice' <- markAnnotated splice return (HsSpliceTy a splice') + exact (HsDocTy an ty doc) = do + ty' <- markAnnotated ty + doc' <- markAnnotated doc + return (HsDocTy an ty' doc') exact (HsBangTy an (HsSrcBang mt up str) ty) = do an0 <- case mt of ===================================== utils/check-exact/Main.hs ===================================== @@ -59,7 +59,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../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) - "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) + -- "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3a.hs" (Just changeWhereIn3a) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3b.hs" (Just changeWhereIn3b) -- "../../testsuite/tests/ghc-api/exactprint/AddLocalDecl1.hs" (Just addLocaLDecl1) @@ -203,6 +203,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../testsuite/tests/ghc-api/exactprint/Test20239.hs" Nothing -- "../../testsuite/tests/printer/PprArrowLambdaCase.hs" Nothing -- "../../testsuite/tests/printer/Test16279.hs" Nothing + "../../testsuite/tests/printer/HsDocTy.hs" Nothing -- cloneT does not need a test, function can be retired View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f18df76f6e61b72205eb40b97f8debc2949b831 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f18df76f6e61b72205eb40b97f8debc2949b831 You're receiving 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 Jan 7 17:15:01 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 07 Jan 2023 12:15:01 -0500 Subject: [Git][ghc/ghc][master] Make FloatIn robust to shadowing Message-ID: <63b9a8953ebd1_c35a1551401587e3@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - 3 changed files: - compiler/GHC/Core/Opt/FloatIn.hs - + testsuite/tests/simplCore/should_compile/T22662.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/FloatIn.hs ===================================== @@ -35,9 +35,12 @@ import GHC.Types.Var import GHC.Types.Var.Set import GHC.Utils.Misc -import GHC.Utils.Panic import GHC.Utils.Panic.Plain +import GHC.Utils.Outputable + +import Data.List ( mapAccumL ) + {- Top-level interface function, @floatInwards at . Note that we do not actually float any bindings downwards from the top-level. @@ -124,7 +127,7 @@ the closure for a is not built. ************************************************************************ -} -type FreeVarSet = DIdSet +type FreeVarSet = DVarSet type BoundVarSet = DIdSet data FloatInBind = FB BoundVarSet FreeVarSet FloatBind @@ -132,11 +135,17 @@ data FloatInBind = FB BoundVarSet FreeVarSet FloatBind -- of recursive bindings, the set doesn't include the bound -- variables. -type FloatInBinds = [FloatInBind] - -- In reverse dependency order (innermost binder first) +type FloatInBinds = [FloatInBind] -- In normal dependency order + -- (outermost binder first) +type RevFloatInBinds = [FloatInBind] -- In reverse dependency order + -- (innermost binder first) + +instance Outputable FloatInBind where + ppr (FB bvs fvs _) = text "FB" <> braces (sep [ text "bndrs =" <+> ppr bvs + , text "fvs =" <+> ppr fvs ]) fiExpr :: Platform - -> FloatInBinds -- Binds we're trying to drop + -> RevFloatInBinds -- Binds we're trying to drop -- as far "inwards" as possible -> CoreExprWithFVs -- Input expr -> CoreExpr -- Result @@ -147,13 +156,12 @@ fiExpr _ to_drop (_, AnnType ty) = assert (null to_drop) $ Type ty fiExpr _ to_drop (_, AnnVar v) = wrapFloats to_drop (Var v) fiExpr _ to_drop (_, AnnCoercion co) = wrapFloats to_drop (Coercion co) fiExpr platform to_drop (_, AnnCast expr (co_ann, co)) - = wrapFloats (drop_here ++ co_drop) $ + = wrapFloats drop_here $ Cast (fiExpr platform e_drop expr) co where - [drop_here, e_drop, co_drop] - = sepBindsByDropPoint platform False - [freeVarsOf expr, freeVarsOfAnn co_ann] - to_drop + (drop_here, [e_drop]) + = sepBindsByDropPoint platform False to_drop + (freeVarsOfAnn co_ann) [freeVarsOf expr] {- Applications: we do float inside applications, mainly because we @@ -162,7 +170,7 @@ pull out any silly ones. -} fiExpr platform to_drop ann_expr@(_,AnnApp {}) - = wrapFloats drop_here $ wrapFloats extra_drop $ + = wrapFloats drop_here $ mkTicks ticks $ mkApps (fiExpr platform fun_drop ann_fun) (zipWithEqual "fiExpr" (fiExpr platform) arg_drops ann_args) @@ -170,21 +178,19 @@ fiExpr platform to_drop ann_expr@(_,AnnApp {}) -- length ann_args = length arg_fvs = length arg_drops where (ann_fun, ann_args, ticks) = collectAnnArgsTicks tickishFloatable ann_expr - fun_ty = exprType (deAnnotate ann_fun) fun_fvs = freeVarsOf ann_fun - arg_fvs = map freeVarsOf ann_args - (drop_here : extra_drop : fun_drop : arg_drops) - = sepBindsByDropPoint platform False - (extra_fvs : fun_fvs : arg_fvs) - to_drop + (drop_here, fun_drop : arg_drops) + = sepBindsByDropPoint platform False to_drop + here_fvs (fun_fvs : arg_fvs) + -- Shortcut behaviour: if to_drop is empty, -- sepBindsByDropPoint returns a suitable bunch of empty -- lists without evaluating extra_fvs, and hence without -- peering into each argument - (_, extra_fvs) = foldl' add_arg (fun_ty, extra_fvs0) ann_args - extra_fvs0 = case ann_fun of + (here_fvs, arg_fvs) = mapAccumL add_arg here_fvs0 ann_args + here_fvs0 = case ann_fun of (_, AnnVar _) -> fun_fvs _ -> emptyDVarSet -- Don't float the binding for f into f x y z; see Note [Join points] @@ -192,14 +198,11 @@ fiExpr platform to_drop ann_expr@(_,AnnApp {}) -- join point, floating it in isn't especially harmful but it's -- useless since the simplifier will immediately float it back out.) - add_arg :: (Type,FreeVarSet) -> CoreExprWithFVs -> (Type,FreeVarSet) - add_arg (fun_ty, extra_fvs) (_, AnnType ty) - = (piResultTy fun_ty ty, extra_fvs) - add_arg (fun_ty, extra_fvs) (arg_fvs, arg) - | noFloatIntoArg arg - = (funResultTy fun_ty, extra_fvs `unionDVarSet` arg_fvs) - | otherwise - = (funResultTy fun_ty, extra_fvs) + add_arg :: FreeVarSet -> CoreExprWithFVs -> (FreeVarSet,FreeVarSet) + -- We can't float into some arguments, so put them into the here_fvs + add_arg here_fvs (arg_fvs, arg) + | noFloatIntoArg arg = (here_fvs `unionDVarSet` arg_fvs, emptyDVarSet) + | otherwise = (here_fvs, arg_fvs) {- Note [Dead bindings] ~~~~~~~~~~~~~~~~~~~~~~~ @@ -272,7 +275,6 @@ it's non-recursive, so we float only into non-recursive join points.) Urk! if all are tyvars, and we don't float in, we may miss an opportunity to float inside a nested case branch - Note [Floating coercions] ~~~~~~~~~~~~~~~~~~~~~~~~~ We could, in principle, have a coercion binding like @@ -292,6 +294,36 @@ of the types of all the drop points involved. If any of the floaters bind a coercion variable mentioned in any of the types, that binder must be dropped right away. +Note [Shadowing and name capture] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we have + let x = y+1 in + case p of + (y:ys) -> ...x... + [] -> blah +It is obviously bogus for FloatIn to transform to + case p of + (y:ys) -> ...(let x = y+1 in x)... + [] -> blah +because the y is captured. This doesn't happen much, because shadowing is +rare, but it did happen in #22662. + +One solution would be to clone as we go. But a simpler one is this: + + at a binding site (like that for (y:ys) above), abandon float-in for + any floating bindings that mention the binders (y, ys in this case) + +We achieve that by calling sepBindsByDropPoint with the binders in +the "used-here" set: + +* In fiExpr (AnnLam ...). For the body there is no need to delete + the lambda-binders from the body_fvs, because any bindings that + mention these binders will be dropped here anyway. + +* In fiExpr (AnnCase ...). Remember to include the case_bndr in the + binders. Again, no need to delete the alt binders from the rhs + free vars, beause any bindings mentioning them will be dropped + here unconditionally. -} fiExpr platform to_drop lam@(_, AnnLam _ _) @@ -300,10 +332,17 @@ fiExpr platform to_drop lam@(_, AnnLam _ _) = wrapFloats to_drop (mkLams bndrs (fiExpr platform [] body)) | otherwise -- Float inside - = mkLams bndrs (fiExpr platform to_drop body) + = wrapFloats drop_here $ + mkLams bndrs (fiExpr platform body_drop body) where (bndrs, body) = collectAnnBndrs lam + body_fvs = freeVarsOf body + + -- Why sepBindsByDropPoint? Because of potential capture + -- See Note [Shadowing and name capture] + (drop_here, [body_drop]) = sepBindsByDropPoint platform False to_drop + (mkDVarSet bndrs) [body_fvs] {- We don't float lets inwards past an SCC. @@ -443,16 +482,16 @@ fiExpr platform to_drop (_, AnnCase scrut case_bndr _ [AnnAlt con alt_bndrs rhs] = wrapFloats shared_binds $ fiExpr platform (case_float : rhs_binds) rhs where - case_float = FB (mkDVarSet (case_bndr : alt_bndrs)) scrut_fvs + case_float = FB all_bndrs scrut_fvs (FloatCase scrut' case_bndr con alt_bndrs) scrut' = fiExpr platform scrut_binds scrut - rhs_fvs = freeVarsOf rhs `delDVarSetList` (case_bndr : alt_bndrs) - scrut_fvs = freeVarsOf scrut + rhs_fvs = freeVarsOf rhs -- No need to delete alt_bndrs + scrut_fvs = freeVarsOf scrut -- See Note [Shadowing and name capture] + all_bndrs = mkDVarSet alt_bndrs `extendDVarSet` case_bndr - [shared_binds, scrut_binds, rhs_binds] - = sepBindsByDropPoint platform False - [scrut_fvs, rhs_fvs] - to_drop + (shared_binds, [scrut_binds, rhs_binds]) + = sepBindsByDropPoint platform False to_drop + all_bndrs [scrut_fvs, rhs_fvs] fiExpr platform to_drop (_, AnnCase scrut case_bndr ty alts) = wrapFloats drop_here1 $ @@ -462,39 +501,43 @@ fiExpr platform to_drop (_, AnnCase scrut case_bndr ty alts) -- use zipWithEqual, we should have length alts_drops_s = length alts where -- Float into the scrut and alts-considered-together just like App - [drop_here1, scrut_drops, alts_drops] - = sepBindsByDropPoint platform False - [scrut_fvs, all_alts_fvs] - to_drop + (drop_here1, [scrut_drops, alts_drops]) + = sepBindsByDropPoint platform False to_drop + all_alt_bndrs [scrut_fvs, all_alt_fvs] + -- all_alt_bndrs: see Note [Shadowing and name capture] -- Float into the alts with the is_case flag set - (drop_here2 : alts_drops_s) - | [ _ ] <- alts = [] : [alts_drops] - | otherwise = sepBindsByDropPoint platform True alts_fvs alts_drops - - scrut_fvs = freeVarsOf scrut - alts_fvs = map alt_fvs alts - all_alts_fvs = unionDVarSets alts_fvs - alt_fvs (AnnAlt _con args rhs) - = foldl' delDVarSet (freeVarsOf rhs) (case_bndr:args) - -- Delete case_bndr and args from free vars of rhs - -- to get free vars of alt + (drop_here2, alts_drops_s) + = sepBindsByDropPoint platform True alts_drops emptyDVarSet alts_fvs + + scrut_fvs = freeVarsOf scrut + + all_alt_bndrs = foldr (unionDVarSet . ann_alt_bndrs) (unitDVarSet case_bndr) alts + ann_alt_bndrs (AnnAlt _ bndrs _) = mkDVarSet bndrs + + alts_fvs :: [DVarSet] + alts_fvs = [freeVarsOf rhs | AnnAlt _ _ rhs <- alts] + -- No need to delete binders + -- See Note [Shadowing and name capture] + + all_alt_fvs :: DVarSet + all_alt_fvs = foldr unionDVarSet (unitDVarSet case_bndr) alts_fvs fi_alt to_drop (AnnAlt con args rhs) = Alt con args (fiExpr platform to_drop rhs) ------------------ fiBind :: Platform - -> FloatInBinds -- Binds we're trying to drop - -- as far "inwards" as possible - -> CoreBindWithFVs -- Input binding - -> DVarSet -- Free in scope of binding - -> ( FloatInBinds -- Land these before - , FloatInBind -- The binding itself - , FloatInBinds) -- Land these after + -> RevFloatInBinds -- Binds we're trying to drop + -- as far "inwards" as possible + -> CoreBindWithFVs -- Input binding + -> DVarSet -- Free in scope of binding + -> ( RevFloatInBinds -- Land these before + , FloatInBind -- The binding itself + , RevFloatInBinds) -- Land these after fiBind platform to_drop (AnnNonRec id ann_rhs@(rhs_fvs, rhs)) body_fvs - = ( extra_binds ++ shared_binds -- Land these before - -- See Note [extra_fvs (1)] and Note [extra_fvs (2)] + = ( shared_binds -- Land these before + -- See Note [extra_fvs (1)] and Note [extra_fvs (2)] , FB (unitDVarSet id) rhs_fvs' -- The new binding itself (FloatLet (NonRec id rhs')) , body_binds ) -- Land these after @@ -512,10 +555,9 @@ fiBind platform to_drop (AnnNonRec id ann_rhs@(rhs_fvs, rhs)) body_fvs -- We *can't* float into ok-for-speculation unlifted RHSs -- But do float into join points - [shared_binds, extra_binds, rhs_binds, body_binds] - = sepBindsByDropPoint platform False - [extra_fvs, rhs_fvs, body_fvs2] - to_drop + (shared_binds, [rhs_binds, body_binds]) + = sepBindsByDropPoint platform False to_drop + extra_fvs [rhs_fvs, body_fvs2] -- Push rhs_binds into the right hand side of the binding rhs' = fiRhs platform rhs_binds id ann_rhs @@ -523,7 +565,7 @@ fiBind platform to_drop (AnnNonRec id ann_rhs@(rhs_fvs, rhs)) body_fvs -- Don't forget the rule_fvs; the binding mentions them! fiBind platform to_drop (AnnRec bindings) body_fvs - = ( extra_binds ++ shared_binds + = ( shared_binds , FB (mkDVarSet ids) rhs_fvs' (FloatLet (Rec (fi_bind rhss_binds bindings))) , body_binds ) @@ -537,17 +579,16 @@ fiBind platform to_drop (AnnRec bindings) body_fvs unionDVarSets [ rhs_fvs | (bndr, (rhs_fvs, rhs)) <- bindings , noFloatIntoRhs Recursive bndr rhs ] - (shared_binds:extra_binds:body_binds:rhss_binds) - = sepBindsByDropPoint platform False - (extra_fvs:body_fvs:rhss_fvs) - to_drop + (shared_binds, body_binds:rhss_binds) + = sepBindsByDropPoint platform False to_drop + extra_fvs (body_fvs:rhss_fvs) rhs_fvs' = unionDVarSets rhss_fvs `unionDVarSet` unionDVarSets (map floatedBindsFVs rhss_binds) `unionDVarSet` rule_fvs -- Don't forget the rule variables! -- Push rhs_binds into the right hand side of the binding - fi_bind :: [FloatInBinds] -- one per "drop pt" conjured w/ fvs_of_rhss + fi_bind :: [RevFloatInBinds] -- One per "drop pt" conjured w/ fvs_of_rhss -> [(Id, CoreExprWithFVs)] -> [(Id, CoreExpr)] @@ -556,7 +597,7 @@ fiBind platform to_drop (AnnRec bindings) body_fvs | ((binder, rhs), to_drop) <- zipEqual "fi_bind" pairs to_drops ] ------------------ -fiRhs :: Platform -> FloatInBinds -> CoreBndr -> CoreExprWithFVs -> CoreExpr +fiRhs :: Platform -> RevFloatInBinds -> CoreBndr -> CoreExprWithFVs -> CoreExpr fiRhs platform to_drop bndr rhs | Just join_arity <- isJoinId_maybe bndr , let (bndrs, body) = collectNAnnBndrs join_arity rhs @@ -656,68 +697,84 @@ point. We have to maintain the order on these drop-point-related lists. -} --- pprFIB :: FloatInBinds -> SDoc +-- pprFIB :: RevFloatInBinds -> SDoc -- pprFIB fibs = text "FIB:" <+> ppr [b | FB _ _ b <- fibs] sepBindsByDropPoint :: Platform - -> Bool -- True <=> is case expression - -> [FreeVarSet] -- One set of FVs per drop point - -- Always at least two long! - -> FloatInBinds -- Candidate floaters - -> [FloatInBinds] -- FIRST one is bindings which must not be floated - -- inside any drop point; the rest correspond - -- one-to-one with the input list of FV sets + -> Bool -- True <=> is case expression + -> RevFloatInBinds -- Candidate floaters + -> FreeVarSet -- here_fvs: if these vars are free in a binding, + -- don't float that binding inside any drop point + -> [FreeVarSet] -- fork_fvs: one set of FVs per drop point + -> ( RevFloatInBinds -- Bindings which must not be floated inside + , [RevFloatInBinds] ) -- Corresponds 1-1 with the input list of FV sets -- Every input floater is returned somewhere in the result; -- none are dropped, not even ones which don't seem to be -- free in *any* of the drop-point fvs. Why? Because, for example, -- a binding (let x = E in B) might have a specialised version of -- x (say x') stored inside x, but x' isn't free in E or B. +-- +-- The here_fvs argument is used for two things: +-- * Avoid shadowing bugs: see Note [Shadowing and name capture] +-- * Drop some of the bindings at the top, e.g. of an application type DropBox = (FreeVarSet, FloatInBinds) -sepBindsByDropPoint platform is_case drop_pts floaters +dropBoxFloats :: DropBox -> RevFloatInBinds +dropBoxFloats (_, floats) = reverse floats + +usedInDropBox :: DIdSet -> DropBox -> Bool +usedInDropBox bndrs (db_fvs, _) = db_fvs `intersectsDVarSet` bndrs + +initDropBox :: DVarSet -> DropBox +initDropBox fvs = (fvs, []) + +sepBindsByDropPoint platform is_case floaters here_fvs fork_fvs | null floaters -- Shortcut common case - = [] : [[] | _ <- drop_pts] + = ([], [[] | _ <- fork_fvs]) | otherwise - = assert (drop_pts `lengthAtLeast` 2) $ - go floaters (map (\fvs -> (fvs, [])) (emptyDVarSet : drop_pts)) + = go floaters (initDropBox here_fvs) (map initDropBox fork_fvs) where - n_alts = length drop_pts + n_alts = length fork_fvs - go :: FloatInBinds -> [DropBox] -> [FloatInBinds] - -- The *first* one in the argument list is the drop_here set - -- The FloatInBinds in the lists are in the reverse of - -- the normal FloatInBinds order; that is, they are the right way round! + go :: RevFloatInBinds -> DropBox -> [DropBox] + -> (RevFloatInBinds, [RevFloatInBinds]) + -- The *first* one in the pair is the drop_here set - go [] drop_boxes = map (reverse . snd) drop_boxes + go [] here_box fork_boxes + = (dropBoxFloats here_box, map dropBoxFloats fork_boxes) - go (bind_w_fvs@(FB bndrs bind_fvs bind) : binds) drop_boxes@(here_box : fork_boxes) - = go binds new_boxes + go (bind_w_fvs@(FB bndrs bind_fvs bind) : binds) here_box fork_boxes + | drop_here = go binds (insert here_box) fork_boxes + | otherwise = go binds here_box new_fork_boxes where -- "here" means the group of bindings dropped at the top of the fork - (used_here : used_in_flags) = [ fvs `intersectsDVarSet` bndrs - | (fvs, _) <- drop_boxes] + used_here = bndrs `usedInDropBox` here_box + used_in_flags = case fork_boxes of + [] -> [] + [_] -> [True] -- Push all bindings into a single branch + -- No need to look at its free vars + _ -> map (bndrs `usedInDropBox`) fork_boxes + -- Short-cut for the singleton case; + -- used for lambdas and singleton cases drop_here = used_here || cant_push n_used_alts = count id used_in_flags -- returns number of Trues in list. cant_push - | is_case = n_used_alts == n_alts -- Used in all, don't push - -- Remember n_alts > 1 + | is_case = (n_alts > 1 && n_used_alts == n_alts) + -- Used in all, muliple branches, don't push || (n_used_alts > 1 && not (floatIsDupable platform bind)) -- floatIsDupable: see Note [Duplicating floats] | otherwise = floatIsCase bind || n_used_alts > 1 -- floatIsCase: see Note [Floating primops] - new_boxes | drop_here = (insert here_box : fork_boxes) - | otherwise = (here_box : new_fork_boxes) - new_fork_boxes = zipWithEqual "FloatIn.sepBinds" insert_maybe fork_boxes used_in_flags @@ -727,8 +784,6 @@ sepBindsByDropPoint platform is_case drop_pts floaters insert_maybe box True = insert box insert_maybe box False = box - go _ _ = panic "sepBindsByDropPoint/go" - {- Note [Duplicating floats] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -745,14 +800,14 @@ If the thing is used in all RHSs there is nothing gained, so we don't duplicate then. -} -floatedBindsFVs :: FloatInBinds -> FreeVarSet +floatedBindsFVs :: RevFloatInBinds -> FreeVarSet floatedBindsFVs binds = mapUnionDVarSet fbFVs binds fbFVs :: FloatInBind -> DVarSet fbFVs (FB _ fvs _) = fvs -wrapFloats :: FloatInBinds -> CoreExpr -> CoreExpr --- Remember FloatInBinds is in *reverse* dependency order +wrapFloats :: RevFloatInBinds -> CoreExpr -> CoreExpr +-- Remember RevFloatInBinds is in *reverse* dependency order wrapFloats [] e = e wrapFloats (FB _ _ fl : bs) e = wrapFloats bs (wrapFloat fl e) ===================================== testsuite/tests/simplCore/should_compile/T22662.hs ===================================== @@ -0,0 +1,6 @@ +module T22662 where + +import Data.Set + +foo x = sequence_ [ f y | y <- x ] + where f _ = return (fromList [0]) ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -461,3 +461,4 @@ 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, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) +test('T22662', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6206cb9287f3f6e70c669660a646a65274870d2b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6206cb9287f3f6e70c669660a646a65274870d2b You're receiving 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 Jan 7 17:15:31 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 07 Jan 2023 12:15:31 -0500 Subject: [Git][ghc/ghc][master] 3 commits: T10955: Set DYLD_LIBRARY_PATH for darwin Message-ID: <63b9a8b38f31_c35a1550c8162043@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s - - - - - 73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. - - - - - 8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - 4 changed files: - configure.ac - + m4/fp_ld_no_fixup_chains.m4 - testsuite/tests/ghci/linking/dyn/Makefile - testsuite/tests/rts/T18623/all.T Changes: ===================================== configure.ac ===================================== @@ -658,6 +658,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) # Stage 3 won't be supported by cross-compilation +FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) +FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + GHC_LLVM_TARGET_SET_VAR # we intend to pass trough --targets to llvm as is. LLVMTarget_CPP=` echo "$LlvmTarget"` ===================================== m4/fp_ld_no_fixup_chains.m4 ===================================== @@ -0,0 +1,24 @@ +# FP_LD_NO_FIXUP_CHAINS +# -------------------- +# See if whether we are using a version of ld64 on darwin platforms which +# requires us to pass -no_fixup_chains +# +# $1 = the platform +# $2 = the name of the linker flags variable when linking with $CC +AC_DEFUN([FP_LD_NO_FIXUP_CHAINS], [ + case $$1 in + *-darwin) + AC_MSG_CHECKING([whether ld64 requires -no_fixup_chains]) + echo 'int main(void) {return 0;}' > conftest.c + if $CC -o conftest.o -Wl,-no_fixup_chains conftest.c > /dev/null 2>&1 + then + $2="-Wl,-no_fixup_chains" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + rm -f conftest.c conftest.o + ;; + + esac +]) ===================================== testsuite/tests/ghci/linking/dyn/Makefile ===================================== @@ -84,7 +84,7 @@ compile_libAB_dyn: '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_dyn" -shared B.c -o "bin_dyn/$(call DLL,B)" $(call DEF,B) -lA -L"./bin_dyn" rm -f bin_dyn/*.a '$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -v0 -o "bin_dyn/$(call EXE,T10955dyn)" -L./bin_dyn -lB -lA T10955dyn.hs -v0 - LD_LIBRARY_PATH=./bin_dyn ./bin_dyn/$(call EXE,T10955dyn) + DYLD_LIBRARY_PATH=./bin_dyn LD_LIBRARY_PATH=./bin_dyn ./bin_dyn/$(call EXE,T10955dyn) .PHONY: compile_libAS_impl_gcc compile_libAS_impl_gcc: ===================================== testsuite/tests/rts/T18623/all.T ===================================== @@ -5,6 +5,8 @@ test('T18623', # This keeps failing on aarch64-linux for reasons that are not # fully clear. Maybe it needs a higher limit due to LLVM? when(arch('aarch64'), skip), + # Recent versions of osx report an error when running `ulimit -v` + when(arch('darwin'), skip), when(arch('powerpc64le'), skip), cmd_prefix('ulimit -v ' + str(1024 ** 2) + ' && '), ignore_stdout], View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6206cb9287f3f6e70c669660a646a65274870d2b...8c0ea25fb4a27d4729aabf73f4c00b912bb0c58d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6206cb9287f3f6e70c669660a646a65274870d2b...8c0ea25fb4a27d4729aabf73f4c00b912bb0c58d You're receiving 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 Jan 7 17:32:00 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Sat, 07 Jan 2023 12:32:00 -0500 Subject: [Git][ghc/ghc][ghc-9.6] 3 commits: T10955: Set DYLD_LIBRARY_PATH for darwin Message-ID: <63b9ac90c0d87_c35a1550b41640c7@gitlab.mail> Matthew Pickering pushed to branch ghc-9.6 at Glasgow Haskell Compiler / GHC Commits: 0e8aa04f by Matthew Pickering at 2023-01-07T17:31:37+00:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s (cherry picked from commit a960ca817d6ad0109ea6edda50da3902cc538e86) - - - - - 95e68d38 by Matthew Pickering at 2023-01-07T17:31:37+00:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. (cherry picked from commit 734847108420cf826a807c30ad54651659cf3a08) - - - - - a587499c by Matthew Pickering at 2023-01-07T17:31:37+00:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes (cherry picked from commit 8c0ea25fb4a27d4729aabf73f4c00b912bb0c58d) - - - - - 4 changed files: - configure.ac - + m4/fp_ld_no_fixup_chains.m4 - testsuite/tests/ghci/linking/dyn/Makefile - testsuite/tests/rts/T18623/all.T Changes: ===================================== configure.ac ===================================== @@ -658,6 +658,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) # Stage 3 won't be supported by cross-compilation +FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) +FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + GHC_LLVM_TARGET_SET_VAR # we intend to pass trough --targets to llvm as is. LLVMTarget_CPP=` echo "$LlvmTarget"` ===================================== m4/fp_ld_no_fixup_chains.m4 ===================================== @@ -0,0 +1,24 @@ +# FP_LD_NO_FIXUP_CHAINS +# -------------------- +# See if whether we are using a version of ld64 on darwin platforms which +# requires us to pass -no_fixup_chains +# +# $1 = the platform +# $2 = the name of the linker flags variable when linking with $CC +AC_DEFUN([FP_LD_NO_FIXUP_CHAINS], [ + case $$1 in + *-darwin) + AC_MSG_CHECKING([whether ld64 requires -no_fixup_chains]) + echo 'int main(void) {return 0;}' > conftest.c + if $CC -o conftest.o -Wl,-no_fixup_chains conftest.c > /dev/null 2>&1 + then + $2="-Wl,-no_fixup_chains" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + rm -f conftest.c conftest.o + ;; + + esac +]) ===================================== testsuite/tests/ghci/linking/dyn/Makefile ===================================== @@ -84,7 +84,7 @@ compile_libAB_dyn: '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_dyn" -shared B.c -o "bin_dyn/$(call DLL,B)" $(call DEF,B) -lA -L"./bin_dyn" rm -f bin_dyn/*.a '$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -v0 -o "bin_dyn/$(call EXE,T10955dyn)" -L./bin_dyn -lB -lA T10955dyn.hs -v0 - LD_LIBRARY_PATH=./bin_dyn ./bin_dyn/$(call EXE,T10955dyn) + DYLD_LIBRARY_PATH=./bin_dyn LD_LIBRARY_PATH=./bin_dyn ./bin_dyn/$(call EXE,T10955dyn) .PHONY: compile_libAS_impl_gcc compile_libAS_impl_gcc: ===================================== testsuite/tests/rts/T18623/all.T ===================================== @@ -5,6 +5,8 @@ test('T18623', # This keeps failing on aarch64-linux for reasons that are not # fully clear. Maybe it needs a higher limit due to LLVM? when(arch('aarch64'), skip), + # Recent versions of osx report an error when running `ulimit -v` + when(arch('darwin'), skip), when(arch('powerpc64le'), skip), cmd_prefix('ulimit -v ' + str(1024 ** 2) + ' && '), ignore_stdout], View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/80601b0e774003da257819ee722d2cfdf711c580...a587499c6dc8a7e7e646e9c5f246903a4cc99e56 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/80601b0e774003da257819ee722d2cfdf711c580...a587499c6dc8a7e7e646e9c5f246903a4cc99e56 You're receiving 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 Jan 7 18:13:57 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Sat, 07 Jan 2023 13:13:57 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/no_fixup_chains_2 Message-ID: <63b9b6656dcea_c35a1550f017071f@gitlab.mail> Matthew Pickering pushed new branch wip/no_fixup_chains_2 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/no_fixup_chains_2 You're receiving 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 Jan 8 05:26:18 2023 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Sun, 08 Jan 2023 00:26:18 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] 18 commits: Add support for sized literals in the bytecode interpreter. Message-ID: <63ba53faf1b5e_136d98526349487e@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00 Add support for sized literals in the bytecode interpreter. The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945 - - - - - ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00 rts: MUT_VAR is not a StgMutArrPtrs There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs. - - - - - 6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s - - - - - 73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. - - - - - 8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - fdba0a60 by Luite Stegeman at 2023-01-08T14:23:54+09:00 Add PrimCallConv suppport to GHCi - - - - - 9c9fc6af by Luite Stegeman at 2023-01-08T14:23:54+09:00 make bytecode assembler assertion failures more descriptive - - - - - 699de3e5 by Luite Stegeman at 2023-01-08T14:23:54+09:00 fix typo in testcase - - - - - 63d009b9 by Luite Stegeman at 2023-01-08T14:23:54+09:00 fix whitespace - - - - - 486906fe by Luite Stegeman at 2023-01-08T14:23:55+09:00 fix GHCiPrimCall expected output - - - - - b9dcc607 by Luite Stegeman at 2023-01-08T14:23:55+09:00 add GHCiPrimCall expected test output for wordsize 32 - - - - - 5e31366d by Luite Stegeman at 2023-01-08T14:23:55+09:00 re-enable some disabled testcases in GHCiPrimCall test - - - - - a054e549 by Luite Stegeman at 2023-01-08T14:23:55+09:00 add type sig again - - - - - 0a6347fc by Luite Stegeman at 2023-01-08T14:23:55+09:00 correct GHCiPrimCall word size 32 expected result - - - - - 30 changed files: - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Foreign.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Match.hs-boot - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Utils/Outputable.hs - compiler/Language/Haskell/Syntax/Expr.hs - configure.ac - + m4/fp_ld_no_fixup_chains.m4 - rts/Disassembler.c - rts/Interpreter.c - rts/RtsSymbols.c - rts/StgMiscClosures.cmm The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee171e8b127a7f11aedbfe45e284f08636588dec...0a6347fc57013d1a3edccdf4a801cb2e4a230836 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee171e8b127a7f11aedbfe45e284f08636588dec...0a6347fc57013d1a3edccdf4a801cb2e4a230836 You're receiving 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 Jan 8 11:59:11 2023 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Sun, 08 Jan 2023 06:59:11 -0500 Subject: [Git][ghc/ghc][wip/req_smp] testsuite: req_host_smp --> req_ghc_smp Message-ID: <63bab00f9ba8e_136d98d35979410749b@gitlab.mail> doyougnu pushed to branch wip/req_smp at Glasgow Haskell Compiler / GHC Commits: 84c4bd6c by doyougnu at 2023-01-08T06:59:01-05:00 testsuite: req_host_smp --> req_ghc_smp - - - - - 11 changed files: - libraries/base/tests/all.T - testsuite/driver/testlib.py - testsuite/tests/codeGen/should_run/all.T - testsuite/tests/concurrent/should_run/all.T - testsuite/tests/driver/T14075/all.T - testsuite/tests/driver/T20030/test1/all.T - testsuite/tests/driver/j-space/all.T - testsuite/tests/driver/t22391/all.T - testsuite/tests/ffi/should_run/all.T - testsuite/tests/rts/all.T - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== libraries/base/tests/all.T ===================================== @@ -240,7 +240,7 @@ test('T11555', normal, compile_and_run, ['']) test('T12494', normal, compile_and_run, ['']) test('T12852', [when(opsys('mingw32'), skip), js_broken(22374)], compile_and_run, ['']) test('lazySTexamples', normal, compile_and_run, ['']) -test('T11760', [req_host_smp, req_target_smp], compile_and_run, ['-threaded -with-rtsopts=-N2']) +test('T11760', [req_ghc_smp, req_target_smp], compile_and_run, ['-threaded -with-rtsopts=-N2']) test('T12874', normal, compile_and_run, ['']) test('T13191', [ collect_stats('bytes allocated', 5) ===================================== testsuite/driver/testlib.py ===================================== @@ -296,7 +296,7 @@ def req_th( name, opts ): if ghc_dynamic(): return _omit_ways(name, opts, ['profasm', 'profthreaded']) -def req_host_smp( name, opts ): +def req_ghc_smp( name, opts ): """ Mark a test as requiring the host to be linked with an RTS that supports smp. Use this when the test needs to be compiled with smp support, but may ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -156,7 +156,7 @@ test('T10246', normal, compile_and_run, ['']) test('T9533', normal, compile_and_run, ['']) test('T9533b', normal, compile_and_run, ['']) test('T9533c', normal, compile_and_run, ['']) -test('T10414', [only_ways(['threaded2']), extra_ways(['threaded2']), req_target_smp, req_host_smp], +test('T10414', [only_ways(['threaded2']), extra_ways(['threaded2']), req_target_smp, req_ghc_smp], compile_and_run, ['-feager-blackholing']) test('T10521', normal, compile_and_run, ['']) test('T10521b', normal, compile_and_run, ['']) ===================================== testsuite/tests/concurrent/should_run/all.T ===================================== @@ -241,7 +241,7 @@ test('setnumcapabilities001', extra_run_opts('8 12 2000'), when(have_thread_sanitizer(), expect_broken(18808)), req_target_smp, - req_host_smp + req_ghc_smp ], compile_and_run, ['']) @@ -251,7 +251,7 @@ test('T21651', when(opsys('darwin'),extra_run_opts('8 12 2000 100')), unless(opsys('darwin'),extra_run_opts('8 12 2000 200')), # darwin runners complain of too many open files req_target_smp, - req_host_smp + req_ghc_smp ], compile_and_run, ['']) ===================================== testsuite/tests/driver/T14075/all.T ===================================== @@ -1,6 +1,6 @@ test('T14075', [ extra_files(['F.hs', 'F.hs-boot', 'O.hs', 'V.hs', 'V.hs-boot']) - , req_host_smp # uses ghc --make -j2 + , req_ghc_smp # uses ghc --make -j2 , js_broken(22261) ], makefile_test, []) ===================================== testsuite/tests/driver/T20030/test1/all.T ===================================== @@ -10,6 +10,6 @@ test('T20030_test1j', , 'D.hs' , 'E.hs-boot' , 'E.hs' , 'F.hs' , 'G.hs' , 'H.hs' , 'I.hs', 'J.hs-boot', 'J.hs', 'K.hs' ]) , req_target_smp - , req_host_smp + , req_ghc_smp ], multimod_compile, ['I.hs K.hs', '-v1 -j']) ===================================== testsuite/tests/driver/j-space/all.T ===================================== @@ -1 +1 @@ -test('jspace', [extra_files(['genJspace']), req_target_smp, req_host_smp], makefile_test, ['jspace']) +test('jspace', [extra_files(['genJspace']), req_target_smp, req_ghc_smp], makefile_test, ['jspace']) ===================================== testsuite/tests/driver/t22391/all.T ===================================== @@ -1,5 +1,5 @@ test('t22391', [extra_files(['src'])], multimod_compile, ['Lib', '-v1 -Wall -fhide-source-paths -isrc -fdefer-diagnostics']) -test('t22391j', [req_target_smp, req_host_smp, extra_files(['src'])], +test('t22391j', [req_target_smp, req_ghc_smp, extra_files(['src'])], multimod_compile, ['Lib', '-v1 -Wall -fhide-source-paths -isrc -fdefer-diagnostics -j2']) ===================================== testsuite/tests/ffi/should_run/all.T ===================================== @@ -235,7 +235,7 @@ test('T17471', [omit_ways(['ghci']), req_c], compile_and_run, ['T17471_c.c -optc-D -optcFOO']) test('IncallAffinity', - [req_target_smp, req_host_smp, only_ways(['threaded1', 'threaded2']), + [req_target_smp, req_ghc_smp, only_ways(['threaded1', 'threaded2']), # Unregisterised build doesn't support when(unregisterised(), skip), req_c], ===================================== testsuite/tests/rts/all.T ===================================== @@ -286,7 +286,7 @@ test('stablename001', expect_fail_for(['hpc']), compile_and_run, ['']) test('T7815', [ multi_cpu_race, extra_run_opts('50000 +RTS -N2 -RTS'), - req_target_smp, req_host_smp, + req_target_smp, req_ghc_smp, only_ways(['threaded1', 'threaded2']) ], compile_and_run, [''] ) # ignore_stderr because it contains a unique: @@ -305,10 +305,10 @@ test('T7919', [ when(fast(), skip) test('T8035', normal, compile_and_run, ['']) -test('T8209', [ req_target_smp, req_host_smp, only_ways(threaded_ways), ignore_stdout ], +test('T8209', [ req_target_smp, req_ghc_smp, only_ways(threaded_ways), ignore_stdout ], compile_and_run, ['']) -test('T8242', [ req_target_smp, req_host_smp, only_ways(threaded_ways), ignore_stdout ], +test('T8242', [ req_target_smp, req_ghc_smp, only_ways(threaded_ways), ignore_stdout ], compile_and_run, ['']) test('T8124', [ only_ways(threaded_ways), omit_ways(['ghci']), @@ -330,7 +330,7 @@ test('T9078', only_ways(['threaded1']), compile_and_run, ['']) test('T10017', [ when(opsys('mingw32'), skip) , when(unregisterised(), skip) , req_target_smp - , req_host_smp + , req_ghc_smp , only_ways(threaded_ways), extra_run_opts('+RTS -N2 -RTS') ], compile_and_run, ['']) test('T11108', normal, compile_and_run, ['']) @@ -403,7 +403,7 @@ test('T11788', [ when(ghc_dynamic(), skip) , req_interp ], makefile_test, ['T11788']) -test('T10296a', [req_host_smp], makefile_test, ['T10296a']) +test('T10296a', [req_ghc_smp], makefile_test, ['T10296a']) test('T10296b', [only_ways(['threaded2'])], compile_and_run, ['']) @@ -457,7 +457,7 @@ test('alloccounter1', js_broken(22261), compile_and_run, test('nursery-chunks1', [ extra_run_opts('4 100 +RTS -n32k -A1m -RTS') - , req_host_smp + , req_ghc_smp , req_target_smp , only_ways(['threaded1','threaded2']) ], ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -412,7 +412,7 @@ test('T11990a', normal, compile_fail, ['']) test('T11990b', normal, compile_fail, ['']) test('T12035', [], multimod_compile_fail, ['T12035', '-v0']) test('T12035j', [ extra_files(['T12035.hs', 'T12035a.hs', 'T12035.hs-boot']) - , req_host_smp + , req_ghc_smp , js_broken(22261) ], multimod_compile_fail, ['T12035', '-j2 -v0']) test('T12045b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84c4bd6c36b7e5a4599c9e371ce06fa96f29d744 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84c4bd6c36b7e5a4599c9e371ce06fa96f29d744 You're receiving 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 Jan 8 14:26:58 2023 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Sun, 08 Jan 2023 09:26:58 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] finish documentation on call_info word and some minor cleanups Message-ID: <63bad2b2ace98_136d985265c127452@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: ae1dfed9 by Luite Stegeman at 2023-01-08T23:26:20+09:00 finish documentation on call_info word and some minor cleanups - - - - - 4 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/StgToByteCode.hs - rts/StgMiscClosures.cmm Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -600,7 +600,7 @@ maxPrimCallNativeStackSize = 255 mkNativeCallInfoSig :: Platform -> NativeCallInfo -> Word32 mkNativeCallInfoSig platform NativeCallInfo{..} | nativeCallType == NativePrimCall && nativeCallStackSpillSize > maxPrimCallNativeStackSize - = pprPanic "mkNativeCallInfoSig: call too big for the bytecode compiler" + = pprPanic "mkNativeCallInfoSig: native call too big for the bytecode compiler" (ppr nativeCallStackSpillSize <+> text "stack words." <+> text "Use -fobject-code to get around this limit" ) ===================================== compiler/GHC/Cmm/CallConv.hs ===================================== @@ -224,7 +224,7 @@ realArgRegsCover platform {- Note [GHCi and native call registers] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The GHCi bytecode interpreter does not have access to the STG registers that the native calling convention uses for passing arguments. It uses @@ -233,7 +233,7 @@ realArgRegsCover platform If only a single register needs to be moved, GHCi uses a specific stack frame. For example stg_ctoi_R1p saves a heap pointer value from STG register R1 and stg_ctoi_D1 saves a double precision floating point value from D1. - In the other directin, helpers stg_ret_p and stg_ret_d move a value from + In the other direction, helpers stg_ret_p and stg_ret_d move a value from the stack to the R1 and D1 registers, respectively. When GHCi needs to move more than one register it cannot use a specific @@ -243,22 +243,73 @@ realArgRegsCover platform and the number of stack words used by the arguments of a call. These helper stack frames are currently: + - stg_ret_t: return a tuple to the continuation at the top of the stack - - stg_ctoi_t: convert a tuple value to be used in bytecode + - stg_ctoi_t: convert a tuple return value to be used in + bytecode - stg_primcall: call a function - The call_info word XXX incomplete!!! - XXX TODO + The call_info word contains a bitmap of the active registers + for the call and and a stack offset. The layout is as follows: + + - bit 0-23: Bitmap of active registers for the call, the + order corresponds to the list returned by + allArgRegsCover. For example if bit 0 (the least + significant bit) is set, the first register in the + allArgRegsCover list is active. Bit 1 for the + second register in the list and so on. + + - bit 24-31: Unsigned byte, indicating the stack usage of the + call in words (not counting the space ) + + The upper 32 bits on 64 bit platforms are currently unused. + + If a register is smaller than a word on the stack (for example a + single precision float on a 64 bit system), then the stack slot + is padded to a whole word. + + Example: + + If a call has three arguments passed registers and and + additional five words of arguments on the stack, then + three bits in the bitmap in bits 0-23 would be set. And + Bit 24-31 would be 00000010 (two in binary). + + The values on the stack before a call to POP_ARG_REGS would + be as follows: + + ... + stack_arg_1 + stack_arg_2 + register_arg_3 + register_arg_2 + register_arg_1 <- Sp + + A call to POP_ARG_REGS(call_info) would move register_arg_1 + to the register corresponding to the lowest set bit in the + call_info word. register_arg_2 would be moved to the register + corresponding to the second lowest set bit, and so on. - XXX TODO + After POP_ARG_REGS(call_info), the stack pointer Sp points + to the first stack slot below the stack arguments. The stack + arguments are still on the stack above Sp, so the stack looks + as follows: - XXX TODO + ... <- Sp + stack_arg_1 + stack_arg_2 - XXX TODO + At this point all the arguments are in place and we are ready + to jump to the native function. - XXX TODO + On x86_64, the double precision (Dn) and single precision + floating (Fn) point registers overlap, e.g. D1 uses the same + physical register as F1. On this platform, the list returned + by allArgRegsCover contains only entries for the double + precision registers. If an argument is passed in register + Fn, the bit corresponding to Dn should be set. Note: if anything changes in how registers for native calls overlap, make sure to also update GHC.StgToByteCode.layoutNativeCall ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -1250,7 +1250,6 @@ tupleBCO platform info pointers = body_code = mkSlideW 0 1 -- pop frame header `snocOL` RETURN_TUPLE -- and add it again --- XXX merge with tupleBCO primCallBCO :: Platform -> NativeCallInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name primCallBCO platform args_info pointers = mkProtoBCO platform invented_name body_code (Left []) ===================================== rts/StgMiscClosures.cmm ===================================== @@ -366,20 +366,10 @@ MK_STG_CTOI_T(61) MK_STG_CTOI_T(62) /* - Note [GHCi tuple layout] - ~~~~~~~~~~~~~~~~~~~~~~~~ - the tuple_info word describes the register and stack usage of the tuple: + Convert a tuple return value to be used in bytecode. - [ ssss ssss rrrr rrrr rrrr rrrr rrrr rrrr ] - - - r: bitmap of live registers, corresponding to the list of registers - returned by GHC.Cmm.CallConv.tupleRegsCover (the least significant - bit corresponds to the first element in the list) - - s: number of words on stack (in addition to registers) - - The order of the live registers in the bitmap is the same as the list - given by GHC.Cmm.CallConv.tupleRegsCover, with the least significant - bit corresponding to the first register in the list. + See Note [GHCi and native call registers] for information on how + values are moved between the stack and registers. */ stg_ctoi_t @@ -433,13 +423,9 @@ INFO_TABLE_RET( stg_ret_t, RET_BCO ) /* The stg_primcall frame is used by the bytecode interpreter to call - a Cmm function. The frame contains an args_info word that contains + a Cmm function. The frame contains a call_info word that contains a bitmap describing the register arguments. - The register arguments are moved to registers first (they are on - the stack in the order that POP_ARG_REGS expects) while the - remaining arguments are left on the stack. - When the target function is called, Sp points to the topmost stack argument. @@ -450,11 +436,13 @@ INFO_TABLE_RET( stg_ret_t, RET_BCO ) ... arg_n target_funptr (pointer to the function we're calling) - args_info (describes the registers containing the arguments) + call_info (describes the registers containing the arguments) primcall_BCO (contains bitmap describing pointers in args) stg_primcall_info <- Sp - - XXX describe register bitmaps + See Note [GHCi and native call registers] for information on the call_info + word and how registers are moved between the stack and registers. + */ INFO_TABLE_RET ( stg_primcall, RET_BCO ) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ae1dfed92faca6dc7fead5a14c524701a2167f17 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ae1dfed92faca6dc7fead5a14c524701a2167f17 You're receiving 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 Jan 8 14:35:54 2023 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Sun, 08 Jan 2023 09:35:54 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] minor cleanups Message-ID: <63bad4ca88538_136d985265c12798f@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 2fbcf50d by Luite Stegeman at 2023-01-08T23:35:38+09:00 minor cleanups - - - - - 3 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Foreign.hs Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -595,7 +595,7 @@ maxPrimCallNativeStackSize = 255 use to convert arguments between the native calling convention and the interpreter. - See Note [GHCi tuple layout] for more information. + See Note [GHCi and native call registers] for more information. -} mkNativeCallInfoSig :: Platform -> NativeCallInfo -> Word32 mkNativeCallInfoSig platform NativeCallInfo{..} ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -1065,7 +1065,6 @@ layoutNativeCall :: Profile ) layoutNativeCall profile call_type start_off arg_ty reps = let platform = profilePlatform profile - -- XXX is NativeReturn correct for both NativeTupleReturn and NativePrimCall? (orig_stk_bytes, pos) = assignArgumentsPos profile 0 NativeReturn ===================================== compiler/GHC/StgToCmm/Foreign.hs ===================================== @@ -349,7 +349,7 @@ emitRestoreRegs = do -- bytecode interpreter. -- -- The "live registers" bitmap corresponds to the list of registers given by --- 'actualArgRegsCover', with the least significant bit indicating liveness of +-- 'allArgRegsCover', with the least significant bit indicating liveness of -- the first register in the list. -- -- Each register is saved to a stack slot of one or more machine words, even View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2fbcf50d1142f5bb81076e43092286cfa6b3df54 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2fbcf50d1142f5bb81076e43092286cfa6b3df54 You're receiving 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 Jan 8 15:07:31 2023 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Sun, 08 Jan 2023 10:07:31 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] fix some docs and not references Message-ID: <63badc337283f_136d98110334e41342bd@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 858961bc by Luite Stegeman at 2023-01-09T00:06:47+09:00 fix some docs and not references - - - - - 4 changed files: - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/Reg.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Foreign.hs Changes: ===================================== compiler/GHC/ByteCode/Instr.hs ===================================== @@ -271,8 +271,8 @@ instance Outputable BCInstr where ppr (PUSH_ALTS bco) = hang (text "PUSH_ALTS") 2 (ppr bco) ppr (PUSH_ALTS_UNLIFTED bco pk) = hang (text "PUSH_ALTS_UNLIFTED" <+> ppr pk) 2 (ppr bco) - ppr (PUSH_ALTS_TUPLE bco tuple_info tuple_bco) = - hang (text "PUSH_ALTS_TUPLE" <+> ppr tuple_info) + ppr (PUSH_ALTS_TUPLE bco call_info tuple_bco) = + hang (text "PUSH_ALTS_TUPLE" <+> ppr call_info) 2 (ppr tuple_bco $+$ ppr bco) @@ -385,9 +385,9 @@ bciStackUse (PUSH_ALTS bco) = 2 {- profiling only, restore CCCS -} + bciStackUse (PUSH_ALTS_UNLIFTED bco _) = 2 {- profiling only, restore CCCS -} + 4 + protoBCOStackUse bco bciStackUse (PUSH_ALTS_TUPLE bco info _) = - -- (tuple_bco, tuple_info word, cont_bco, stg_ctoi_t) + -- (tuple_bco, call_info word, cont_bco, stg_ctoi_t) -- tuple - -- (tuple_info, tuple_bco, stg_ret_t) + -- (call_info, tuple_bco, stg_ret_t) 1 {- profiling only -} + 7 + fromIntegral (nativeCallSize info) + protoBCOStackUse bco bciStackUse (PUSH_PAD8) = 1 -- overapproximation ===================================== compiler/GHC/Cmm/Reg.hs ===================================== @@ -223,7 +223,7 @@ instance Eq GlobalReg where _r1 == _r2 = False -- NOTE: this Ord instance affects the tuple layout in GHCi, see --- Note [GHCi tuple layout] +-- Note [GHCi and native call registers] instance Ord GlobalReg where compare (VanillaReg i _) (VanillaReg j _) = compare i j -- Ignore type when seeking clashes ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -986,8 +986,8 @@ doCase d s p scrut bndr alts -- unboxed tuples get two more words, the second is a pointer (tuple_bco) (extra_pointers, extra_slots) - | ubx_tuple_frame && profiling = ([1], 3) -- tuple_info, tuple_BCO, CCCS - | ubx_tuple_frame = ([1], 2) -- tuple_info, tuple_BCO + | ubx_tuple_frame && profiling = ([1], 3) -- call_info, tuple_BCO, CCCS + | ubx_tuple_frame = ([1], 2) -- call_info, tuple_BCO | otherwise = ([], 0) bitmap_size = trunc16W $ fromIntegral extra_slots + @@ -1134,7 +1134,7 @@ usePlainReturn t ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We have the bytecode instructions RETURN_TUPLE and PUSH_ALTS_TUPLE to return and receive arbitrary unboxed tuples, respectively. These - instructions use the helper data tuple_BCO and tuple_info. + instructions use the helper data tuple_BCO and call_info. The helper data is used to convert tuples between GHCs native calling convention (object code), which uses stack and registers, and the bytecode @@ -1146,7 +1146,7 @@ usePlainReturn t ================= Bytecode that returns a tuple first pushes all the tuple fields followed - by the appropriate tuple_info and tuple_BCO onto the stack. It then + by the appropriate call_info and tuple_BCO onto the stack. It then executes the RETURN_TUPLE instruction, which causes the interpreter to push stg_ret_t_info to the top of the stack. The stack (growing down) then looks as follows: @@ -1157,14 +1157,14 @@ usePlainReturn t tuple_field_2 ... tuple_field_n - tuple_info + call_info tuple_BCO stg_ret_t_info <- Sp If next_frame is bytecode, the interpreter will start executing it. If it's object code, the interpreter jumps back to the scheduler, which in turn jumps to stg_ret_t. stg_ret_t converts the tuple to the native - calling convention using the description in tuple_info, and then jumps + calling convention using the description in call_info, and then jumps to next_frame. @@ -1176,13 +1176,13 @@ usePlainReturn t tuple. The PUSH_ALTS_TUPLE instuction contains three pieces of data: * cont_BCO: the continuation that receives the tuple - * tuple_info: see below + * call_info: see below * tuple_BCO: see below The interpreter pushes these onto the stack when the PUSH_ALTS_TUPLE instruction is executed, followed by stg_ctoi_tN_info, with N depending on the number of stack words used by the tuple in the GHC native calling - convention. N is derived from tuple_info. + convention. N is derived from call_info. For example if we expect a tuple with three words on the stack, the stack looks as follows after PUSH_ALTS_TUPLE: @@ -1193,7 +1193,7 @@ usePlainReturn t cont_free_var_2 ... cont_free_var_n - tuple_info + call_info tuple_BCO cont_BCO stg_ctoi_t3_info <- Sp @@ -1213,16 +1213,16 @@ usePlainReturn t that is already on the stack. - The tuple_info word + The call_info word =================== - The tuple_info word describes the stack and STG register (e.g. R1..R6, - D1..D6) usage for the tuple. tuple_info contains enough information to + The call_info word describes the stack and STG register (e.g. R1..R6, + D1..D6) usage for the tuple. call_info contains enough information to convert the tuple between the stack-only bytecode and stack+registers GHC native calling conventions. - See Note [GHCi tuple layout] for more details of how the data is packed - in a single word. + See Note [GHCi and native call registers] for more details of how the + data is packed in a single word. -} @@ -1240,7 +1240,7 @@ tupleBCO platform info pointers = -} invented_name = mkSystemVarName (mkPseudoUniqueE 0) (fsLit "tuple") - -- the first word in the frame is the tuple_info word, + -- the first word in the frame is the call_info word, -- which is not a pointer bitmap_size = trunc16W $ 1 + nativeCallSize info bitmap = intsToReverseBitmap platform (fromIntegral bitmap_size) $ @@ -1264,7 +1264,7 @@ primCallBCO platform args_info pointers = invented_name = mkSystemVarName (mkPseudoUniqueE 0) (fsLit "primcall") -- the first three words in the frame are the BCO describing the - -- pointers in the frame, the tuple_info word and the pointer + -- pointers in the frame, the call_info word and the pointer -- to the Cmm function being called. None of these is a pointer that -- should be followed by the garbage collector bitmap_size = trunc16W $ 2 + nativeCallSize args_info @@ -1321,7 +1321,7 @@ generatePrimCall d s p target _mb_unit _result_ty args size of arguments plus three words for: - function pointer to the target - - tuple_info word + - call_info word - BCO to describe the stack frame -} szb = wordsToBytes platform (nativeCallSize args_info + 3) ===================================== compiler/GHC/StgToCmm/Foreign.hs ===================================== @@ -362,7 +362,7 @@ emitRestoreRegs = do -- if((mask & 2) != 0) { Sp_adj(-1); Sp(0) = R2; } -- if((mask & 1) != 0) { Sp_adj(-1); Sp(0) = R1; } -- --- See Note [GHCi tuple layout] +-- See Note [GHCi and native call registers] emitPushArgRegs :: CmmExpr -> FCode () emitPushArgRegs regs_live = do View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/858961bc2641096b33621d16a5a00cb6a334fb2d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/858961bc2641096b33621d16a5a00cb6a334fb2d You're receiving 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 Jan 8 21:52:14 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Sun, 08 Jan 2023 16:52:14 -0500 Subject: [Git][ghc/ghc][wip/andreask/cmov-primop] Add a cmov# primop Message-ID: <63bb3b0eba44b_136d9816cb0938154161@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/cmov-primop at Glasgow Haskell Compiler / GHC Commits: 4bfbebdf by Andreas Klebinger at 2023-01-08T22:50:31+01:00 Add a cmov# primop The cmov# primop allows users to force GHC to emit a conditional move instead of a branch if so desired. - - - - - 7 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/StgToCmm/Config.hs - compiler/GHC/StgToCmm/Prim.hs Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -3411,6 +3411,14 @@ primop CompactSize "compactSize#" GenPrimOp has_side_effects = True out_of_line = True +------------------------------------------------------------------------ +section "Cmove" +------------------------------------------------------------------------ + +primop CMovOp "cmov#" GenPrimOp + Int# -> o -> o -> (# o #) + { Returns the last argument if the first argument is zero, the first argument otherwise. } + ------------------------------------------------------------------------ section "Unsafe pointer equality" -- (#1 Bad Guy: Alastair Reid :) ===================================== compiler/GHC/Cmm/MachOp.hs ===================================== @@ -108,6 +108,9 @@ data MachOp | MO_U_Shr Width -- unsigned shift right | MO_S_Shr Width -- signed shift right + -- | Conditional move. First argument tells us which arg to select. + | MO_Cmov Width + -- Conversions. Some of these will be NOPs. -- Floating-point conversions use the signed variant. | MO_SF_Conv Width Width -- Signed int -> Float @@ -412,6 +415,7 @@ machOpResultType platform mop tys = MO_Shl r -> cmmBits r MO_U_Shr r -> cmmBits r MO_S_Shr r -> cmmBits r + MO_Cmov r -> cmmBits r MO_SS_Conv _ to -> cmmBits to MO_UU_Conv _ to -> cmmBits to @@ -503,6 +507,7 @@ machOpArgReps platform op = MO_Shl r -> [r, wordWidth platform] MO_U_Shr r -> [r, wordWidth platform] MO_S_Shr r -> [r, wordWidth platform] + MO_Cmov r -> [wordWidth platform, r, r] MO_SS_Conv from _ -> [from] MO_UU_Conv from _ -> [from] ===================================== compiler/GHC/Cmm/Utils.hs ===================================== @@ -38,7 +38,7 @@ module GHC.Cmm.Utils( cmmNeWord, cmmEqWord, cmmOrWord, cmmAndWord, cmmSubWord, cmmAddWord, cmmMulWord, cmmQuotWord, - cmmToWord, + cmmToWord, cmmCMov, cmmMkAssign, @@ -390,6 +390,12 @@ cmmToWord platform e w = cmmExprWidth platform e word = wordWidth platform +-- Might not be supported on all platforms +cmmCMov :: Platform -> CmmExpr -> CmmExpr -> CmmExpr -> CmmExpr +cmmCMov platform cond x y = + CmmMachOp (MO_Cmov (cmmExprWidth platform x)) + [cmmNeWord platform (cmmToWord platform cond) (zeroExpr platform),x,y] + cmmMkAssign :: Platform -> CmmExpr -> Unique -> (CmmNode O O, CmmExpr) cmmMkAssign platform expr uq = let !ty = cmmExprType platform expr ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -379,7 +379,11 @@ type InstrBlock -- | Condition codes passed up the tree. -- data CondCode - = CondCode Bool Cond InstrBlock + = CondCode + { _cond_is_float :: Bool + , _cond_cond :: Cond + , _cond_instr :: InstrBlock + } -- | Register's passed up the tree. If the stix code forces the register @@ -1148,6 +1152,26 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps return (Fixed format result code) +getRegister' _bid _is32Bit (CmmMachOp mop [x, y, z]) = -- triadic MachOps + case mop of + MO_Cmov width -> do + let format = (intFormat width) + + CondCode is_float cond code_cond <- getCondCode x + massert (not is_float) + + (y_reg, code_y) <- getSomeReg y + + get_code_z <- getAnyReg z + let cmov_code dst_reg = + code_y `appOL` (get_code_z dst_reg) `appOL` code_cond `appOL` + toOL [CMOV cond format (OpReg y_reg) dst_reg] + return $ Any format cmov_code + _other -> pprPanic "getRegister(x86) - trinary CmmMachOp (1)" (pprMachOp mop) + where + + + getRegister' _ _ (CmmLoad mem pk _) | isFloatType pk ===================================== compiler/GHC/Driver/Config/StgToCmm.hs ===================================== @@ -51,6 +51,7 @@ initStgToCmmConfig dflags mod = StgToCmmConfig , stgToCmmAllowQuotRem2 = (ncg && (x86ish || ppc)) || llvm , stgToCmmAllowExtendedAddSubInstrs = (ncg && (x86ish || ppc)) || llvm , stgToCmmAllowIntMul2Instr = (ncg && x86ish) || llvm + , stgToCmmAllowCMovInstr = (ncg && x86_64) -- SIMD flags , stgToCmmVecInstrsErr = vec_err , stgToCmmAvx = isAvxEnabled dflags @@ -70,6 +71,9 @@ initStgToCmmConfig dflags mod = StgToCmmConfig ArchX86 -> True ArchX86_64 -> True _ -> False + x86_64 = case platformArch platform of + ArchX86_64 -> True + _ -> False ppc = case platformArch platform of ArchPPC -> True ArchPPC_64 _ -> True ===================================== compiler/GHC/StgToCmm/Config.hs ===================================== @@ -66,6 +66,7 @@ data StgToCmmConfig = StgToCmmConfig , stgToCmmAllowQuotRem2 :: !Bool -- ^ Allowed to generate QuotRem , stgToCmmAllowExtendedAddSubInstrs :: !Bool -- ^ Allowed to generate AddWordC, SubWordC, Add2, etc. , stgToCmmAllowIntMul2Instr :: !Bool -- ^ Allowed to generate IntMul2 instruction + , stgToCmmAllowCMovInstr :: !Bool -- ^ Allowed to generate conditional move instructions. , stgToCmmTickyAP :: !Bool -- ^ Disable use of precomputed standard thunks. ------------------------------ SIMD flags ------------------------------------ -- Each of these flags checks vector compatibility with the backend requested ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -341,6 +341,12 @@ emitPrimOp cfg primop = EqStablePtrOp -> \args -> opTranslate args (mo_wordEq platform) + CMovOp -> \[cond, x, y] -> + opIntoRegs $ \[res] -> if allowCmov + then emitAssign (CmmLocal res) (cmmCMov platform cond x y) + -- Fall back to using a branch + else emitGenericCMov [res] [cond, x, y] + ReallyUnsafePtrEqualityOp -> \[arg1, arg2] -> opIntoRegs $ \[res] -> emitAssign (CmmLocal res) (CmmMachOp (mo_wordEq platform) [arg1,arg2]) @@ -1735,6 +1741,7 @@ emitPrimOp cfg primop = allowQuotRem2 = stgToCmmAllowQuotRem2 cfg allowExtAdd = stgToCmmAllowExtendedAddSubInstrs cfg allowInt2Mul = stgToCmmAllowIntMul2Instr cfg + allowCmov = stgToCmmAllowCMovInstr cfg data PrimopCmmEmit -- | Out of line fake primop that's actually just a foreign call to other @@ -2024,6 +2031,15 @@ genericIntMul2Op [res_c, res_h, res_l] both_args@[arg_x, arg_y] ] genericIntMul2Op _ _ = panic "genericIntMul2Op" +-- | Emulate cmov by using a branch, urkh +emitGenericCMov :: GenericOp +emitGenericCMov [res] [cond, arg_x, arg_y] + = do true_lbl <- newBlockId + emitAssign (CmmLocal res) arg_x + emit =<< mkCmmIfGoto cond true_lbl + emitAssign (CmmLocal res) arg_y + emitLabel true_lbl +emitGenericCMov _ _ = panic "genericIntMul2Op" ------------------------------------------------------------------------------ -- Helpers for translating various minor variants of array indexing. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bfbebdf48a1e01a551ca7a3f083ffe34650d13d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bfbebdf48a1e01a551ca7a3f083ffe34650d13d You're receiving 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 Jan 8 22:25:51 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 08 Jan 2023 17:25:51 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Make FloatIn robust to shadowing Message-ID: <63bb42ef11487_136d98526701680df@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s - - - - - 73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. - - - - - 8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - 18c9fb08 by Matthew Pickering at 2023-01-08T17:25:37-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 521cc499 by Alan Zimmerman at 2023-01-08T17:25:37-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 14 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Core/Opt/FloatIn.hs - configure.ac - + m4/fp_ld_no_fixup_chains.m4 - testsuite/tests/ghci/linking/dyn/Makefile - + testsuite/tests/printer/HsDocTy.hs - testsuite/tests/printer/Makefile - testsuite/tests/printer/all.T - testsuite/tests/rts/T18623/all.T - + testsuite/tests/simplCore/should_compile/T22662.hs - testsuite/tests/simplCore/should_compile/all.T - utils/check-exact/ExactPrint.hs - utils/check-exact/Main.hs Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -813,7 +813,7 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , standardBuilds Amd64 Darwin , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin - , standardBuilds AArch64 (Linux Debian10) + , standardBuildsWithConfig AArch64 (Linux Debian10) (splitSectionsBroken vanilla) , disableValidate (standardBuildsWithConfig AArch64 (Linux Debian10) llvm) , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla) , standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static) ===================================== .gitlab/jobs.yaml ===================================== @@ -1926,7 +1926,7 @@ "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release": { + "release-aarch64-linux-deb10-release+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1936,7 +1936,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release.tar.xz", + "ghc-aarch64-linux-deb10-release+llvm.tar.xz", "junit.xml" ], "reports": { @@ -1978,15 +1978,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", + "BUILD_FLAVOUR": "release+llvm", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release", + "TEST_ENV": "aarch64-linux-deb10-release+llvm", "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release+llvm": { + "release-aarch64-linux-deb10-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1996,7 +1996,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release+llvm.tar.xz", + "ghc-aarch64-linux-deb10-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2038,11 +2038,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", - "BUILD_FLAVOUR": "release+llvm", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release+llvm", + "TEST_ENV": "aarch64-linux-deb10-release+no_split_sections", "XZ_OPT": "-9" } }, ===================================== compiler/GHC/Core/Opt/FloatIn.hs ===================================== @@ -35,9 +35,12 @@ import GHC.Types.Var import GHC.Types.Var.Set import GHC.Utils.Misc -import GHC.Utils.Panic import GHC.Utils.Panic.Plain +import GHC.Utils.Outputable + +import Data.List ( mapAccumL ) + {- Top-level interface function, @floatInwards at . Note that we do not actually float any bindings downwards from the top-level. @@ -124,7 +127,7 @@ the closure for a is not built. ************************************************************************ -} -type FreeVarSet = DIdSet +type FreeVarSet = DVarSet type BoundVarSet = DIdSet data FloatInBind = FB BoundVarSet FreeVarSet FloatBind @@ -132,11 +135,17 @@ data FloatInBind = FB BoundVarSet FreeVarSet FloatBind -- of recursive bindings, the set doesn't include the bound -- variables. -type FloatInBinds = [FloatInBind] - -- In reverse dependency order (innermost binder first) +type FloatInBinds = [FloatInBind] -- In normal dependency order + -- (outermost binder first) +type RevFloatInBinds = [FloatInBind] -- In reverse dependency order + -- (innermost binder first) + +instance Outputable FloatInBind where + ppr (FB bvs fvs _) = text "FB" <> braces (sep [ text "bndrs =" <+> ppr bvs + , text "fvs =" <+> ppr fvs ]) fiExpr :: Platform - -> FloatInBinds -- Binds we're trying to drop + -> RevFloatInBinds -- Binds we're trying to drop -- as far "inwards" as possible -> CoreExprWithFVs -- Input expr -> CoreExpr -- Result @@ -147,13 +156,12 @@ fiExpr _ to_drop (_, AnnType ty) = assert (null to_drop) $ Type ty fiExpr _ to_drop (_, AnnVar v) = wrapFloats to_drop (Var v) fiExpr _ to_drop (_, AnnCoercion co) = wrapFloats to_drop (Coercion co) fiExpr platform to_drop (_, AnnCast expr (co_ann, co)) - = wrapFloats (drop_here ++ co_drop) $ + = wrapFloats drop_here $ Cast (fiExpr platform e_drop expr) co where - [drop_here, e_drop, co_drop] - = sepBindsByDropPoint platform False - [freeVarsOf expr, freeVarsOfAnn co_ann] - to_drop + (drop_here, [e_drop]) + = sepBindsByDropPoint platform False to_drop + (freeVarsOfAnn co_ann) [freeVarsOf expr] {- Applications: we do float inside applications, mainly because we @@ -162,7 +170,7 @@ pull out any silly ones. -} fiExpr platform to_drop ann_expr@(_,AnnApp {}) - = wrapFloats drop_here $ wrapFloats extra_drop $ + = wrapFloats drop_here $ mkTicks ticks $ mkApps (fiExpr platform fun_drop ann_fun) (zipWithEqual "fiExpr" (fiExpr platform) arg_drops ann_args) @@ -170,21 +178,19 @@ fiExpr platform to_drop ann_expr@(_,AnnApp {}) -- length ann_args = length arg_fvs = length arg_drops where (ann_fun, ann_args, ticks) = collectAnnArgsTicks tickishFloatable ann_expr - fun_ty = exprType (deAnnotate ann_fun) fun_fvs = freeVarsOf ann_fun - arg_fvs = map freeVarsOf ann_args - (drop_here : extra_drop : fun_drop : arg_drops) - = sepBindsByDropPoint platform False - (extra_fvs : fun_fvs : arg_fvs) - to_drop + (drop_here, fun_drop : arg_drops) + = sepBindsByDropPoint platform False to_drop + here_fvs (fun_fvs : arg_fvs) + -- Shortcut behaviour: if to_drop is empty, -- sepBindsByDropPoint returns a suitable bunch of empty -- lists without evaluating extra_fvs, and hence without -- peering into each argument - (_, extra_fvs) = foldl' add_arg (fun_ty, extra_fvs0) ann_args - extra_fvs0 = case ann_fun of + (here_fvs, arg_fvs) = mapAccumL add_arg here_fvs0 ann_args + here_fvs0 = case ann_fun of (_, AnnVar _) -> fun_fvs _ -> emptyDVarSet -- Don't float the binding for f into f x y z; see Note [Join points] @@ -192,14 +198,11 @@ fiExpr platform to_drop ann_expr@(_,AnnApp {}) -- join point, floating it in isn't especially harmful but it's -- useless since the simplifier will immediately float it back out.) - add_arg :: (Type,FreeVarSet) -> CoreExprWithFVs -> (Type,FreeVarSet) - add_arg (fun_ty, extra_fvs) (_, AnnType ty) - = (piResultTy fun_ty ty, extra_fvs) - add_arg (fun_ty, extra_fvs) (arg_fvs, arg) - | noFloatIntoArg arg - = (funResultTy fun_ty, extra_fvs `unionDVarSet` arg_fvs) - | otherwise - = (funResultTy fun_ty, extra_fvs) + add_arg :: FreeVarSet -> CoreExprWithFVs -> (FreeVarSet,FreeVarSet) + -- We can't float into some arguments, so put them into the here_fvs + add_arg here_fvs (arg_fvs, arg) + | noFloatIntoArg arg = (here_fvs `unionDVarSet` arg_fvs, emptyDVarSet) + | otherwise = (here_fvs, arg_fvs) {- Note [Dead bindings] ~~~~~~~~~~~~~~~~~~~~~~~ @@ -272,7 +275,6 @@ it's non-recursive, so we float only into non-recursive join points.) Urk! if all are tyvars, and we don't float in, we may miss an opportunity to float inside a nested case branch - Note [Floating coercions] ~~~~~~~~~~~~~~~~~~~~~~~~~ We could, in principle, have a coercion binding like @@ -292,6 +294,36 @@ of the types of all the drop points involved. If any of the floaters bind a coercion variable mentioned in any of the types, that binder must be dropped right away. +Note [Shadowing and name capture] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we have + let x = y+1 in + case p of + (y:ys) -> ...x... + [] -> blah +It is obviously bogus for FloatIn to transform to + case p of + (y:ys) -> ...(let x = y+1 in x)... + [] -> blah +because the y is captured. This doesn't happen much, because shadowing is +rare, but it did happen in #22662. + +One solution would be to clone as we go. But a simpler one is this: + + at a binding site (like that for (y:ys) above), abandon float-in for + any floating bindings that mention the binders (y, ys in this case) + +We achieve that by calling sepBindsByDropPoint with the binders in +the "used-here" set: + +* In fiExpr (AnnLam ...). For the body there is no need to delete + the lambda-binders from the body_fvs, because any bindings that + mention these binders will be dropped here anyway. + +* In fiExpr (AnnCase ...). Remember to include the case_bndr in the + binders. Again, no need to delete the alt binders from the rhs + free vars, beause any bindings mentioning them will be dropped + here unconditionally. -} fiExpr platform to_drop lam@(_, AnnLam _ _) @@ -300,10 +332,17 @@ fiExpr platform to_drop lam@(_, AnnLam _ _) = wrapFloats to_drop (mkLams bndrs (fiExpr platform [] body)) | otherwise -- Float inside - = mkLams bndrs (fiExpr platform to_drop body) + = wrapFloats drop_here $ + mkLams bndrs (fiExpr platform body_drop body) where (bndrs, body) = collectAnnBndrs lam + body_fvs = freeVarsOf body + + -- Why sepBindsByDropPoint? Because of potential capture + -- See Note [Shadowing and name capture] + (drop_here, [body_drop]) = sepBindsByDropPoint platform False to_drop + (mkDVarSet bndrs) [body_fvs] {- We don't float lets inwards past an SCC. @@ -443,16 +482,16 @@ fiExpr platform to_drop (_, AnnCase scrut case_bndr _ [AnnAlt con alt_bndrs rhs] = wrapFloats shared_binds $ fiExpr platform (case_float : rhs_binds) rhs where - case_float = FB (mkDVarSet (case_bndr : alt_bndrs)) scrut_fvs + case_float = FB all_bndrs scrut_fvs (FloatCase scrut' case_bndr con alt_bndrs) scrut' = fiExpr platform scrut_binds scrut - rhs_fvs = freeVarsOf rhs `delDVarSetList` (case_bndr : alt_bndrs) - scrut_fvs = freeVarsOf scrut + rhs_fvs = freeVarsOf rhs -- No need to delete alt_bndrs + scrut_fvs = freeVarsOf scrut -- See Note [Shadowing and name capture] + all_bndrs = mkDVarSet alt_bndrs `extendDVarSet` case_bndr - [shared_binds, scrut_binds, rhs_binds] - = sepBindsByDropPoint platform False - [scrut_fvs, rhs_fvs] - to_drop + (shared_binds, [scrut_binds, rhs_binds]) + = sepBindsByDropPoint platform False to_drop + all_bndrs [scrut_fvs, rhs_fvs] fiExpr platform to_drop (_, AnnCase scrut case_bndr ty alts) = wrapFloats drop_here1 $ @@ -462,39 +501,43 @@ fiExpr platform to_drop (_, AnnCase scrut case_bndr ty alts) -- use zipWithEqual, we should have length alts_drops_s = length alts where -- Float into the scrut and alts-considered-together just like App - [drop_here1, scrut_drops, alts_drops] - = sepBindsByDropPoint platform False - [scrut_fvs, all_alts_fvs] - to_drop + (drop_here1, [scrut_drops, alts_drops]) + = sepBindsByDropPoint platform False to_drop + all_alt_bndrs [scrut_fvs, all_alt_fvs] + -- all_alt_bndrs: see Note [Shadowing and name capture] -- Float into the alts with the is_case flag set - (drop_here2 : alts_drops_s) - | [ _ ] <- alts = [] : [alts_drops] - | otherwise = sepBindsByDropPoint platform True alts_fvs alts_drops - - scrut_fvs = freeVarsOf scrut - alts_fvs = map alt_fvs alts - all_alts_fvs = unionDVarSets alts_fvs - alt_fvs (AnnAlt _con args rhs) - = foldl' delDVarSet (freeVarsOf rhs) (case_bndr:args) - -- Delete case_bndr and args from free vars of rhs - -- to get free vars of alt + (drop_here2, alts_drops_s) + = sepBindsByDropPoint platform True alts_drops emptyDVarSet alts_fvs + + scrut_fvs = freeVarsOf scrut + + all_alt_bndrs = foldr (unionDVarSet . ann_alt_bndrs) (unitDVarSet case_bndr) alts + ann_alt_bndrs (AnnAlt _ bndrs _) = mkDVarSet bndrs + + alts_fvs :: [DVarSet] + alts_fvs = [freeVarsOf rhs | AnnAlt _ _ rhs <- alts] + -- No need to delete binders + -- See Note [Shadowing and name capture] + + all_alt_fvs :: DVarSet + all_alt_fvs = foldr unionDVarSet (unitDVarSet case_bndr) alts_fvs fi_alt to_drop (AnnAlt con args rhs) = Alt con args (fiExpr platform to_drop rhs) ------------------ fiBind :: Platform - -> FloatInBinds -- Binds we're trying to drop - -- as far "inwards" as possible - -> CoreBindWithFVs -- Input binding - -> DVarSet -- Free in scope of binding - -> ( FloatInBinds -- Land these before - , FloatInBind -- The binding itself - , FloatInBinds) -- Land these after + -> RevFloatInBinds -- Binds we're trying to drop + -- as far "inwards" as possible + -> CoreBindWithFVs -- Input binding + -> DVarSet -- Free in scope of binding + -> ( RevFloatInBinds -- Land these before + , FloatInBind -- The binding itself + , RevFloatInBinds) -- Land these after fiBind platform to_drop (AnnNonRec id ann_rhs@(rhs_fvs, rhs)) body_fvs - = ( extra_binds ++ shared_binds -- Land these before - -- See Note [extra_fvs (1)] and Note [extra_fvs (2)] + = ( shared_binds -- Land these before + -- See Note [extra_fvs (1)] and Note [extra_fvs (2)] , FB (unitDVarSet id) rhs_fvs' -- The new binding itself (FloatLet (NonRec id rhs')) , body_binds ) -- Land these after @@ -512,10 +555,9 @@ fiBind platform to_drop (AnnNonRec id ann_rhs@(rhs_fvs, rhs)) body_fvs -- We *can't* float into ok-for-speculation unlifted RHSs -- But do float into join points - [shared_binds, extra_binds, rhs_binds, body_binds] - = sepBindsByDropPoint platform False - [extra_fvs, rhs_fvs, body_fvs2] - to_drop + (shared_binds, [rhs_binds, body_binds]) + = sepBindsByDropPoint platform False to_drop + extra_fvs [rhs_fvs, body_fvs2] -- Push rhs_binds into the right hand side of the binding rhs' = fiRhs platform rhs_binds id ann_rhs @@ -523,7 +565,7 @@ fiBind platform to_drop (AnnNonRec id ann_rhs@(rhs_fvs, rhs)) body_fvs -- Don't forget the rule_fvs; the binding mentions them! fiBind platform to_drop (AnnRec bindings) body_fvs - = ( extra_binds ++ shared_binds + = ( shared_binds , FB (mkDVarSet ids) rhs_fvs' (FloatLet (Rec (fi_bind rhss_binds bindings))) , body_binds ) @@ -537,17 +579,16 @@ fiBind platform to_drop (AnnRec bindings) body_fvs unionDVarSets [ rhs_fvs | (bndr, (rhs_fvs, rhs)) <- bindings , noFloatIntoRhs Recursive bndr rhs ] - (shared_binds:extra_binds:body_binds:rhss_binds) - = sepBindsByDropPoint platform False - (extra_fvs:body_fvs:rhss_fvs) - to_drop + (shared_binds, body_binds:rhss_binds) + = sepBindsByDropPoint platform False to_drop + extra_fvs (body_fvs:rhss_fvs) rhs_fvs' = unionDVarSets rhss_fvs `unionDVarSet` unionDVarSets (map floatedBindsFVs rhss_binds) `unionDVarSet` rule_fvs -- Don't forget the rule variables! -- Push rhs_binds into the right hand side of the binding - fi_bind :: [FloatInBinds] -- one per "drop pt" conjured w/ fvs_of_rhss + fi_bind :: [RevFloatInBinds] -- One per "drop pt" conjured w/ fvs_of_rhss -> [(Id, CoreExprWithFVs)] -> [(Id, CoreExpr)] @@ -556,7 +597,7 @@ fiBind platform to_drop (AnnRec bindings) body_fvs | ((binder, rhs), to_drop) <- zipEqual "fi_bind" pairs to_drops ] ------------------ -fiRhs :: Platform -> FloatInBinds -> CoreBndr -> CoreExprWithFVs -> CoreExpr +fiRhs :: Platform -> RevFloatInBinds -> CoreBndr -> CoreExprWithFVs -> CoreExpr fiRhs platform to_drop bndr rhs | Just join_arity <- isJoinId_maybe bndr , let (bndrs, body) = collectNAnnBndrs join_arity rhs @@ -656,68 +697,84 @@ point. We have to maintain the order on these drop-point-related lists. -} --- pprFIB :: FloatInBinds -> SDoc +-- pprFIB :: RevFloatInBinds -> SDoc -- pprFIB fibs = text "FIB:" <+> ppr [b | FB _ _ b <- fibs] sepBindsByDropPoint :: Platform - -> Bool -- True <=> is case expression - -> [FreeVarSet] -- One set of FVs per drop point - -- Always at least two long! - -> FloatInBinds -- Candidate floaters - -> [FloatInBinds] -- FIRST one is bindings which must not be floated - -- inside any drop point; the rest correspond - -- one-to-one with the input list of FV sets + -> Bool -- True <=> is case expression + -> RevFloatInBinds -- Candidate floaters + -> FreeVarSet -- here_fvs: if these vars are free in a binding, + -- don't float that binding inside any drop point + -> [FreeVarSet] -- fork_fvs: one set of FVs per drop point + -> ( RevFloatInBinds -- Bindings which must not be floated inside + , [RevFloatInBinds] ) -- Corresponds 1-1 with the input list of FV sets -- Every input floater is returned somewhere in the result; -- none are dropped, not even ones which don't seem to be -- free in *any* of the drop-point fvs. Why? Because, for example, -- a binding (let x = E in B) might have a specialised version of -- x (say x') stored inside x, but x' isn't free in E or B. +-- +-- The here_fvs argument is used for two things: +-- * Avoid shadowing bugs: see Note [Shadowing and name capture] +-- * Drop some of the bindings at the top, e.g. of an application type DropBox = (FreeVarSet, FloatInBinds) -sepBindsByDropPoint platform is_case drop_pts floaters +dropBoxFloats :: DropBox -> RevFloatInBinds +dropBoxFloats (_, floats) = reverse floats + +usedInDropBox :: DIdSet -> DropBox -> Bool +usedInDropBox bndrs (db_fvs, _) = db_fvs `intersectsDVarSet` bndrs + +initDropBox :: DVarSet -> DropBox +initDropBox fvs = (fvs, []) + +sepBindsByDropPoint platform is_case floaters here_fvs fork_fvs | null floaters -- Shortcut common case - = [] : [[] | _ <- drop_pts] + = ([], [[] | _ <- fork_fvs]) | otherwise - = assert (drop_pts `lengthAtLeast` 2) $ - go floaters (map (\fvs -> (fvs, [])) (emptyDVarSet : drop_pts)) + = go floaters (initDropBox here_fvs) (map initDropBox fork_fvs) where - n_alts = length drop_pts + n_alts = length fork_fvs - go :: FloatInBinds -> [DropBox] -> [FloatInBinds] - -- The *first* one in the argument list is the drop_here set - -- The FloatInBinds in the lists are in the reverse of - -- the normal FloatInBinds order; that is, they are the right way round! + go :: RevFloatInBinds -> DropBox -> [DropBox] + -> (RevFloatInBinds, [RevFloatInBinds]) + -- The *first* one in the pair is the drop_here set - go [] drop_boxes = map (reverse . snd) drop_boxes + go [] here_box fork_boxes + = (dropBoxFloats here_box, map dropBoxFloats fork_boxes) - go (bind_w_fvs@(FB bndrs bind_fvs bind) : binds) drop_boxes@(here_box : fork_boxes) - = go binds new_boxes + go (bind_w_fvs@(FB bndrs bind_fvs bind) : binds) here_box fork_boxes + | drop_here = go binds (insert here_box) fork_boxes + | otherwise = go binds here_box new_fork_boxes where -- "here" means the group of bindings dropped at the top of the fork - (used_here : used_in_flags) = [ fvs `intersectsDVarSet` bndrs - | (fvs, _) <- drop_boxes] + used_here = bndrs `usedInDropBox` here_box + used_in_flags = case fork_boxes of + [] -> [] + [_] -> [True] -- Push all bindings into a single branch + -- No need to look at its free vars + _ -> map (bndrs `usedInDropBox`) fork_boxes + -- Short-cut for the singleton case; + -- used for lambdas and singleton cases drop_here = used_here || cant_push n_used_alts = count id used_in_flags -- returns number of Trues in list. cant_push - | is_case = n_used_alts == n_alts -- Used in all, don't push - -- Remember n_alts > 1 + | is_case = (n_alts > 1 && n_used_alts == n_alts) + -- Used in all, muliple branches, don't push || (n_used_alts > 1 && not (floatIsDupable platform bind)) -- floatIsDupable: see Note [Duplicating floats] | otherwise = floatIsCase bind || n_used_alts > 1 -- floatIsCase: see Note [Floating primops] - new_boxes | drop_here = (insert here_box : fork_boxes) - | otherwise = (here_box : new_fork_boxes) - new_fork_boxes = zipWithEqual "FloatIn.sepBinds" insert_maybe fork_boxes used_in_flags @@ -727,8 +784,6 @@ sepBindsByDropPoint platform is_case drop_pts floaters insert_maybe box True = insert box insert_maybe box False = box - go _ _ = panic "sepBindsByDropPoint/go" - {- Note [Duplicating floats] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -745,14 +800,14 @@ If the thing is used in all RHSs there is nothing gained, so we don't duplicate then. -} -floatedBindsFVs :: FloatInBinds -> FreeVarSet +floatedBindsFVs :: RevFloatInBinds -> FreeVarSet floatedBindsFVs binds = mapUnionDVarSet fbFVs binds fbFVs :: FloatInBind -> DVarSet fbFVs (FB _ fvs _) = fvs -wrapFloats :: FloatInBinds -> CoreExpr -> CoreExpr --- Remember FloatInBinds is in *reverse* dependency order +wrapFloats :: RevFloatInBinds -> CoreExpr -> CoreExpr +-- Remember RevFloatInBinds is in *reverse* dependency order wrapFloats [] e = e wrapFloats (FB _ _ fl : bs) e = wrapFloats bs (wrapFloat fl e) ===================================== configure.ac ===================================== @@ -658,6 +658,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) # Stage 3 won't be supported by cross-compilation +FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) +FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + GHC_LLVM_TARGET_SET_VAR # we intend to pass trough --targets to llvm as is. LLVMTarget_CPP=` echo "$LlvmTarget"` ===================================== m4/fp_ld_no_fixup_chains.m4 ===================================== @@ -0,0 +1,24 @@ +# FP_LD_NO_FIXUP_CHAINS +# -------------------- +# See if whether we are using a version of ld64 on darwin platforms which +# requires us to pass -no_fixup_chains +# +# $1 = the platform +# $2 = the name of the linker flags variable when linking with $CC +AC_DEFUN([FP_LD_NO_FIXUP_CHAINS], [ + case $$1 in + *-darwin) + AC_MSG_CHECKING([whether ld64 requires -no_fixup_chains]) + echo 'int main(void) {return 0;}' > conftest.c + if $CC -o conftest.o -Wl,-no_fixup_chains conftest.c > /dev/null 2>&1 + then + $2="-Wl,-no_fixup_chains" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + rm -f conftest.c conftest.o + ;; + + esac +]) ===================================== testsuite/tests/ghci/linking/dyn/Makefile ===================================== @@ -84,7 +84,7 @@ compile_libAB_dyn: '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_dyn" -shared B.c -o "bin_dyn/$(call DLL,B)" $(call DEF,B) -lA -L"./bin_dyn" rm -f bin_dyn/*.a '$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -v0 -o "bin_dyn/$(call EXE,T10955dyn)" -L./bin_dyn -lB -lA T10955dyn.hs -v0 - LD_LIBRARY_PATH=./bin_dyn ./bin_dyn/$(call EXE,T10955dyn) + DYLD_LIBRARY_PATH=./bin_dyn LD_LIBRARY_PATH=./bin_dyn ./bin_dyn/$(call EXE,T10955dyn) .PHONY: compile_libAS_impl_gcc compile_libAS_impl_gcc: ===================================== testsuite/tests/printer/HsDocTy.hs ===================================== @@ -0,0 +1,6 @@ +{-# OPTIONS_GHC -haddock #-} +module HsDocTy where + +class C1 a where + f1 :: a -> Int + -- ^ comment on Int ===================================== testsuite/tests/printer/Makefile ===================================== @@ -769,3 +769,9 @@ Test21355: Test21805: $(CHECK_PPR) $(LIBDIR) Test21805.hs $(CHECK_EXACT) $(LIBDIR) Test21805.hs + +.PHONY: HsDocTy +HsDocTy: + # See comment on pprWithDocString, this won't round trip + # $(CHECK_PPR) $(LIBDIR) HsDocTy.hs + $(CHECK_EXACT) $(LIBDIR) HsDocTy.hs ===================================== testsuite/tests/printer/all.T ===================================== @@ -185,4 +185,5 @@ test('Test21805', [ignore_stderr, req_ppr_deps], makefile_test, ['Test21805']) test('T22488', normal, ghci_script, ['T22488.script']) test('T22488_docHead', normal, compile_and_run, ['-package ghc']) test('T20531', extra_files(['T20531_defs.hs']), ghci_script, ['T20531.script']) -test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) \ No newline at end of file +test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) +test('HsDocTy', [ignore_stderr, req_ppr_deps], makefile_test, ['HsDocTy']) \ No newline at end of file ===================================== testsuite/tests/rts/T18623/all.T ===================================== @@ -5,6 +5,8 @@ test('T18623', # This keeps failing on aarch64-linux for reasons that are not # fully clear. Maybe it needs a higher limit due to LLVM? when(arch('aarch64'), skip), + # Recent versions of osx report an error when running `ulimit -v` + when(arch('darwin'), skip), when(arch('powerpc64le'), skip), cmd_prefix('ulimit -v ' + str(1024 ** 2) + ' && '), ignore_stdout], ===================================== testsuite/tests/simplCore/should_compile/T22662.hs ===================================== @@ -0,0 +1,6 @@ +module T22662 where + +import Data.Set + +foo x = sequence_ [ f y | y <- x ] + where f _ = return (fromList [0]) ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -461,3 +461,4 @@ 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, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) +test('T22662', normal, compile, ['']) ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -3898,6 +3898,10 @@ instance ExactPrint (HsType GhcPs) where exact (HsSpliceTy a splice) = do splice' <- markAnnotated splice return (HsSpliceTy a splice') + exact (HsDocTy an ty doc) = do + ty' <- markAnnotated ty + doc' <- markAnnotated doc + return (HsDocTy an ty' doc') exact (HsBangTy an (HsSrcBang mt up str) ty) = do an0 <- case mt of ===================================== utils/check-exact/Main.hs ===================================== @@ -59,7 +59,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../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) - "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) + -- "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3a.hs" (Just changeWhereIn3a) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3b.hs" (Just changeWhereIn3b) -- "../../testsuite/tests/ghc-api/exactprint/AddLocalDecl1.hs" (Just addLocaLDecl1) @@ -203,6 +203,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../testsuite/tests/ghc-api/exactprint/Test20239.hs" Nothing -- "../../testsuite/tests/printer/PprArrowLambdaCase.hs" Nothing -- "../../testsuite/tests/printer/Test16279.hs" Nothing + "../../testsuite/tests/printer/HsDocTy.hs" Nothing -- cloneT does not need a test, function can be retired View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/857c2404e892725cd344889b177cc732571d84cc...521cc49949866a7d74445cb20debab9f60da532f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/857c2404e892725cd344889b177cc732571d84cc...521cc49949866a7d74445cb20debab9f60da532f You're receiving 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 Jan 9 01:25:57 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 08 Jan 2023 20:25:57 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Disable split sections on aarch64-deb10 build Message-ID: <63bb6d25e516e_136d9819fec9f0188458@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 39002e53 by Matthew Pickering at 2023-01-08T20:25:50-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - d819193a by Alan Zimmerman at 2023-01-08T20:25:50-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 7 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - + testsuite/tests/printer/HsDocTy.hs - testsuite/tests/printer/Makefile - testsuite/tests/printer/all.T - utils/check-exact/ExactPrint.hs - utils/check-exact/Main.hs Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -813,7 +813,7 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , standardBuilds Amd64 Darwin , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin - , standardBuilds AArch64 (Linux Debian10) + , standardBuildsWithConfig AArch64 (Linux Debian10) (splitSectionsBroken vanilla) , disableValidate (standardBuildsWithConfig AArch64 (Linux Debian10) llvm) , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla) , standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static) ===================================== .gitlab/jobs.yaml ===================================== @@ -1926,7 +1926,7 @@ "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release": { + "release-aarch64-linux-deb10-release+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1936,7 +1936,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release.tar.xz", + "ghc-aarch64-linux-deb10-release+llvm.tar.xz", "junit.xml" ], "reports": { @@ -1978,15 +1978,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", + "BUILD_FLAVOUR": "release+llvm", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release", + "TEST_ENV": "aarch64-linux-deb10-release+llvm", "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release+llvm": { + "release-aarch64-linux-deb10-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1996,7 +1996,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release+llvm.tar.xz", + "ghc-aarch64-linux-deb10-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2038,11 +2038,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", - "BUILD_FLAVOUR": "release+llvm", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release+llvm", + "TEST_ENV": "aarch64-linux-deb10-release+no_split_sections", "XZ_OPT": "-9" } }, ===================================== testsuite/tests/printer/HsDocTy.hs ===================================== @@ -0,0 +1,6 @@ +{-# OPTIONS_GHC -haddock #-} +module HsDocTy where + +class C1 a where + f1 :: a -> Int + -- ^ comment on Int ===================================== testsuite/tests/printer/Makefile ===================================== @@ -769,3 +769,9 @@ Test21355: Test21805: $(CHECK_PPR) $(LIBDIR) Test21805.hs $(CHECK_EXACT) $(LIBDIR) Test21805.hs + +.PHONY: HsDocTy +HsDocTy: + # See comment on pprWithDocString, this won't round trip + # $(CHECK_PPR) $(LIBDIR) HsDocTy.hs + $(CHECK_EXACT) $(LIBDIR) HsDocTy.hs ===================================== testsuite/tests/printer/all.T ===================================== @@ -185,4 +185,5 @@ test('Test21805', [ignore_stderr, req_ppr_deps], makefile_test, ['Test21805']) test('T22488', normal, ghci_script, ['T22488.script']) test('T22488_docHead', normal, compile_and_run, ['-package ghc']) test('T20531', extra_files(['T20531_defs.hs']), ghci_script, ['T20531.script']) -test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) \ No newline at end of file +test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) +test('HsDocTy', [ignore_stderr, req_ppr_deps], makefile_test, ['HsDocTy']) \ No newline at end of file ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -3898,6 +3898,10 @@ instance ExactPrint (HsType GhcPs) where exact (HsSpliceTy a splice) = do splice' <- markAnnotated splice return (HsSpliceTy a splice') + exact (HsDocTy an ty doc) = do + ty' <- markAnnotated ty + doc' <- markAnnotated doc + return (HsDocTy an ty' doc') exact (HsBangTy an (HsSrcBang mt up str) ty) = do an0 <- case mt of ===================================== utils/check-exact/Main.hs ===================================== @@ -59,7 +59,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../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) - "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) + -- "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3a.hs" (Just changeWhereIn3a) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3b.hs" (Just changeWhereIn3b) -- "../../testsuite/tests/ghc-api/exactprint/AddLocalDecl1.hs" (Just addLocaLDecl1) @@ -203,6 +203,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../testsuite/tests/ghc-api/exactprint/Test20239.hs" Nothing -- "../../testsuite/tests/printer/PprArrowLambdaCase.hs" Nothing -- "../../testsuite/tests/printer/Test16279.hs" Nothing + "../../testsuite/tests/printer/HsDocTy.hs" Nothing -- cloneT does not need a test, function can be retired View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/521cc49949866a7d74445cb20debab9f60da532f...d819193a69cdcbba823cd1309808abcfc9712a06 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/521cc49949866a7d74445cb20debab9f60da532f...d819193a69cdcbba823cd1309808abcfc9712a06 You're receiving 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 Jan 9 04:46:11 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 08 Jan 2023 23:46:11 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Disable split sections on aarch64-deb10 build Message-ID: <63bb9c1377b6e_136d9819fec9f02066b8@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 455ba9f8 by Matthew Pickering at 2023-01-08T23:46:03-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 44063813 by Alan Zimmerman at 2023-01-08T23:46:03-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 7 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - + testsuite/tests/printer/HsDocTy.hs - testsuite/tests/printer/Makefile - testsuite/tests/printer/all.T - utils/check-exact/ExactPrint.hs - utils/check-exact/Main.hs Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -813,7 +813,7 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , standardBuilds Amd64 Darwin , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin - , standardBuilds AArch64 (Linux Debian10) + , standardBuildsWithConfig AArch64 (Linux Debian10) (splitSectionsBroken vanilla) , disableValidate (standardBuildsWithConfig AArch64 (Linux Debian10) llvm) , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla) , standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static) ===================================== .gitlab/jobs.yaml ===================================== @@ -1926,7 +1926,7 @@ "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release": { + "release-aarch64-linux-deb10-release+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1936,7 +1936,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release.tar.xz", + "ghc-aarch64-linux-deb10-release+llvm.tar.xz", "junit.xml" ], "reports": { @@ -1978,15 +1978,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", + "BUILD_FLAVOUR": "release+llvm", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release", + "TEST_ENV": "aarch64-linux-deb10-release+llvm", "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release+llvm": { + "release-aarch64-linux-deb10-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1996,7 +1996,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release+llvm.tar.xz", + "ghc-aarch64-linux-deb10-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2038,11 +2038,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", - "BUILD_FLAVOUR": "release+llvm", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release+llvm", + "TEST_ENV": "aarch64-linux-deb10-release+no_split_sections", "XZ_OPT": "-9" } }, ===================================== testsuite/tests/printer/HsDocTy.hs ===================================== @@ -0,0 +1,6 @@ +{-# OPTIONS_GHC -haddock #-} +module HsDocTy where + +class C1 a where + f1 :: a -> Int + -- ^ comment on Int ===================================== testsuite/tests/printer/Makefile ===================================== @@ -769,3 +769,9 @@ Test21355: Test21805: $(CHECK_PPR) $(LIBDIR) Test21805.hs $(CHECK_EXACT) $(LIBDIR) Test21805.hs + +.PHONY: HsDocTy +HsDocTy: + # See comment on pprWithDocString, this won't round trip + # $(CHECK_PPR) $(LIBDIR) HsDocTy.hs + $(CHECK_EXACT) $(LIBDIR) HsDocTy.hs ===================================== testsuite/tests/printer/all.T ===================================== @@ -185,4 +185,5 @@ test('Test21805', [ignore_stderr, req_ppr_deps], makefile_test, ['Test21805']) test('T22488', normal, ghci_script, ['T22488.script']) test('T22488_docHead', normal, compile_and_run, ['-package ghc']) test('T20531', extra_files(['T20531_defs.hs']), ghci_script, ['T20531.script']) -test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) \ No newline at end of file +test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) +test('HsDocTy', [ignore_stderr, req_ppr_deps], makefile_test, ['HsDocTy']) \ No newline at end of file ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -3898,6 +3898,10 @@ instance ExactPrint (HsType GhcPs) where exact (HsSpliceTy a splice) = do splice' <- markAnnotated splice return (HsSpliceTy a splice') + exact (HsDocTy an ty doc) = do + ty' <- markAnnotated ty + doc' <- markAnnotated doc + return (HsDocTy an ty' doc') exact (HsBangTy an (HsSrcBang mt up str) ty) = do an0 <- case mt of ===================================== utils/check-exact/Main.hs ===================================== @@ -59,7 +59,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../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) - "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) + -- "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3a.hs" (Just changeWhereIn3a) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3b.hs" (Just changeWhereIn3b) -- "../../testsuite/tests/ghc-api/exactprint/AddLocalDecl1.hs" (Just addLocaLDecl1) @@ -203,6 +203,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../testsuite/tests/ghc-api/exactprint/Test20239.hs" Nothing -- "../../testsuite/tests/printer/PprArrowLambdaCase.hs" Nothing -- "../../testsuite/tests/printer/Test16279.hs" Nothing + "../../testsuite/tests/printer/HsDocTy.hs" Nothing -- cloneT does not need a test, function can be retired View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d819193a69cdcbba823cd1309808abcfc9712a06...440638137dd8f5f6de794fcd1ad4ae96f89a41a3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d819193a69cdcbba823cd1309808abcfc9712a06...440638137dd8f5f6de794fcd1ad4ae96f89a41a3 You're receiving 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 Jan 9 07:36:29 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 09 Jan 2023 02:36:29 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Disable split sections on aarch64-deb10 build Message-ID: <63bbc3fd6c14a_136d983df048c2256de@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 7 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - + testsuite/tests/printer/HsDocTy.hs - testsuite/tests/printer/Makefile - testsuite/tests/printer/all.T - utils/check-exact/ExactPrint.hs - utils/check-exact/Main.hs Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -813,7 +813,7 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , standardBuilds Amd64 Darwin , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin - , standardBuilds AArch64 (Linux Debian10) + , standardBuildsWithConfig AArch64 (Linux Debian10) (splitSectionsBroken vanilla) , disableValidate (standardBuildsWithConfig AArch64 (Linux Debian10) llvm) , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla) , standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static) ===================================== .gitlab/jobs.yaml ===================================== @@ -1926,7 +1926,7 @@ "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release": { + "release-aarch64-linux-deb10-release+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1936,7 +1936,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release.tar.xz", + "ghc-aarch64-linux-deb10-release+llvm.tar.xz", "junit.xml" ], "reports": { @@ -1978,15 +1978,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", + "BUILD_FLAVOUR": "release+llvm", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release", + "TEST_ENV": "aarch64-linux-deb10-release+llvm", "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release+llvm": { + "release-aarch64-linux-deb10-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1996,7 +1996,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release+llvm.tar.xz", + "ghc-aarch64-linux-deb10-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2038,11 +2038,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", - "BUILD_FLAVOUR": "release+llvm", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release+llvm", + "TEST_ENV": "aarch64-linux-deb10-release+no_split_sections", "XZ_OPT": "-9" } }, ===================================== testsuite/tests/printer/HsDocTy.hs ===================================== @@ -0,0 +1,6 @@ +{-# OPTIONS_GHC -haddock #-} +module HsDocTy where + +class C1 a where + f1 :: a -> Int + -- ^ comment on Int ===================================== testsuite/tests/printer/Makefile ===================================== @@ -769,3 +769,9 @@ Test21355: Test21805: $(CHECK_PPR) $(LIBDIR) Test21805.hs $(CHECK_EXACT) $(LIBDIR) Test21805.hs + +.PHONY: HsDocTy +HsDocTy: + # See comment on pprWithDocString, this won't round trip + # $(CHECK_PPR) $(LIBDIR) HsDocTy.hs + $(CHECK_EXACT) $(LIBDIR) HsDocTy.hs ===================================== testsuite/tests/printer/all.T ===================================== @@ -185,4 +185,5 @@ test('Test21805', [ignore_stderr, req_ppr_deps], makefile_test, ['Test21805']) test('T22488', normal, ghci_script, ['T22488.script']) test('T22488_docHead', normal, compile_and_run, ['-package ghc']) test('T20531', extra_files(['T20531_defs.hs']), ghci_script, ['T20531.script']) -test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) \ No newline at end of file +test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) +test('HsDocTy', [ignore_stderr, req_ppr_deps], makefile_test, ['HsDocTy']) \ No newline at end of file ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -3898,6 +3898,10 @@ instance ExactPrint (HsType GhcPs) where exact (HsSpliceTy a splice) = do splice' <- markAnnotated splice return (HsSpliceTy a splice') + exact (HsDocTy an ty doc) = do + ty' <- markAnnotated ty + doc' <- markAnnotated doc + return (HsDocTy an ty' doc') exact (HsBangTy an (HsSrcBang mt up str) ty) = do an0 <- case mt of ===================================== utils/check-exact/Main.hs ===================================== @@ -59,7 +59,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../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) - "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) + -- "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3a.hs" (Just changeWhereIn3a) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3b.hs" (Just changeWhereIn3b) -- "../../testsuite/tests/ghc-api/exactprint/AddLocalDecl1.hs" (Just addLocaLDecl1) @@ -203,6 +203,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../testsuite/tests/ghc-api/exactprint/Test20239.hs" Nothing -- "../../testsuite/tests/printer/PprArrowLambdaCase.hs" Nothing -- "../../testsuite/tests/printer/Test16279.hs" Nothing + "../../testsuite/tests/printer/HsDocTy.hs" Nothing -- cloneT does not need a test, function can be retired View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/440638137dd8f5f6de794fcd1ad4ae96f89a41a3...965a273510adfac4f041a31182c2fec82e614e47 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/440638137dd8f5f6de794fcd1ad4ae96f89a41a3...965a273510adfac4f041a31182c2fec82e614e47 You're receiving 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 Jan 9 08:35:18 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 09 Jan 2023 03:35:18 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22718 Message-ID: <63bbd1c6d8060_136d98142d6b8023995c@gitlab.mail> Sebastian Graf pushed new branch wip/T22718 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22718 You're receiving 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 Jan 9 08:37:11 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 09 Jan 2023 03:37:11 -0500 Subject: [Git][ghc/ghc][wip/T22718] Handle shadowing in DmdAnal (#22718) Message-ID: <63bbd23778e2e_136d981dc91ce824698a@gitlab.mail> Sebastian Graf pushed to branch wip/T22718 at Glasgow Haskell Compiler / GHC Commits: d0425089 by Sebastian Graf at 2023-01-09T09:37:05+01:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. - - - - - 1 changed file: - compiler/GHC/Core/Opt/DmdAnal.hs Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -333,7 +333,8 @@ dmdAnalBindLetUp :: TopLevelFlag -> WithDmdType (DmdResult CoreBind a) dmdAnalBindLetUp top_lvl env id rhs anal_body = WithDmdType final_ty (R (NonRec id' rhs') (body')) where - WithDmdType body_ty body' = anal_body env + WithDmdType body_ty body' = anal_body (addInScopeAnalEnv env id) + -- addInScopeAnalEnv: id shadows existing signatures WithDmdType body_ty' id_dmd = findBndrDmd env body_ty id -- See Note [Finalising boxity for demand signatures] @@ -473,7 +474,7 @@ dmdAnal' env dmd (App fun arg) dmdAnal' env dmd (Lam var body) | isTyVar var = let - WithDmdType body_ty body' = dmdAnal env dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) dmd body in WithDmdType body_ty (Lam var body') @@ -481,7 +482,7 @@ dmdAnal' env dmd (Lam var body) = let (n, body_dmd) = peelCallDmd dmd -- body_dmd: a demand to analyze the body - WithDmdType body_ty body' = dmdAnal env body_dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) body_dmd body WithDmdType lam_ty var' = annotateLamIdBndr env body_ty var new_dmd_type = multDmdType n lam_ty in @@ -493,7 +494,8 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt_con bndrs rhs]) -- can consider its field demands when analysing the scrutinee. | want_precise_field_dmds alt_con = let - WithDmdType rhs_ty rhs' = dmdAnal env dmd rhs + rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + WithDmdType rhs_ty rhs' = dmdAnal rhs_env dmd rhs WithDmdType alt_ty1 fld_dmds = findBndrsDmds env rhs_ty bndrs WithDmdType alt_ty2 case_bndr_dmd = findBndrDmd env alt_ty1 case_bndr !case_bndr' = setIdDemandInfo case_bndr case_bndr_dmd @@ -629,7 +631,8 @@ dmdAnalSumAlts env dmd case_bndr (alt:alts) dmdAnalSumAlt :: AnalEnv -> SubDemand -> Id -> CoreAlt -> WithDmdType CoreAlt dmdAnalSumAlt env dmd case_bndr (Alt con bndrs rhs) - | WithDmdType rhs_ty rhs' <- dmdAnal env dmd rhs + | let rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + , WithDmdType rhs_ty rhs' <- dmdAnal rhs_env dmd rhs , WithDmdType alt_ty dmds <- findBndrsDmds env rhs_ty bndrs , let (_ :* case_bndr_sd) = findIdDemand alt_ty case_bndr -- See Note [Demand on case-alternative binders] @@ -2399,7 +2402,7 @@ enterDFun bind env emptySigEnv :: SigEnv emptySigEnv = emptyVarEnv --- | Extend an environment with the strictness IDs attached to the id +-- | Extend an environment with the strictness sigs attached to the Ids extendAnalEnvs :: TopLevelFlag -> AnalEnv -> [Id] -> AnalEnv extendAnalEnvs top_lvl env vars = env { ae_sigs = extendSigEnvs top_lvl (ae_sigs env) vars } @@ -2418,6 +2421,12 @@ extendSigEnv top_lvl sigs var sig = extendVarEnv sigs var (sig, top_lvl) lookupSigEnv :: AnalEnv -> Id -> Maybe (DmdSig, TopLevelFlag) lookupSigEnv env id = lookupVarEnv (ae_sigs env) id +addInScopeAnalEnv :: AnalEnv -> Var -> AnalEnv +addInScopeAnalEnv env id = env { ae_sigs = delVarEnv (ae_sigs env) id } + +addInScopeAnalEnvs :: AnalEnv -> [Var] -> AnalEnv +addInScopeAnalEnvs env ids = env { ae_sigs = delVarEnvList (ae_sigs env) ids } + nonVirgin :: AnalEnv -> AnalEnv nonVirgin env = env { ae_virgin = False } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d04250895ef9018151469d9fef68bc8a9c6b8297 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d04250895ef9018151469d9fef68bc8a9c6b8297 You're receiving 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 Jan 9 10:03:01 2023 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Mon, 09 Jan 2023 05:03:01 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] use call_info name consistently (instead of tuple_info) Message-ID: <63bbe6557759b_136d98d3597942806a2@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 60322fa3 by Luite Stegeman at 2023-01-09T19:01:35+09:00 use call_info name consistently (instead of tuple_info) - - - - - 2 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/StgToByteCode.hs Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -389,14 +389,14 @@ assembleI platform i = case i of -> do let ul_bco = assembleBCO platform proto p <- ioptr (liftM BCOPtrBCO ul_bco) emit (push_alts pk) [Op p] - PUSH_ALTS_TUPLE proto tuple_info tuple_proto + PUSH_ALTS_TUPLE proto call_info tuple_proto -> do let ul_bco = assembleBCO platform proto ul_tuple_bco = assembleBCO platform tuple_proto p <- ioptr (liftM BCOPtrBCO ul_bco) p_tup <- ioptr (liftM BCOPtrBCO ul_tuple_bco) info <- int (fromIntegral $ - mkNativeCallInfoSig platform tuple_info) + mkNativeCallInfoSig platform call_info) emit bci_PUSH_ALTS_T [Op p, Op info, Op p_tup] PUSH_PAD8 -> emit bci_PUSH_PAD8 [] @@ -623,8 +623,8 @@ mkNativeCallInfoSig platform NativeCallInfo{..} regs = allArgRegsCover platform mkNativeCallInfoLit :: Platform -> NativeCallInfo -> Literal -mkNativeCallInfoLit platform tuple_info = - mkLitWord platform . fromIntegral $ mkNativeCallInfoSig platform tuple_info +mkNativeCallInfoLit platform call_info = + mkLitWord platform . fromIntegral $ mkNativeCallInfoSig platform call_info -- Make lists of host-sized words for literals, so that when the -- words are placed in memory at increasing addresses, the ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -464,10 +464,10 @@ returnUnliftedReps d s szb reps = do [rep] -> return (unitOL $ RETURN_UNLIFTED (toArgRep platform rep)) -- otherwise use RETURN_TUPLE with a tuple descriptor nv_reps -> do - let (tuple_info, args_offsets) = layoutNativeCall profile NativeTupleReturn 0 (primRepCmmType platform) nv_reps + let (call_info, args_offsets) = layoutNativeCall profile NativeTupleReturn 0 (primRepCmmType platform) nv_reps args_ptrs = map (\(rep, off) -> (isFollowableArg (toArgRep platform rep), off)) args_offsets - tuple_bco <- emitBc (tupleBCO platform tuple_info args_ptrs) - return $ PUSH_UBX (mkNativeCallInfoLit platform tuple_info) 1 `consOL` + tuple_bco <- emitBc (tupleBCO platform call_info args_ptrs) + return $ PUSH_UBX (mkNativeCallInfoLit platform call_info) 1 `consOL` PUSH_BCO tuple_bco `consOL` unitOL RETURN_TUPLE return ( mkSlideB platform szb (d - s) -- clear to sequel @@ -484,11 +484,11 @@ returnUnboxedTuple d s p es = do profile <- getProfile let platform = profilePlatform profile arg_ty e = primRepCmmType platform (atomPrimRep e) - (tuple_info, tuple_components) = layoutNativeCall profile - NativeTupleReturn - d - arg_ty - es + (call_info, tuple_components) = layoutNativeCall profile + NativeTupleReturn + d + arg_ty + es go _ pushes [] = return (reverse pushes) go !dd pushes ((a, off):cs) = do (push, szb) <- pushAtom dd p a massert (off == dd + szb) @@ -496,7 +496,7 @@ returnUnboxedTuple d s p es = do pushes <- go d [] tuple_components ret <- returnUnliftedReps d s - (wordsToBytes platform $ nativeCallSize tuple_info) + (wordsToBytes platform $ nativeCallSize call_info) (map atomPrimRep es) return (mconcat pushes `appOL` ret) @@ -844,14 +844,14 @@ doCase d s p scrut bndr alts | ubx_frame = wordSize platform | otherwise = 0 - (bndr_size, tuple_info, args_offsets) + (bndr_size, call_info, args_offsets) | ubx_tuple_frame = let bndr_ty = primRepCmmType platform bndr_reps = filter (not.isVoidRep) (bcIdPrimReps bndr) - (tuple_info, args_offsets) = + (call_info, args_offsets) = layoutNativeCall profile NativeTupleReturn 0 bndr_ty bndr_reps - in ( wordsToBytes platform (nativeCallSize tuple_info) - , tuple_info + in ( wordsToBytes platform (nativeCallSize call_info) + , call_info , args_offsets ) | otherwise = ( wordsToBytes platform (idSizeW platform bndr) @@ -889,7 +889,7 @@ doCase d s p scrut bndr alts | isUnboxedTupleType bndr_ty || isUnboxedSumType bndr_ty = let bndr_ty = primRepCmmType platform . bcIdPrimRep tuple_start = d_bndr - (tuple_info, args_offsets) = + (call_info, args_offsets) = layoutNativeCall profile NativeTupleReturn 0 @@ -900,7 +900,7 @@ doCase d s p scrut bndr alts p' = Map.insertList [ (arg, tuple_start - - wordsToBytes platform (nativeCallSize tuple_info) + + wordsToBytes platform (nativeCallSize call_info) + offset) | (arg, offset) <- args_offsets , not (isVoidRep $ bcIdPrimRep arg)] @@ -1033,8 +1033,8 @@ doCase d s p scrut bndr alts let args_ptrs = map (\(rep, off) -> (isFollowableArg (toArgRep platform rep), off)) args_offsets - tuple_bco <- emitBc (tupleBCO platform tuple_info args_ptrs) - return (PUSH_ALTS_TUPLE alt_bco' tuple_info tuple_bco + tuple_bco <- emitBc (tupleBCO platform call_info args_ptrs) + return (PUSH_ALTS_TUPLE alt_bco' call_info tuple_bco `consOL` scrut_code) else let push_alts | not ubx_frame View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/60322fa3f7a8b8587b48842053eb7d96d2eff14b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/60322fa3f7a8b8587b48842053eb7d96d2eff14b You're receiving 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 Jan 9 10:39:00 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 09 Jan 2023 05:39:00 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/darwin-llvm-target Message-ID: <63bbeec416b2_136d98223baaac2908eb@gitlab.mail> Matthew Pickering pushed new branch wip/darwin-llvm-target at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/darwin-llvm-target You're receiving 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 Jan 9 10:50:24 2023 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Mon, 09 Jan 2023 05:50:24 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] Add PrimCallConv suppport to GHCi Message-ID: <63bbf170acb5c_136d9820fda2e4293133@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 992606f2 by Luite Stegeman at 2023-01-09T19:31:07+09:00 Add PrimCallConv suppport to GHCi This adds support for calling Cmm code from bytecode using the native calling convention, allowing modules that use `foreign import prim` to be loaded and debugged in GHCi. This patch introduces a new `PRIMCALL` bytecode instruction and a helper stack frame `stg_primcall`. The code is based on the existing functionality for dealing with unboxed tuples in bytecode, which has been generalised to handle arbitrary calls. Fixes #22051 - - - - - 21 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Foreign.hs - rts/Disassembler.c - rts/Interpreter.c - rts/RtsSymbols.c - rts/StgMiscClosures.cmm - rts/include/rts/Bytecodes.h - rts/include/stg/MiscClosures.h - testsuite/tests/ghci/prog014/prog014.T - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout-ws-32 - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm - + testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile - + testsuite/tests/ghci/should_run/GHCiPrimCall/all.T Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -12,7 +12,7 @@ module GHC.ByteCode.Asm ( bcoFreeNames, SizedSeq, sizeSS, ssElts, iNTERP_STACK_CHECK_THRESH, - mkTupleInfoLit + mkNativeCallInfoLit ) where import GHC.Prelude @@ -32,7 +32,6 @@ import GHC.Types.Unique.DSet import GHC.Utils.Outputable import GHC.Utils.Panic -import GHC.Utils.Panic.Plain import GHC.Core.TyCon import GHC.Data.FastString @@ -40,7 +39,7 @@ import GHC.Data.SizedSeq import GHC.StgToCmm.Layout ( ArgRep(..) ) import GHC.Cmm.Expr -import GHC.Cmm.CallConv ( tupleRegsCover ) +import GHC.Cmm.CallConv ( allArgRegsCover ) import GHC.Platform import GHC.Platform.Profile @@ -202,7 +201,8 @@ assembleBCO platform (ProtoBCO { protoBCOName = nm (final_insns, final_lits, final_ptrs) <- flip execStateT initial_state $ runAsm platform long_jumps env asm -- precomputed size should be equal to final size - massert (n_insns == sizeSS final_insns) + massertPpr (n_insns == sizeSS final_insns) + (text "bytecode instruction count mismatch") let asm_insns = ssElts final_insns insns_arr = Array.listArray (0, fromIntegral n_insns - 1) asm_insns @@ -351,7 +351,8 @@ largeArg platform w = case platformWordSize platform of fromIntegral (w `shiftR` 32), fromIntegral (w `shiftR` 16), fromIntegral w] - PW4 -> assert (w < fromIntegral (maxBound :: Word32)) $ + PW4 -> assertPpr (w < fromIntegral (maxBound :: Word32)) + (text "largeArg too big:" <+> ppr w) $ [fromIntegral (w `shiftR` 16), fromIntegral w] @@ -388,14 +389,14 @@ assembleI platform i = case i of -> do let ul_bco = assembleBCO platform proto p <- ioptr (liftM BCOPtrBCO ul_bco) emit (push_alts pk) [Op p] - PUSH_ALTS_TUPLE proto tuple_info tuple_proto + PUSH_ALTS_TUPLE proto call_info tuple_proto -> do let ul_bco = assembleBCO platform proto ul_tuple_bco = assembleBCO platform tuple_proto p <- ioptr (liftM BCOPtrBCO ul_bco) p_tup <- ioptr (liftM BCOPtrBCO ul_tuple_bco) info <- int (fromIntegral $ - mkTupleInfoSig platform tuple_info) + mkNativeCallInfoSig platform call_info) emit bci_PUSH_ALTS_T [Op p, Op info, Op p_tup] PUSH_PAD8 -> emit bci_PUSH_PAD8 [] @@ -491,6 +492,7 @@ assembleI platform i = case i of RETURN_TUPLE -> emit bci_RETURN_T [] CCALL off m_addr i -> do np <- addr m_addr emit bci_CCALL [SmallOp off, Op np, SmallOp i] + PRIMCALL -> emit bci_PRIMCALL [] BRK_FUN index uniq cc -> do p1 <- ptr BCOPtrBreakArray q <- int (getKey uniq) np <- addr cc @@ -582,39 +584,47 @@ return_unlifted V64 = error "return_unlifted: vector" platform). -} -maxTupleNativeStackSize :: WordOff -maxTupleNativeStackSize = 62 +maxTupleReturnNativeStackSize :: WordOff +maxTupleReturnNativeStackSize = 62 + +maxPrimCallNativeStackSize :: WordOff +maxPrimCallNativeStackSize = 255 {- - Construct the tuple_info word that stg_ctoi_t and stg_ret_t use - to convert a tuple between the native calling convention and the + Construct the call_info word that stg_ctoi_t, stg_ret_t and stg_primcall + use to convert arguments between the native calling convention and the interpreter. - See Note [GHCi tuple layout] for more information. + See Note [GHCi and native call registers] for more information. -} -mkTupleInfoSig :: Platform -> TupleInfo -> Word32 -mkTupleInfoSig platform TupleInfo{..} - | tupleNativeStackSize > maxTupleNativeStackSize - = pprPanic "mkTupleInfoSig: tuple too big for the bytecode compiler" - (ppr tupleNativeStackSize <+> text "stack words." <+> +mkNativeCallInfoSig :: Platform -> NativeCallInfo -> Word32 +mkNativeCallInfoSig platform NativeCallInfo{..} + | nativeCallType == NativePrimCall && nativeCallStackSpillSize > maxPrimCallNativeStackSize + = pprPanic "mkNativeCallInfoSig: native call too big for the bytecode compiler" + (ppr nativeCallStackSpillSize <+> text "stack words." <+> + text "Use -fobject-code to get around this limit" + ) + | nativeCallType == NativeTupleReturn && nativeCallStackSpillSize > maxTupleReturnNativeStackSize + = pprPanic "mkNativeCallInfoSig: tuple too big for the bytecode compiler" + (ppr nativeCallStackSpillSize <+> text "stack words." <+> text "Use -fobject-code to get around this limit" ) | otherwise - = assert (length regs <= 24) {- 24 bits for bitmap -} - assert (tupleNativeStackSize < 255) {- 8 bits for stack size -} - assert (all (`elem` regs) (regSetToList tupleRegs)) {- all regs accounted for -} + = assertPpr (length regs <= 24) (text "too many registers for bitmap:" <+> ppr (length regs)) {- 24 bits for bitmap -} + assertPpr (nativeCallStackSpillSize < 255) (text "stack spill size too large:" <+> ppr nativeCallStackSpillSize) {- 8 bits for stack size -} + assertPpr (all (`elem` regs) (regSetToList nativeCallRegs)) (text "not all registers accounted for") {- all regs accounted for -} foldl' reg_bit 0 (zip regs [0..]) .|. - (fromIntegral tupleNativeStackSize `shiftL` 24) + (fromIntegral nativeCallStackSpillSize `shiftL` 24) where reg_bit :: Word32 -> (GlobalReg, Int) -> Word32 reg_bit x (r, n) - | r `elemRegSet` tupleRegs = x .|. 1 `shiftL` n - | otherwise = x - regs = tupleRegsCover platform + | r `elemRegSet` nativeCallRegs = x .|. 1 `shiftL` n + | otherwise = x + regs = allArgRegsCover platform -mkTupleInfoLit :: Platform -> TupleInfo -> Literal -mkTupleInfoLit platform tuple_info = - mkLitWord platform . fromIntegral $ mkTupleInfoSig platform tuple_info +mkNativeCallInfoLit :: Platform -> NativeCallInfo -> Literal +mkNativeCallInfoLit platform call_info = + mkLitWord platform . fromIntegral $ mkNativeCallInfoSig platform call_info -- Make lists of host-sized words for literals, so that when the -- words are placed in memory at increasing addresses, the ===================================== compiler/GHC/ByteCode/Instr.hs ===================================== @@ -90,7 +90,7 @@ data BCInstr | PUSH_ALTS (ProtoBCO Name) | PUSH_ALTS_UNLIFTED (ProtoBCO Name) ArgRep | PUSH_ALTS_TUPLE (ProtoBCO Name) -- continuation - !TupleInfo + !NativeCallInfo (ProtoBCO Name) -- tuple return BCO -- Pushing 8, 16 and 32 bits of padding (for constructors). @@ -184,6 +184,8 @@ data BCInstr -- (XXX: inefficient, but I don't know -- what the alignment constraints are.) + | PRIMCALL + -- For doing magic ByteArray passing to foreign calls | SWIZZLE Word16 -- to the ptr N words down the stack, Word16 -- add M (interpreted as a signed 16-bit entity) @@ -269,8 +271,8 @@ instance Outputable BCInstr where ppr (PUSH_ALTS bco) = hang (text "PUSH_ALTS") 2 (ppr bco) ppr (PUSH_ALTS_UNLIFTED bco pk) = hang (text "PUSH_ALTS_UNLIFTED" <+> ppr pk) 2 (ppr bco) - ppr (PUSH_ALTS_TUPLE bco tuple_info tuple_bco) = - hang (text "PUSH_ALTS_TUPLE" <+> ppr tuple_info) + ppr (PUSH_ALTS_TUPLE bco call_info tuple_bco) = + hang (text "PUSH_ALTS_TUPLE" <+> ppr call_info) 2 (ppr tuple_bco $+$ ppr bco) @@ -340,6 +342,7 @@ instance Outputable BCInstr where 0x1 -> text "(interruptible)" 0x2 -> text "(unsafe)" _ -> empty) + ppr PRIMCALL = text "PRIMCALL" ppr (SWIZZLE stkoff n) = text "SWIZZLE " <+> text "stkoff" <+> ppr stkoff <+> text "by" <+> ppr n ppr ENTER = text "ENTER" @@ -382,11 +385,11 @@ bciStackUse (PUSH_ALTS bco) = 2 {- profiling only, restore CCCS -} + bciStackUse (PUSH_ALTS_UNLIFTED bco _) = 2 {- profiling only, restore CCCS -} + 4 + protoBCOStackUse bco bciStackUse (PUSH_ALTS_TUPLE bco info _) = - -- (tuple_bco, tuple_info word, cont_bco, stg_ctoi_t) + -- (tuple_bco, call_info word, cont_bco, stg_ctoi_t) -- tuple - -- (tuple_info, tuple_bco, stg_ret_t) + -- (call_info, tuple_bco, stg_ret_t) 1 {- profiling only -} + - 7 + fromIntegral (tupleSize info) + protoBCOStackUse bco + 7 + fromIntegral (nativeCallSize info) + protoBCOStackUse bco bciStackUse (PUSH_PAD8) = 1 -- overapproximation bciStackUse (PUSH_PAD16) = 1 -- overapproximation bciStackUse (PUSH_PAD32) = 1 -- overapproximation on 64bit arch @@ -443,6 +446,7 @@ bciStackUse RETURN{} = 0 bciStackUse RETURN_UNLIFTED{} = 1 -- pushes stg_ret_X for some X bciStackUse RETURN_TUPLE{} = 1 -- pushes stg_ret_t header bciStackUse CCALL{} = 0 +bciStackUse PRIMCALL{} = 1 -- pushes stg_primcall bciStackUse SWIZZLE{} = 0 bciStackUse BRK_FUN{} = 0 ===================================== compiler/GHC/ByteCode/Types.hs ===================================== @@ -10,7 +10,7 @@ module GHC.ByteCode.Types ( CompiledByteCode(..), seqCompiledByteCode , FFIInfo(..) , RegBitmap(..) - , TupleInfo(..), voidTupleInfo + , NativeCallType(..), NativeCallInfo(..), voidTupleReturnInfo, voidPrimCallInfo , ByteOff(..), WordOff(..) , UnlinkedBCO(..), BCOPtr(..), BCONPtr(..) , ItblEnv, ItblPtr(..) @@ -105,22 +105,32 @@ newtype RegBitmap = RegBitmap { unRegBitmap :: Word32 } See GHC.StgToByteCode.layoutTuple for more details. -} -data TupleInfo = TupleInfo - { tupleSize :: !WordOff -- total size of tuple in words - , tupleRegs :: !GlobalRegSet - , tupleNativeStackSize :: !WordOff {- words spilled on the stack by - GHCs native calling convention -} - } deriving (Show) - -instance Outputable TupleInfo where - ppr TupleInfo{..} = text " ppr tupleSize <+> - text "stack" <+> ppr tupleNativeStackSize <+> - text "regs" <+> - ppr (map (text @SDoc . show) $ regSetToList tupleRegs) <> - char '>' - -voidTupleInfo :: TupleInfo -voidTupleInfo = TupleInfo 0 emptyRegSet 0 + +data NativeCallType = NativePrimCall + | NativeTupleReturn + deriving (Eq) + +data NativeCallInfo = NativeCallInfo + { nativeCallType :: !NativeCallType + , nativeCallSize :: !WordOff -- total size of arguments in words + , nativeCallRegs :: !GlobalRegSet + , nativeCallStackSpillSize :: !WordOff {- words spilled on the stack by + GHCs native calling convention -} + } + +instance Outputable NativeCallInfo where + ppr NativeCallInfo{..} = text " ppr nativeCallSize <+> + text "stack" <+> ppr nativeCallStackSpillSize <+> + text "regs" <+> + ppr (map (text @SDoc . show) $ regSetToList nativeCallRegs) <> + char '>' + + +voidTupleReturnInfo :: NativeCallInfo +voidTupleReturnInfo = NativeCallInfo NativeTupleReturn 0 emptyRegSet 0 + +voidPrimCallInfo :: NativeCallInfo +voidPrimCallInfo = NativeCallInfo NativePrimCall 0 emptyRegSet 0 type ItblEnv = NameEnv (Name, ItblPtr) -- We need the Name in the range so we know which ===================================== compiler/GHC/Cmm/CallConv.hs ===================================== @@ -3,7 +3,7 @@ module GHC.Cmm.CallConv ( assignArgumentsPos, assignStack, realArgRegsCover, - tupleRegsCover + allArgRegsCover ) where import GHC.Prelude @@ -220,12 +220,104 @@ realArgRegsCover platform realLongRegs platform -- we don't save XMM registers if they are not used for parameter passing --- Like realArgRegsCover but always includes the node. This covers the real --- and virtual registers used for unboxed tuples. --- --- Note: if anything changes in how registers for unboxed tuples overlap, --- make sure to also update GHC.StgToByteCode.layoutTuple. -tupleRegsCover :: Platform -> [GlobalReg] -tupleRegsCover platform = +{- + + Note [GHCi and native call registers] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + The GHCi bytecode interpreter does not have access to the STG registers + that the native calling convention uses for passing arguments. It uses + helper stack frames to move values between the stack and registers. + + If only a single register needs to be moved, GHCi uses a specific stack + frame. For example stg_ctoi_R1p saves a heap pointer value from STG register + R1 and stg_ctoi_D1 saves a double precision floating point value from D1. + In the other direction, helpers stg_ret_p and stg_ret_d move a value from + the stack to the R1 and D1 registers, respectively. + + When GHCi needs to move more than one register it cannot use a specific + helper frame. It would simply be impossible to create a helper for all + possible combinations of register values. Instead, there are generic helper + stack frames that use a call_info word that describes the active registers + and the number of stack words used by the arguments of a call. + + These helper stack frames are currently: + + - stg_ret_t: return a tuple to the continuation at the top of + the stack + - stg_ctoi_t: convert a tuple return value to be used in + bytecode + - stg_primcall: call a function + + + The call_info word contains a bitmap of the active registers + for the call and and a stack offset. The layout is as follows: + + - bit 0-23: Bitmap of active registers for the call, the + order corresponds to the list returned by + allArgRegsCover. For example if bit 0 (the least + significant bit) is set, the first register in the + allArgRegsCover list is active. Bit 1 for the + second register in the list and so on. + + - bit 24-31: Unsigned byte, indicating the stack usage of the + call in words (not counting the space ) + + The upper 32 bits on 64 bit platforms are currently unused. + + If a register is smaller than a word on the stack (for example a + single precision float on a 64 bit system), then the stack slot + is padded to a whole word. + + Example: + + If a call has three arguments passed registers and and + additional five words of arguments on the stack, then + three bits in the bitmap in bits 0-23 would be set. And + Bit 24-31 would be 00000010 (two in binary). + + The values on the stack before a call to POP_ARG_REGS would + be as follows: + + ... + stack_arg_1 + stack_arg_2 + register_arg_3 + register_arg_2 + register_arg_1 <- Sp + + A call to POP_ARG_REGS(call_info) would move register_arg_1 + to the register corresponding to the lowest set bit in the + call_info word. register_arg_2 would be moved to the register + corresponding to the second lowest set bit, and so on. + + After POP_ARG_REGS(call_info), the stack pointer Sp points + to the first stack slot below the stack arguments. The stack + arguments are still on the stack above Sp, so the stack looks + as follows: + + ... <- Sp + stack_arg_1 + stack_arg_2 + + At this point all the arguments are in place and we are ready + to jump to the native function. + + On x86_64, the double precision (Dn) and single precision + floating (Fn) point registers overlap, e.g. D1 uses the same + physical register as F1. On this platform, the list returned + by allArgRegsCover contains only entries for the double + precision registers. If an argument is passed in register + Fn, the bit corresponding to Dn should be set. + + Note: if anything changes in how registers for native calls overlap, + make sure to also update GHC.StgToByteCode.layoutNativeCall + -} + +-- Like realArgRegsCover but always includes the node. This covers all real +-- and virtual registers actually used for passing arguments. + +allArgRegsCover :: Platform -> [GlobalReg] +allArgRegsCover platform = nub (VanillaReg 1 VGcPtr : realArgRegsCover platform) ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -1233,8 +1233,8 @@ stmtMacros = listToUFM [ ( fsLit "SAVE_REGS", \[] -> emitSaveRegs ), ( fsLit "RESTORE_REGS", \[] -> emitRestoreRegs ), - ( fsLit "PUSH_TUPLE_REGS", \[live_regs] -> emitPushTupleRegs live_regs ), - ( fsLit "POP_TUPLE_REGS", \[live_regs] -> emitPopTupleRegs live_regs ), + ( fsLit "PUSH_ARG_REGS", \[live_regs] -> emitPushArgRegs live_regs ), + ( fsLit "POP_ARG_REGS", \[live_regs] -> emitPopArgRegs live_regs ), ( fsLit "LDV_ENTER", \[e] -> ldvEnter e ), ( fsLit "LDV_RECORD_CREATE", \[e] -> ldvRecordCreate e ), ===================================== compiler/GHC/Cmm/Reg.hs ===================================== @@ -223,7 +223,7 @@ instance Eq GlobalReg where _r1 == _r2 = False -- NOTE: this Ord instance affects the tuple layout in GHCi, see --- Note [GHCi tuple layout] +-- Note [GHCi and native call registers] instance Ord GlobalReg where compare (VanillaReg i _) (VanillaReg j _) = compare i j -- Ignore type when seeking clashes ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -58,7 +58,7 @@ import GHC.Data.FastString import GHC.Utils.Panic import GHC.Utils.Panic.Plain import GHC.Utils.Exception (evaluate) -import GHC.StgToCmm.Closure ( NonVoid(..), fromNonVoid, nonVoidIds ) +import GHC.StgToCmm.Closure ( NonVoid(..), fromNonVoid, nonVoidIds, argPrimRep ) import GHC.StgToCmm.Layout import GHC.Runtime.Heap.Layout hiding (WordOff, ByteOff, wordsToBytes) import GHC.Data.Bitmap @@ -464,10 +464,10 @@ returnUnliftedReps d s szb reps = do [rep] -> return (unitOL $ RETURN_UNLIFTED (toArgRep platform rep)) -- otherwise use RETURN_TUPLE with a tuple descriptor nv_reps -> do - let (tuple_info, args_offsets) = layoutTuple profile 0 (primRepCmmType platform) nv_reps + let (call_info, args_offsets) = layoutNativeCall profile NativeTupleReturn 0 (primRepCmmType platform) nv_reps args_ptrs = map (\(rep, off) -> (isFollowableArg (toArgRep platform rep), off)) args_offsets - tuple_bco <- emitBc (tupleBCO platform tuple_info args_ptrs) - return $ PUSH_UBX (mkTupleInfoLit platform tuple_info) 1 `consOL` + tuple_bco <- emitBc (tupleBCO platform call_info args_ptrs) + return $ PUSH_UBX (mkNativeCallInfoLit platform call_info) 1 `consOL` PUSH_BCO tuple_bco `consOL` unitOL RETURN_TUPLE return ( mkSlideB platform szb (d - s) -- clear to sequel @@ -484,7 +484,11 @@ returnUnboxedTuple d s p es = do profile <- getProfile let platform = profilePlatform profile arg_ty e = primRepCmmType platform (atomPrimRep e) - (tuple_info, tuple_components) = layoutTuple profile d arg_ty es + (call_info, tuple_components) = layoutNativeCall profile + NativeTupleReturn + d + arg_ty + es go _ pushes [] = return (reverse pushes) go !dd pushes ((a, off):cs) = do (push, szb) <- pushAtom dd p a massert (off == dd + szb) @@ -492,7 +496,7 @@ returnUnboxedTuple d s p es = do pushes <- go d [] tuple_components ret <- returnUnliftedReps d s - (wordsToBytes platform $ tupleSize tuple_info) + (wordsToBytes platform $ nativeCallSize call_info) (map atomPrimRep es) return (mconcat pushes `appOL` ret) @@ -648,14 +652,14 @@ schemeT d s p app -- Case 1 schemeT d s p (StgOpApp (StgFCallOp (CCall ccall_spec) _ty) args result_ty) = if isSupportedCConv ccall_spec - then generateCCall d s p ccall_spec result_ty (reverse args) + then generateCCall d s p ccall_spec result_ty args else unsupportedCConvException schemeT d s p (StgOpApp (StgPrimOp op) args _ty) = doTailCall d s p (primOpId op) (reverse args) -schemeT _d _s _p (StgOpApp StgPrimCallOp{} _args _ty) - = unsupportedCConvException +schemeT d s p (StgOpApp (StgPrimCallOp (PrimCall label unit)) args result_ty) + = generatePrimCall d s p label (Just unit) result_ty args -- Case 2: Unboxed tuple schemeT d s p (StgConApp con _cn args _tys) @@ -840,18 +844,18 @@ doCase d s p scrut bndr alts | ubx_frame = wordSize platform | otherwise = 0 - (bndr_size, tuple_info, args_offsets) + (bndr_size, call_info, args_offsets) | ubx_tuple_frame = let bndr_ty = primRepCmmType platform bndr_reps = filter (not.isVoidRep) (bcIdPrimReps bndr) - (tuple_info, args_offsets) = - layoutTuple profile 0 bndr_ty bndr_reps - in ( wordsToBytes platform (tupleSize tuple_info) - , tuple_info + (call_info, args_offsets) = + layoutNativeCall profile NativeTupleReturn 0 bndr_ty bndr_reps + in ( wordsToBytes platform (nativeCallSize call_info) + , call_info , args_offsets ) | otherwise = ( wordsToBytes platform (idSizeW platform bndr) - , voidTupleInfo + , voidTupleReturnInfo , [] ) @@ -885,17 +889,18 @@ doCase d s p scrut bndr alts | isUnboxedTupleType bndr_ty || isUnboxedSumType bndr_ty = let bndr_ty = primRepCmmType platform . bcIdPrimRep tuple_start = d_bndr - (tuple_info, args_offsets) = - layoutTuple profile - 0 - bndr_ty - bndrs + (call_info, args_offsets) = + layoutNativeCall profile + NativeTupleReturn + 0 + bndr_ty + bndrs stack_bot = d_alts p' = Map.insertList [ (arg, tuple_start - - wordsToBytes platform (tupleSize tuple_info) + + wordsToBytes platform (nativeCallSize call_info) + offset) | (arg, offset) <- args_offsets , not (isVoidRep $ bcIdPrimRep arg)] @@ -981,8 +986,8 @@ doCase d s p scrut bndr alts -- unboxed tuples get two more words, the second is a pointer (tuple_bco) (extra_pointers, extra_slots) - | ubx_tuple_frame && profiling = ([1], 3) -- tuple_info, tuple_BCO, CCCS - | ubx_tuple_frame = ([1], 2) -- tuple_info, tuple_BCO + | ubx_tuple_frame && profiling = ([1], 3) -- call_info, tuple_BCO, CCCS + | ubx_tuple_frame = ([1], 2) -- call_info, tuple_BCO | otherwise = ([], 0) bitmap_size = trunc16W $ fromIntegral extra_slots + @@ -1028,8 +1033,8 @@ doCase d s p scrut bndr alts let args_ptrs = map (\(rep, off) -> (isFollowableArg (toArgRep platform rep), off)) args_offsets - tuple_bco <- emitBc (tupleBCO platform tuple_info args_ptrs) - return (PUSH_ALTS_TUPLE alt_bco' tuple_info tuple_bco + tuple_bco <- emitBc (tupleBCO platform call_info args_ptrs) + return (PUSH_ALTS_TUPLE alt_bco' call_info tuple_bco `consOL` scrut_code) else let push_alts | not ubx_frame @@ -1050,14 +1055,15 @@ doCase d s p scrut bndr alts -- The native calling convention uses registers for tuples, but in the -- bytecode interpreter, all values live on the stack. -layoutTuple :: Profile - -> ByteOff - -> (a -> CmmType) - -> [a] - -> ( TupleInfo -- See Note [GHCi TupleInfo] - , [(a, ByteOff)] -- argument, offset on stack - ) -layoutTuple profile start_off arg_ty reps = +layoutNativeCall :: Profile + -> NativeCallType + -> ByteOff + -> (a -> CmmType) + -> [a] + -> ( NativeCallInfo -- See Note [GHCi TupleInfo] + , [(a, ByteOff)] -- argument, offset on stack + ) +layoutNativeCall profile call_type start_off arg_ty reps = let platform = profilePlatform profile (orig_stk_bytes, pos) = assignArgumentsPos profile 0 @@ -1070,7 +1076,7 @@ layoutTuple profile start_off arg_ty reps = -- sort the register parameters by register and add them to the stack regs_order :: Map.Map GlobalReg Int - regs_order = Map.fromList $ zip (tupleRegsCover platform) [0..] + regs_order = Map.fromList $ zip (allArgRegsCover platform) [0..] reg_order :: GlobalReg -> (Int, GlobalReg) reg_order reg | Just n <- Map.lookup reg regs_order = (n, reg) @@ -1099,10 +1105,11 @@ layoutTuple profile start_off arg_ty reps = get_byte_off _ = panic "GHC.StgToByteCode.layoutTuple get_byte_off" - in ( TupleInfo - { tupleSize = bytesToWords platform (ByteOff new_stk_bytes) - , tupleRegs = regs_set - , tupleNativeStackSize = bytesToWords platform + in ( NativeCallInfo + { nativeCallType = call_type + , nativeCallSize = bytesToWords platform (ByteOff new_stk_bytes) + , nativeCallRegs = regs_set + , nativeCallStackSpillSize = bytesToWords platform (ByteOff orig_stk_bytes) } , sortBy (comparing snd) $ @@ -1127,7 +1134,7 @@ usePlainReturn t ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We have the bytecode instructions RETURN_TUPLE and PUSH_ALTS_TUPLE to return and receive arbitrary unboxed tuples, respectively. These - instructions use the helper data tuple_BCO and tuple_info. + instructions use the helper data tuple_BCO and call_info. The helper data is used to convert tuples between GHCs native calling convention (object code), which uses stack and registers, and the bytecode @@ -1139,7 +1146,7 @@ usePlainReturn t ================= Bytecode that returns a tuple first pushes all the tuple fields followed - by the appropriate tuple_info and tuple_BCO onto the stack. It then + by the appropriate call_info and tuple_BCO onto the stack. It then executes the RETURN_TUPLE instruction, which causes the interpreter to push stg_ret_t_info to the top of the stack. The stack (growing down) then looks as follows: @@ -1150,14 +1157,14 @@ usePlainReturn t tuple_field_2 ... tuple_field_n - tuple_info + call_info tuple_BCO stg_ret_t_info <- Sp If next_frame is bytecode, the interpreter will start executing it. If it's object code, the interpreter jumps back to the scheduler, which in turn jumps to stg_ret_t. stg_ret_t converts the tuple to the native - calling convention using the description in tuple_info, and then jumps + calling convention using the description in call_info, and then jumps to next_frame. @@ -1169,13 +1176,13 @@ usePlainReturn t tuple. The PUSH_ALTS_TUPLE instuction contains three pieces of data: * cont_BCO: the continuation that receives the tuple - * tuple_info: see below + * call_info: see below * tuple_BCO: see below The interpreter pushes these onto the stack when the PUSH_ALTS_TUPLE instruction is executed, followed by stg_ctoi_tN_info, with N depending on the number of stack words used by the tuple in the GHC native calling - convention. N is derived from tuple_info. + convention. N is derived from call_info. For example if we expect a tuple with three words on the stack, the stack looks as follows after PUSH_ALTS_TUPLE: @@ -1186,7 +1193,7 @@ usePlainReturn t cont_free_var_2 ... cont_free_var_n - tuple_info + call_info tuple_BCO cont_BCO stg_ctoi_t3_info <- Sp @@ -1206,20 +1213,20 @@ usePlainReturn t that is already on the stack. - The tuple_info word + The call_info word =================== - The tuple_info word describes the stack and STG register (e.g. R1..R6, - D1..D6) usage for the tuple. tuple_info contains enough information to + The call_info word describes the stack and STG register (e.g. R1..R6, + D1..D6) usage for the tuple. call_info contains enough information to convert the tuple between the stack-only bytecode and stack+registers GHC native calling conventions. - See Note [GHCi tuple layout] for more details of how the data is packed - in a single word. + See Note [GHCi and native call registers] for more details of how the + data is packed in a single word. -} -tupleBCO :: Platform -> TupleInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name +tupleBCO :: Platform -> NativeCallInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name tupleBCO platform info pointers = mkProtoBCO platform invented_name body_code (Left []) 0{-no arity-} bitmap_size bitmap False{-is alts-} @@ -1233,15 +1240,103 @@ tupleBCO platform info pointers = -} invented_name = mkSystemVarName (mkPseudoUniqueE 0) (fsLit "tuple") - -- the first word in the frame is the tuple_info word, + -- the first word in the frame is the call_info word, -- which is not a pointer - bitmap_size = trunc16W $ 1 + tupleSize info + bitmap_size = trunc16W $ 1 + nativeCallSize info bitmap = intsToReverseBitmap platform (fromIntegral bitmap_size) $ map ((+1) . fromIntegral . bytesToWords platform . snd) (filter fst pointers) body_code = mkSlideW 0 1 -- pop frame header `snocOL` RETURN_TUPLE -- and add it again +primCallBCO :: Platform -> NativeCallInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name +primCallBCO platform args_info pointers = + mkProtoBCO platform invented_name body_code (Left []) + 0{-no arity-} bitmap_size bitmap False{-is alts-} + + where + {- + The primcall BCO is never referred to by name, so we can get away + with using a fake name here. We will need to change this if we want + to save some memory by sharing the BCO between places that have + the same tuple shape + -} + invented_name = mkSystemVarName (mkPseudoUniqueE 0) (fsLit "primcall") + + -- the first three words in the frame are the BCO describing the + -- pointers in the frame, the call_info word and the pointer + -- to the Cmm function being called. None of these is a pointer that + -- should be followed by the garbage collector + bitmap_size = trunc16W $ 2 + nativeCallSize args_info + bitmap = intsToReverseBitmap platform (fromIntegral bitmap_size) $ + map ((+2) . fromIntegral . bytesToWords platform . snd) + (filter fst pointers) + -- if the primcall BCO is ever run it's a bug, since the BCO should only + -- be pushed immediately before running the PRIMCALL bytecode instruction, + -- which immediately leaves the interpreter to jump to the stg_primcall_info + -- Cmm function + body_code = unitOL CASEFAIL + +-- ----------------------------------------------------------------------------- +-- Deal with a primitive call to native code. + +generatePrimCall + :: StackDepth + -> Sequel + -> BCEnv + -> CLabelString -- where to call + -> Maybe Unit + -> Type + -> [StgArg] -- args (atoms) + -> BcM BCInstrList +generatePrimCall d s p target _mb_unit _result_ty args + = do + profile <- getProfile + let + platform = profilePlatform profile + + non_void VoidRep = False + non_void _ = True + + nv_args :: [StgArg] + nv_args = filter (non_void . argPrimRep) args + + (args_info, args_offsets) = + layoutNativeCall profile + NativePrimCall + d + (primRepCmmType platform . argPrimRep) + nv_args + + args_ptrs :: [(Bool, ByteOff)] + args_ptrs = + map (\(r, off) -> + (isFollowableArg (toArgRep platform . argPrimRep $ r), off)) + args_offsets + + push_target = PUSH_UBX (LitLabel target Nothing IsFunction) 1 + push_info = PUSH_UBX (mkNativeCallInfoLit platform args_info) 1 + {- + compute size to move payload (without stg_primcall_info header) + + size of arguments plus three words for: + - function pointer to the target + - call_info word + - BCO to describe the stack frame + -} + szb = wordsToBytes platform (nativeCallSize args_info + 3) + go _ pushes [] = return (reverse pushes) + go !dd pushes ((a, off):cs) = do (push, szb) <- pushAtom dd p a + massert (off == dd + szb) + go (dd + szb) (push:pushes) cs + push_args <- go d [] args_offsets + args_bco <- emitBc (primCallBCO platform args_info args_ptrs) + return $ mconcat push_args `appOL` + (push_target `consOL` + push_info `consOL` + PUSH_BCO args_bco `consOL` + (mkSlideB platform szb (d - s) `appOL` unitOL PRIMCALL)) + -- ----------------------------------------------------------------------------- -- Deal with a CCall. @@ -1259,11 +1354,17 @@ generateCCall -> Type -> [StgArg] -- args (atoms) -> BcM BCInstrList -generateCCall d0 s p (CCallSpec target cconv safety) result_ty args_r_to_l +generateCCall d0 s p (CCallSpec target PrimCallConv _) result_ty args + | (StaticTarget _ label mb_unit _) <- target + = generatePrimCall d0 s p label mb_unit result_ty args + | otherwise + = panic "GHC.StgToByteCode.generateCCall: primcall convention only supports static targets" +generateCCall d0 s p (CCallSpec target cconv safety) result_ty args = do profile <- getProfile let + args_r_to_l = reverse args platform = profilePlatform profile -- useful constants addr_size_b :: ByteOff @@ -2007,7 +2108,7 @@ isSupportedCConv :: CCallSpec -> Bool isSupportedCConv (CCallSpec _ cconv _) = case cconv of CCallConv -> True -- we explicitly pattern match on every StdCallConv -> True -- convention to ensure that a warning - PrimCallConv -> False -- is triggered when a new one is added + PrimCallConv -> True -- is triggered when a new one is added JavaScriptCallConv -> False CApiConv -> True ===================================== compiler/GHC/StgToCmm/Foreign.hs ===================================== @@ -15,8 +15,8 @@ module GHC.StgToCmm.Foreign ( emitLoadThreadState, emitSaveRegs, emitRestoreRegs, - emitPushTupleRegs, - emitPopTupleRegs, + emitPushArgRegs, + emitPopArgRegs, loadThreadState, emitOpenNursery, emitCloseNursery, @@ -349,7 +349,7 @@ emitRestoreRegs = do -- bytecode interpreter. -- -- The "live registers" bitmap corresponds to the list of registers given by --- 'tupleRegsCover', with the least significant bit indicating liveness of +-- 'allArgRegsCover', with the least significant bit indicating liveness of -- the first register in the list. -- -- Each register is saved to a stack slot of one or more machine words, even @@ -362,12 +362,12 @@ emitRestoreRegs = do -- if((mask & 2) != 0) { Sp_adj(-1); Sp(0) = R2; } -- if((mask & 1) != 0) { Sp_adj(-1); Sp(0) = R1; } -- --- See Note [GHCi tuple layout] +-- See Note [GHCi and native call registers] -emitPushTupleRegs :: CmmExpr -> FCode () -emitPushTupleRegs regs_live = do +emitPushArgRegs :: CmmExpr -> FCode () +emitPushArgRegs regs_live = do platform <- getPlatform - let regs = zip (tupleRegsCover platform) [0..] + let regs = zip (allArgRegsCover platform) [0..] save_arg (reg, n) = let mask = CmmLit (CmmInt (1 `shiftL` n) (wordWidth platform)) live = cmmAndWord platform regs_live mask @@ -381,11 +381,11 @@ emitPushTupleRegs regs_live = do in mkCmmIfThen cond $ catAGraphs [adj_sp, save_reg] emit . catAGraphs =<< mapM save_arg (reverse regs) --- | Pop a subset of STG registers from the stack (see 'emitPushTupleRegs') -emitPopTupleRegs :: CmmExpr -> FCode () -emitPopTupleRegs regs_live = do +-- | Pop a subset of STG registers from the stack (see 'emitPushArgRegs') +emitPopArgRegs :: CmmExpr -> FCode () +emitPopArgRegs regs_live = do platform <- getPlatform - let regs = zip (tupleRegsCover platform) [0..] + let regs = zip (allArgRegsCover platform) [0..] save_arg (reg, n) = let mask = CmmLit (CmmInt (1 `shiftL` n) (wordWidth platform)) live = cmmAndWord platform regs_live mask ===================================== rts/Disassembler.c ===================================== @@ -83,6 +83,9 @@ disInstr ( StgBCO *bco, int pc ) debugBelch("CCALL marshaller at 0x%" FMT_HexWord "\n", literals[instrs[pc]] ); pc += 1; break; + case bci_PRIMCALL: + debugBelch("PRIMCALL\n"); + break; case bci_STKCHECK: { StgWord stk_words_reqd = BCO_GET_LARGE_ARG + 1; debugBelch("STKCHECK %" FMT_Word "\n", (W_)stk_words_reqd ); ===================================== rts/Interpreter.c ===================================== @@ -2038,6 +2038,12 @@ run_BCO: goto nextInsn; } + case bci_PRIMCALL: { + Sp_subW(1); + SpW(0) = (W_)&stg_primcall_info; + RETURN_TO_SCHEDULER_NO_PAUSE(ThreadRunGHC, ThreadYielding); + } + case bci_CCALL: { void *tok; int stk_offset = BCO_NEXT; ===================================== rts/RtsSymbols.c ===================================== @@ -602,6 +602,7 @@ extern char **environ; SymI_HasDataProto(stg_ret_l_info) \ SymI_HasDataProto(stg_ret_t_info) \ SymI_HasDataProto(stg_ctoi_t) \ + SymI_HasDataProto(stg_primcall_info) \ SymI_HasDataProto(stg_gc_prim_p) \ SymI_HasDataProto(stg_gc_prim_pp) \ SymI_HasDataProto(stg_gc_prim_n) \ ===================================== rts/StgMiscClosures.cmm ===================================== @@ -366,20 +366,10 @@ MK_STG_CTOI_T(61) MK_STG_CTOI_T(62) /* - Note [GHCi tuple layout] - ~~~~~~~~~~~~~~~~~~~~~~~~ - the tuple_info word describes the register and stack usage of the tuple: + Convert a tuple return value to be used in bytecode. - [ ssss ssss rrrr rrrr rrrr rrrr rrrr rrrr ] - - - r: bitmap of live registers, corresponding to the list of registers - returned by GHC.Cmm.CallConv.tupleRegsCover (the least significant - bit corresponds to the first element in the list) - - s: number of words on stack (in addition to registers) - - The order of the live registers in the bitmap is the same as the list - given by GHC.Cmm.CallConv.tupleRegsCover, with the least significant - bit corresponding to the first register in the list. + See Note [GHCi and native call registers] for information on how + values are moved between the stack and registers. */ stg_ctoi_t @@ -402,7 +392,7 @@ stg_ctoi_t Sp = Sp - WDS(tuple_stack); - PUSH_TUPLE_REGS(tuple_info); + PUSH_ARG_REGS(tuple_info); /* jump to the BCO that will finish the return of the tuple */ Sp_adj(-3); @@ -423,13 +413,57 @@ INFO_TABLE_RET( stg_ret_t, RET_BCO ) /* number of words spilled on stack */ tuple_stack = (tuple_info >> 24) & 0xff; - POP_TUPLE_REGS(tuple_info); + POP_ARG_REGS(tuple_info); /* Sp points to the topmost argument now */ jump %ENTRY_CODE(Sp(tuple_stack)) [*]; // NB. all registers live! } + /* + + The stg_primcall frame is used by the bytecode interpreter to call + a Cmm function. The frame contains a call_info word that contains + a bitmap describing the register arguments. + + When the target function is called, Sp points to the topmost stack + argument. + + ... + next_stack_frame + arg_1 + arg_2 + ... + arg_n + target_funptr (pointer to the function we're calling) + call_info (describes the registers containing the arguments) + primcall_BCO (contains bitmap describing pointers in args) + stg_primcall_info <- Sp + + See Note [GHCi and native call registers] for information on the call_info + word and how registers are moved between the stack and registers. + + */ + +INFO_TABLE_RET ( stg_primcall, RET_BCO ) +{ + W_ args_info, prim_fun; + + /* Sp(1) would be the BCO containing the stack description bitmap */ + args_info = Sp(2); + prim_fun = Sp(3); + + Sp_adj(4); + + /* Sp points to the top of the register arguments now, + load them into actual registers */ + POP_ARG_REGS(args_info); + + /* Sp points to the topmost stack argument now */ + + jump prim_fun [*]; // NB. all registers live! +} + /* * Dummy info table pushed on the top of the stack when the interpreter * should apply the BCO on the stack to its arguments, also on the ===================================== rts/include/rts/Bytecodes.h ===================================== @@ -112,6 +112,8 @@ #define bci_TESTLT_W8 85 #define bci_TESTEQ_W8 86 +#define bci_PRIMCALL 87 + /* If you need to go past 255 then you will run into the flags */ /* If you need to go below 0x0100 then you will run into the instructions */ ===================================== rts/include/stg/MiscClosures.h ===================================== @@ -160,6 +160,7 @@ RTS_RET(stg_ctoi_t60); RTS_RET(stg_ctoi_t61); RTS_RET(stg_ctoi_t62); +RTS_RET(stg_primcall); RTS_RET(stg_apply_interp); RTS_RET(stg_dead_thread); ===================================== testsuite/tests/ghci/prog014/prog014.T ===================================== @@ -1,6 +1,5 @@ test('prog014', [extra_files(['Primop.hs', 'dummy.c']), - expect_fail, # bytecode compiler doesn't support foreign import prim extra_run_opts('dummy.o'), pre_cmd('$MAKE -s --no-print-directory prog014')], ghci_script, ['prog014.script']) ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs ===================================== @@ -0,0 +1,224 @@ +{-# LANGUAGE ForeignFunctionInterface, GHCForeignImportPrim, UnliftedFFITypes, MagicHash, UnboxedTuples #-} + +module Main where + +import GHC.Int +import GHC.Word +import GHC.Prim +import GHC.Exts +import GHC.Types +import Unsafe.Coerce +import GHC.IO + +data Box (a :: UnliftedType) = MkBox a + +i2a :: Int -> Any +i2a = unsafeCoerce + +a2i :: Any -> Int +a2i = unsafeCoerce + +main :: IO () +main = do + + let i8s :: [Int8] + i8s = [0, -1, 1, minBound, maxBound] + + i16s :: [Int16] + i16s = [0, -1, 1, minBound, maxBound] + + i32s :: [Int32] + i32s = [0, -1, 1, minBound, maxBound] + + i64s :: [Int64] + i64s = [0, -1, 1, minBound, maxBound] + + ws :: [Word] + ws = [0, 1, 2, maxBound] + + fs :: [Float] + fs = [-0, 0, -1, 1, -2, 2, 1/0, 1e37, -1e-37] + + ds :: [Double] + ds = [-0, 0, -1, 1, -2, 2, 1/0, 1e307, -1e-307] + + ls :: [Word64] + ls = [0, 1, 2, 4294967296, maxBound] + + mi2a :: Maybe Integer -> Any + mi2a = unsafeCoerce + + a2mi :: Any -> Maybe Integer + a2mi = unsafeCoerce + + a0, a1, a2, a3 :: Any + a0 = mi2a Nothing + a1 = mi2a (Just 1) + a2 = mi2a (Just 18446744073709551617) + a3 = mi2a (Just (-18446744073709551617)) + + as :: [Any] + as = [a0, a1, a2, a3] + + + putStrLn "zero arguments" + IO (\st -> case cmm_zero st of (# st' #) -> (# st', () #)) + print =<< IO (\st -> case cmm_zero_w st of (# st', w #) -> (# st', W# w #)) + print =<< IO (\st -> case cmm_zero_d st of (# st', w #) -> (# st', D# w #)) + print =<< IO (\st -> case cmm_zero_f st of (# st', w #) -> (# st', F# w #)) + + -- XXX zero argument functions + + putStrLn "one argument functions" + print [ I8# (cmm_one1_i8 x) | (I8# x) <- i8s ] + print [ I16# (cmm_one1_i16 x) | (I16# x) <- i16s ] + print [ I32# (cmm_one1_i32 x) | (I32# x) <- i32s ] + print [ I64# (cmm_one1_i64 x) | (I64# x) <- i64s ] + print [ case cmm_one1_p x of (# y #) -> a2mi y | x <- as ] + print [ W# (cmm_one1_w x) | (W# x) <- ws ] + print [ F# (cmm_one1_f x) | (F# x) <- fs ] + print [ D# (cmm_one1_d x) | (D# x) <- ds ] + print [ W64# (cmm_one1_l x) | (W64# x) <- ls ] + + print [ case cmm_one2_i8 x of (# y1, y2 #) -> (I8# y1, I8# y2) | (I8# x) <- i8s ] + print [ case cmm_one2_i16 x of (# y1, y2 #) -> (I16# y1, I16# y2) | (I16# x) <- i16s ] + print [ case cmm_one2_i32 x of (# y1, y2 #) -> (I32# y1, I32# y2) | (I32# x) <- i32s ] + print [ case cmm_one2_i64 x of (# y1, y2 #) -> (I64# y1, I64# y2) | (I64# x) <- i64s ] + print [ case cmm_one2_p x of (# y1, y2 #) -> (a2mi y1, a2mi y2) | x <- as ] + print [ case cmm_one2_w x of (# y1, y2 #) -> (W# y1, W# y2) | (W# x) <- ws ] + print [ case cmm_one2_f x of (# y1, y2 #) -> (F# y1, F# y2) | (F# x) <- fs ] + print [ case cmm_one2_d x of (# y1, y2 #) -> (D# y1, D# y2) | (D# x) <- ds ] + print [ case cmm_one2_l x of (# y1, y2 #) -> (W64# y1, W64# y2) | (W64# x) <- ls ] + + putStrLn "two argument functions" + print [ I8# (cmm_two1_i8 x1 x2) | (I8# x1) <- i8s, (I8# x2) <- i8s ] + print [ I16# (cmm_two1_i16 x1 x2) | (I16# x1) <- i16s, (I16# x2) <- i16s ] + print [ I32# (cmm_two1_i32 x1 x2) | (I32# x1) <- i32s, (I32# x2) <- i32s ] + print [ I64# (cmm_two1_i64 x1 x2) | (I64# x1) <- i64s, (I64# x2) <- i64s ] + print [ case cmm_two1_p x1 x2 of (# y #) -> a2mi y | x1 <- as, x2 <- as ] + print [ W# (cmm_two1_w x1 x2) | (W# x1) <- ws, (W# x2) <- ws ] + print [ F# (cmm_two1_f x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_two1_d x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ W64# (cmm_two1_l x1 x2) | (W64# x1) <- ls, (W64# x2) <- ls ] + + print [ I8# (cmm_two2_i8 x1 x2) | (I8# x1) <- i8s, (I8# x2) <- i8s ] + print [ I16# (cmm_two2_i16 x1 x2) | (I16# x1) <- i16s, (I16# x2) <- i16s ] + print [ I32# (cmm_two2_i32 x1 x2) | (I32# x1) <- i32s, (I32# x2) <- i32s ] + print [ I64# (cmm_two2_i64 x1 x2) | (I64# x1) <- i64s, (I64# x2) <- i64s ] + print [ case cmm_two2_p x1 x2 of (# y #) -> a2mi y | x1 <- as, x2 <- as ] + print [ W# (cmm_two2_w x1 x2) | (W# x1) <- ws, (W# x2) <- ws ] + print [ F# (cmm_two2_f x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_two2_d x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ W64# (cmm_two2_l x1 x2) | (W64# x1) <- ls, (W64# x2) <- ls ] + + putStrLn "additional floating point tests" + print [ F# (cmm_floating_1 x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_floating_2 x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ F# (cmm_floating_3 x1 x2) | (F# x1) <- fs, (D# x2) <- ds ] + print [ D# (cmm_floating_4 x1 x2) | (F# x1) <- fs, (D# x2) <- ds ] + print [ case cmm_floating_5 x1 x2 3.0e1# 4.0e2## 5.0e3# 6.0e4## 7.0e5# 8.0e6## of (# y1, y2 #) -> (F# y1, D# y2) + | (F# x1) <- fs, (D# x2) <- ds ] + print [ case cmm_floating_6 x1 x2 3.0e1## 4.0e2# 5.0e3## 6.0e4# 7.0e5## 8.0e6# of (# y1, y2 #) -> (D# y1, F# y2) + | (D# x1) <- ds, (F# x2) <- fs ] + print [ case cmm_floating_7 w1 x1 x2 + 4## 5.0e1# 6.0e2## + 7## 8.0e3# 9.0e4## + 10## 11.0e5# 12.0e6## + 13## 14.0e7# 15.0e8## + 16## 17.0e9# 18.0e10## + 19## 20.0e11# 21.0e12## of (# y1, y2, y3 #) -> (W# y1, F# y2, D# y3) + | (W# w1) <- ws, (F# x1) <- fs, (D# x2) <- ds ] + + putStrLn "various sized tuple returns" + print [ case cmm_tuple_1 x1 x2 3## of (# y1, y2, y3 #) -> (W# y1, W# y2, W# y3) | (W# x1) <- ws, (W# x2) <- ws] + print [ case cmm_tuple_2 x1 x2 3## 4## a0 a1 7.0## 8.0## a2 a3 11.0# 12.0# + of (# y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12 #) -> + (F# y1, F# y2, a2mi y3, a2mi y4, D# y5, D# y6, a2mi y7, a2mi y8, W# y9, W# y10, a2mi y11, a2mi y12) + | x1 <- as, x2 <- as ] + print [ case cmm_tuple_3 x1 x2 a0 3.0## a1 5.0# + of (# y1, y2, y3, y4, y5, y6 #) -> (F# y1, a2mi y2, D# y3, a2mi y4, W# y5, a2mi y6) + | x1 <- as, (W# x2) <- ws ] + print [ case cmm_tuple_4 x1 x2 of (# y1, y2 #) -> (a2mi y1, a2mi y2) | x1 <- as, x2 <- as ] + + putStrLn "arrays" + MkBox marr0 <- IO (\s -> case newArray# 10# a0 s of (# s', a #) -> (# s', MkBox a #)) + MkBox marr1 <- IO (\s -> case newArray# 12# a1 s of (# s', a #) -> (# s', MkBox a #)) + MkBox arr0 <- IO (\s -> case unsafeFreezeArray# marr0 s of (# s', a #) -> (# s', MkBox a #)) + MkBox arr1 <- IO (\s -> case unsafeFreezeArray# marr1 s of (# s', a #) -> (# s', MkBox a #)) + print (I# (cmm_array_1 arr0), I# (cmm_array_1 arr1)) + case cmm_array_2 arr0 arr1 of (# arr2, arr3 #) -> print (I# (cmm_array_1 arr2), I# (cmm_array_1 arr3)) + + +-- XXX why don't we accept State# RealWorld -> State# RealWorld ? +foreign import prim cmm_zero :: State# RealWorld -> (# State# RealWorld #) +foreign import prim cmm_zero_w :: State# RealWorld -> (# State# RealWorld, Word# #) +foreign import prim cmm_zero_d :: State# RealWorld -> (# State# RealWorld, Double# #) +foreign import prim cmm_zero_f :: State# RealWorld -> (# State# RealWorld, Float# #) + +-- one argument functions +foreign import prim cmm_one1_i8 :: Int8# -> Int8# +foreign import prim cmm_one1_i16 :: Int16# -> Int16# +foreign import prim cmm_one1_i32 :: Int32# -> Int32# +foreign import prim cmm_one1_i64 :: Int64# -> Int64# +foreign import prim cmm_one1_p :: Any -> (# Any #) +foreign import prim cmm_one1_w :: Word# -> Word# +foreign import prim cmm_one1_f :: Float# -> Float# +foreign import prim cmm_one1_d :: Double# -> Double# +foreign import prim cmm_one1_l :: Word64# -> Word64# + +foreign import prim cmm_one2_i8 :: Int8# -> (# Int8#, Int8# #) +foreign import prim cmm_one2_i16 :: Int16# -> (# Int16#, Int16# #) +foreign import prim cmm_one2_i32 :: Int32# -> (# Int32#, Int32# #) +foreign import prim cmm_one2_i64 :: Int64# -> (# Int64#, Int64# #) +foreign import prim cmm_one2_p :: Any -> (# Any, Any #) +foreign import prim cmm_one2_w :: Word# -> (# Word#, Word# #) +foreign import prim cmm_one2_f :: Float# -> (# Float#, Float# #) +foreign import prim cmm_one2_d :: Double# -> (# Double#, Double# #) +foreign import prim cmm_one2_l :: Word64# -> (# Word64#, Word64# #) + +-- two argument functions +foreign import prim cmm_two1_i8 :: Int8# -> Int8# -> Int8# +foreign import prim cmm_two1_i16 :: Int16# -> Int16# -> Int16# +foreign import prim cmm_two1_i32 :: Int32# -> Int32# -> Int32# +foreign import prim cmm_two1_i64 :: Int64# -> Int64# -> Int64# +foreign import prim cmm_two1_p :: Any -> Any -> (# Any #) +foreign import prim cmm_two1_w :: Word# -> Word# -> Word# +foreign import prim cmm_two1_f :: Float# -> Float# -> Float# +foreign import prim cmm_two1_d :: Double# -> Double# -> Double# +foreign import prim cmm_two1_l :: Word64# -> Word64# -> Word64# + +foreign import prim cmm_two2_i8 :: Int8# -> Int8# -> Int8# +foreign import prim cmm_two2_i16 :: Int16# -> Int16# -> Int16# +foreign import prim cmm_two2_i32 :: Int32# -> Int32# -> Int32# +foreign import prim cmm_two2_i64 :: Int64# -> Int64# -> Int64# +foreign import prim cmm_two2_p :: Any -> Any -> (# Any #) +foreign import prim cmm_two2_w :: Word# -> Word# -> Word# +foreign import prim cmm_two2_f :: Float# -> Float# -> Float# +foreign import prim cmm_two2_d :: Double# -> Double# -> Double# +foreign import prim cmm_two2_l :: Word64# -> Word64# -> Word64# + +{- additional tests for floating point, since D_ and F_ registers + overlap on some platforms -} + +foreign import prim cmm_floating_1 :: Float# -> Float# -> Float# +foreign import prim cmm_floating_2 :: Double# -> Double# -> Double# +foreign import prim cmm_floating_3 :: Float# -> Double# -> Float# +foreign import prim cmm_floating_4 :: Float# -> Double# -> Double# +foreign import prim cmm_floating_5 :: Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> (# Float#, Double# #) +foreign import prim cmm_floating_6 :: Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> (# Double#, Float# #) +foreign import prim cmm_floating_7 :: Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> (# Word#, Float#, Double# #) +-- various sized tuple returns + +foreign import prim cmm_tuple_1 :: Word# -> Word# -> Word# -> (# Word# , Word#, Word# #) +foreign import prim cmm_tuple_2 :: Any -> Any -> Word# -> Word# -> Any -> Any -> Double# -> Double# -> Any -> Any -> Float# -> Float# -> + (# Float#, Float#, Any, Any, Double#, Double#, Any, Any, Word#, Word#, Any, Any #) +foreign import prim cmm_tuple_3 :: Any -> Word# -> Any -> Double# -> Any -> Float# -> + (# Float#, Any, Double#, Any, Word#, Any #) +foreign import prim cmm_tuple_4 :: Any -> Any -> (# Any, Any #) + +-- boxed primitive types + +-- get the length of an array +foreign import prim cmm_array_1 :: Array# Any -> Int# +-- return some arrays +foreign import prim cmm_array_2 :: Array# Any -> Array# Any -> (# Array# Any, Array# Any #) ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout ===================================== @@ -0,0 +1,58 @@ +zero arguments +123 +1.0 +1.0 +one argument functions +[0,-1,1,-128,127] +[0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,18446744073709551615] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615] +[(0,0),(-1,-1),(1,1),(-128,-128),(127,127)] +[(0,0),(-1,-1),(1,1),(-32768,-32768),(32767,32767)] +[(0,0),(-1,-1),(1,1),(-2147483648,-2147483648),(2147483647,2147483647)] +[(0,0),(-1,-1),(1,1),(-9223372036854775808,-9223372036854775808),(9223372036854775807,9223372036854775807)] +[(Nothing,Nothing),(Just 1,Just 1),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just (-18446744073709551617))] +[(0,0),(1,1),(2,2),(18446744073709551615,18446744073709551615)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e37,1.0e37),(-1.0e-37,-1.0e-37)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e307,1.0e307),(-1.0e-307,-1.0e-307)] +[(0,0),(1,1),(2,2),(4294967296,4294967296),(18446744073709551615,18446744073709551615)] +two argument functions +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-128,-128,-128,-128,-128,127,127,127,127,127] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-32768,-32768,-32768,-32768,-32768,32767,32767,32767,32767,32767] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,2147483647,2147483647,2147483647,2147483647,2147483647] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807] +[Nothing,Nothing,Nothing,Nothing,Just 1,Just 1,Just 1,Just 1,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617)] +[0,0,0,0,1,1,1,1,2,2,2,2,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307] +[0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,4294967296,4294967296,4294967296,4294967296,4294967296,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127] +[0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,18446744073709551615,0,1,2,18446744073709551615,0,1,2,18446744073709551615,0,1,2,18446744073709551615] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615] +additional floating point tests +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e37,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e37,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e37,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e37,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,Infinity,2.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-2.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e307,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e307,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e307,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e307,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,Infinity,2.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-2.0e-307] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e307),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e307),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e307),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e307),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e307),(Infinity,8060400.0),(1.0e37,8060400.0),(1.0e37,8060400.0),(1.0e37,8060399.0),(1.0e37,8060401.0),(1.0e37,8060398.0),(1.0e37,8060402.0),(1.0e37,Infinity),(1.0e37,1.0e307),(1.0e37,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0)] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e37),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e37),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e37),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e37),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e37),(Infinity,8060400.0),(1.0e307,8060400.0),(1.0e307,8060400.0),(1.0e307,8060399.0),(1.0e307,8060401.0),(1.0e307,8060398.0),(1.0e307,8060402.0),(1.0e307,Infinity),(1.0e307,1.0e37),(1.0e307,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0)] +[(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.1181512090599e13),(69,Infinity,2.1181512090601e13),(69,Infinity,2.1181512090598e13),(69,Infinity,2.1181512090602e13),(69,Infinity,Infinity),(69,Infinity,1.0e307),(69,Infinity,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.1181512090599e13),(69,1.0e37,2.1181512090601e13),(69,1.0e37,2.1181512090598e13),(69,1.0e37,2.1181512090602e13),(69,1.0e37,Infinity),(69,1.0e37,1.0e307),(69,1.0e37,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.1181512090599e13),(70,Infinity,2.1181512090601e13),(70,Infinity,2.1181512090598e13),(70,Infinity,2.1181512090602e13),(70,Infinity,Infinity),(70,Infinity,1.0e307),(70,Infinity,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.1181512090599e13),(70,1.0e37,2.1181512090601e13),(70,1.0e37,2.1181512090598e13),(70,1.0e37,2.1181512090602e13),(70,1.0e37,Infinity),(70,1.0e37,1.0e307),(70,1.0e37,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.1181512090599e13),(71,Infinity,2.1181512090601e13),(71,Infinity,2.1181512090598e13),(71,Infinity,2.1181512090602e13),(71,Infinity,Infinity),(71,Infinity,1.0e307),(71,Infinity,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.1181512090599e13),(71,1.0e37,2.1181512090601e13),(71,1.0e37,2.1181512090598e13),(71,1.0e37,2.1181512090602e13),(71,1.0e37,Infinity),(71,1.0e37,1.0e307),(71,1.0e37,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.1181512090599e13),(68,Infinity,2.1181512090601e13),(68,Infinity,2.1181512090598e13),(68,Infinity,2.1181512090602e13),(68,Infinity,Infinity),(68,Infinity,1.0e307),(68,Infinity,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.1181512090599e13),(68,1.0e37,2.1181512090601e13),(68,1.0e37,2.1181512090598e13),(68,1.0e37,2.1181512090602e13),(68,1.0e37,Infinity),(68,1.0e37,1.0e307),(68,1.0e37,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13)] +various sized tuple returns +[(3,0,0),(3,1,0),(3,2,0),(3,18446744073709551615,0),(3,0,1),(3,1,1),(3,2,1),(3,18446744073709551615,1),(3,0,2),(3,1,2),(3,2,2),(3,18446744073709551615,2),(3,0,18446744073709551615),(3,1,18446744073709551615),(3,2,18446744073709551615),(3,18446744073709551615,18446744073709551615)] +[(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just (-18446744073709551617))] +[(5.0,Just 1,3.0,Nothing,0,Nothing),(5.0,Just 1,3.0,Nothing,1,Nothing),(5.0,Just 1,3.0,Nothing,2,Nothing),(5.0,Just 1,3.0,Nothing,18446744073709551615,Nothing),(5.0,Just 1,3.0,Nothing,0,Just 1),(5.0,Just 1,3.0,Nothing,1,Just 1),(5.0,Just 1,3.0,Nothing,2,Just 1),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just 1),(5.0,Just 1,3.0,Nothing,0,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,1,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,2,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,0,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,1,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,2,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just (-18446744073709551617))] +[(Nothing,Nothing),(Just 1,Nothing),(Just 18446744073709551617,Nothing),(Just (-18446744073709551617),Nothing),(Nothing,Just 1),(Just 1,Just 1),(Just 18446744073709551617,Just 1),(Just (-18446744073709551617),Just 1),(Nothing,Just 18446744073709551617),(Just 1,Just 18446744073709551617),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just 18446744073709551617),(Nothing,Just (-18446744073709551617)),(Just 1,Just (-18446744073709551617)),(Just 18446744073709551617,Just (-18446744073709551617)),(Just (-18446744073709551617),Just (-18446744073709551617))] +arrays +(11,13) +(13,11) ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout-ws-32 ===================================== @@ -0,0 +1,58 @@ +zero arguments +123 +1.0 +1.0 +one argument functions +[0,-1,1,-128,127] +[0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,4294967295] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615] +[(0,0),(-1,-1),(1,1),(-128,-128),(127,127)] +[(0,0),(-1,-1),(1,1),(-32768,-32768),(32767,32767)] +[(0,0),(-1,-1),(1,1),(-2147483648,-2147483648),(2147483647,2147483647)] +[(0,0),(-1,-1),(1,1),(-9223372036854775808,-9223372036854775808),(9223372036854775807,9223372036854775807)] +[(Nothing,Nothing),(Just 1,Just 1),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just (-18446744073709551617))] +[(0,0),(1,1),(2,2),(4294967295,4294967295)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e37,1.0e37),(-1.0e-37,-1.0e-37)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e307,1.0e307),(-1.0e-307,-1.0e-307)] +[(0,0),(1,1),(2,2),(4294967296,4294967296),(18446744073709551615,18446744073709551615)] +two argument functions +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-128,-128,-128,-128,-128,127,127,127,127,127] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-32768,-32768,-32768,-32768,-32768,32767,32767,32767,32767,32767] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,2147483647,2147483647,2147483647,2147483647,2147483647] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807] +[Nothing,Nothing,Nothing,Nothing,Just 1,Just 1,Just 1,Just 1,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617)] +[0,0,0,0,1,1,1,1,2,2,2,2,4294967295,4294967295,4294967295,4294967295] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307] +[0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,4294967296,4294967296,4294967296,4294967296,4294967296,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127] +[0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,4294967295,0,1,2,4294967295,0,1,2,4294967295,0,1,2,4294967295] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615] +additional floating point tests +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e37,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e37,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e37,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e37,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,Infinity,2.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-2.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e307,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e307,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e307,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e307,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,Infinity,2.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-2.0e-307] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e307),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e307),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e307),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e307),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e307),(Infinity,8060400.0),(1.0e37,8060400.0),(1.0e37,8060400.0),(1.0e37,8060399.0),(1.0e37,8060401.0),(1.0e37,8060398.0),(1.0e37,8060402.0),(1.0e37,Infinity),(1.0e37,1.0e307),(1.0e37,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0)] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e37),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e37),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e37),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e37),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e37),(Infinity,8060400.0),(1.0e307,8060400.0),(1.0e307,8060400.0),(1.0e307,8060399.0),(1.0e307,8060401.0),(1.0e307,8060398.0),(1.0e307,8060402.0),(1.0e307,Infinity),(1.0e307,1.0e37),(1.0e307,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0)] +[(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.1181512090599e13),(69,Infinity,2.1181512090601e13),(69,Infinity,2.1181512090598e13),(69,Infinity,2.1181512090602e13),(69,Infinity,Infinity),(69,Infinity,1.0e307),(69,Infinity,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.1181512090599e13),(69,1.0e37,2.1181512090601e13),(69,1.0e37,2.1181512090598e13),(69,1.0e37,2.1181512090602e13),(69,1.0e37,Infinity),(69,1.0e37,1.0e307),(69,1.0e37,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.1181512090599e13),(70,Infinity,2.1181512090601e13),(70,Infinity,2.1181512090598e13),(70,Infinity,2.1181512090602e13),(70,Infinity,Infinity),(70,Infinity,1.0e307),(70,Infinity,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.1181512090599e13),(70,1.0e37,2.1181512090601e13),(70,1.0e37,2.1181512090598e13),(70,1.0e37,2.1181512090602e13),(70,1.0e37,Infinity),(70,1.0e37,1.0e307),(70,1.0e37,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.1181512090599e13),(71,Infinity,2.1181512090601e13),(71,Infinity,2.1181512090598e13),(71,Infinity,2.1181512090602e13),(71,Infinity,Infinity),(71,Infinity,1.0e307),(71,Infinity,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.1181512090599e13),(71,1.0e37,2.1181512090601e13),(71,1.0e37,2.1181512090598e13),(71,1.0e37,2.1181512090602e13),(71,1.0e37,Infinity),(71,1.0e37,1.0e307),(71,1.0e37,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.1181512090599e13),(68,Infinity,2.1181512090601e13),(68,Infinity,2.1181512090598e13),(68,Infinity,2.1181512090602e13),(68,Infinity,Infinity),(68,Infinity,1.0e307),(68,Infinity,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.1181512090599e13),(68,1.0e37,2.1181512090601e13),(68,1.0e37,2.1181512090598e13),(68,1.0e37,2.1181512090602e13),(68,1.0e37,Infinity),(68,1.0e37,1.0e307),(68,1.0e37,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13)] +various sized tuple returns +[(3,0,0),(3,1,0),(3,2,0),(3,4294967295,0),(3,0,1),(3,1,1),(3,2,1),(3,4294967295,1),(3,0,2),(3,1,2),(3,2,2),(3,4294967295,2),(3,0,4294967295),(3,1,4294967295),(3,2,4294967295),(3,4294967295,4294967295)] +[(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just (-18446744073709551617))] +[(5.0,Just 1,3.0,Nothing,0,Nothing),(5.0,Just 1,3.0,Nothing,1,Nothing),(5.0,Just 1,3.0,Nothing,2,Nothing),(5.0,Just 1,3.0,Nothing,4294967295,Nothing),(5.0,Just 1,3.0,Nothing,0,Just 1),(5.0,Just 1,3.0,Nothing,1,Just 1),(5.0,Just 1,3.0,Nothing,2,Just 1),(5.0,Just 1,3.0,Nothing,4294967295,Just 1),(5.0,Just 1,3.0,Nothing,0,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,1,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,2,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,4294967295,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,0,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,1,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,2,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,4294967295,Just (-18446744073709551617))] +[(Nothing,Nothing),(Just 1,Nothing),(Just 18446744073709551617,Nothing),(Just (-18446744073709551617),Nothing),(Nothing,Just 1),(Just 1,Just 1),(Just 18446744073709551617,Just 1),(Just (-18446744073709551617),Just 1),(Nothing,Just 18446744073709551617),(Just 1,Just 18446744073709551617),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just 18446744073709551617),(Nothing,Just (-18446744073709551617)),(Just 1,Just (-18446744073709551617)),(Just 18446744073709551617,Just (-18446744073709551617)),(Just (-18446744073709551617),Just (-18446744073709551617))] +arrays +(11,13) +(13,11) ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm ===================================== @@ -0,0 +1,145 @@ +#include "Cmm.h" + +/* zero arguments */ +cmm_zero() { /* ccall puts("cmm_zero"); buffering gets in the way */ return (); } +cmm_zero_w() { return (123::W_); } +cmm_zero_d() { return (1.0::D_); } +cmm_zero_f() { return (1.0::F_); } +cmm_zero_l() { return (123::L_); } + +/* one argument functions */ +cmm_one1_i8(I8 x) { return (x); } +cmm_one1_i16(I16 x) { return (x); } +cmm_one1_i32(I32 x) { return (x); } +cmm_one1_i64(I64 x) { return (x); } +cmm_one1_p(P_ x) { return (x); } +cmm_one1_w(W_ x) { return (x); } +cmm_one1_f(F_ x) { return (x); } +cmm_one1_d(D_ x) { return (x); } +cmm_one1_l(L_ x) { return (x); } + +cmm_one2_i8(I8 x) { return (x,x); } +cmm_one2_i16(I16 x) { return (x,x); } +cmm_one2_i32(I32 x) { return (x,x); } +cmm_one2_i64(I64 x) { return (x,x); } +cmm_one2_p(P_ x) { return (x,x); } +cmm_one2_w(W_ x) { return (x,x); } +cmm_one2_f(F_ x) { return (x,x); } +cmm_one2_d(D_ x) { return (x,x); } +cmm_one2_l(L_ x) { return (x,x); } + + +/* two argument functions */ +cmm_two1_i8(I8 x, I8 y) { return (x); } +cmm_two1_i16(I16 x, I16 y) { return (x); } +cmm_two1_i32(I32 x, I32 y) { return (x); } +cmm_two1_i64(I64 x, I64 y) { return (x); } +cmm_two1_p(P_ x, P_ y) { return (x); } +cmm_two1_w(W_ x, W_ y) { return (x); } +cmm_two1_f(F_ x, F_ y) { return (x); } +cmm_two1_d(D_ x, D_ y) { return (x); } +cmm_two1_l(L_ x, L_ y) { return (x); } + +cmm_two2_i8(I8 x, I8 y) { return (y); } +cmm_two2_i16(I16 x, I16 y) { return (y); } +cmm_two2_i32(I32 x, I32 y) { return (y); } +cmm_two2_i64(I64 x, I64 y) { return (y); } +cmm_two2_p(P_ x, P_ y) { return (y); } +cmm_two2_w(W_ x, W_ y) { return (y); } +cmm_two2_f(F_ x, F_ y) { return (y); } +cmm_two2_d(D_ x, D_ y) { return (y); } +cmm_two2_l(L_ x, L_ y) { return (y); } + +/* additional tests for floating point, since D_ and F_ registers + overlap on some platforms */ +cmm_floating_1(F_ x, F_ y) { F_ z; z = %fadd(x, y); return (z); } +cmm_floating_2(D_ x, D_ y) { D_ z; z = %fadd(x, y); return (z); } +cmm_floating_3(F_ x, D_ y) { return (x); } +cmm_floating_4(F_ x, D_ y) { return (y); } + + +cmm_floating_5(F_ x1, D_ x2, F_ x3, D_ x4, F_ x5, D_ x6, F_ x7, D_ x8) { + F_ y1; + D_ y2; + + y1 = %fadd(x1,x3); + y1 = %fadd(y1,x5); + y1 = %fadd(y1,x7); + + y2 = %fadd(x2,x4); + y2 = %fadd(y2,x6); + y2 = %fadd(y2,x8); + + return (y1, y2); +} + + +cmm_floating_6(D_ x1, F_ x2, D_ x3, F_ x4, D_ x5, F_ x6, D_ x7, F_ x8) { + D_ y1; + F_ y2; + + y1 = %fadd(x1,x3); + y1 = %fadd(y1,x5); + y1 = %fadd(y1,x7); + + y2 = %fadd(x2,x4); + y2 = %fadd(y2,x6); + y2 = %fadd(y2,x8); + + return (y1, y2); +} + + +cmm_floating_7( W_ x1, F_ x2, D_ x3 + , W_ x4, F_ x5, D_ x6 + , W_ x7, F_ x8, D_ x9 + , W_ x10, F_ x11, D_ x12 + , W_ x13, F_ x14, D_ x15 + , W_ x16, F_ x17, D_ x18 + , W_ x19, F_ x20, D_ x21 + ) { + W_ y1; + F_ y2; + D_ y3; + y1 = x1+x4+x7+x10+x13+x16+x19; + + y2 = %fadd(x2,x5); + y2 = %fadd(y2,x8); + y2 = %fadd(y2,x11); + y2 = %fadd(y2,x14); + y2 = %fadd(y2,x17); + y2 = %fadd(y2,x20); + + y3 = %fadd(x3,x6); + y3 = %fadd(y3,x9); + y3 = %fadd(y3,x12); + y3 = %fadd(y3,x15); + y3 = %fadd(y3,x18); + y3 = %fadd(y3,x21); + + return ( y1, y2, y3 ); +} + + +/* various sized tuple returns */ + +cmm_tuple_1(W_ x, W_ y, W_ z) { return (z, y, x); } +cmm_tuple_2(P_ p1, P_ p2, W_ w1, W_ w2, P_ p3, P_ p4, D_ d1, D_ d2, P_ p5, P_ p6, F_ f1, F_ f2) { + return (f2, f1, p6, p5, d2, d1, p4, p3, w2, w1, p2, p1); +} +cmm_tuple_3(P_ p1, W_ w1, P_ p2, D_ d1, P_ p3, F_ f1) { + return (f1, p3, d1, p2, w1, p1); +} +cmm_tuple_4(P_ p1, P_ p2) { return (p2, p1); } + +/* working with arrays */ +cmm_array_1(P_ x) { + W_ size; + size = StgMutArrPtrs_size(x); + return (size); +} + +/* return two arrays */ +cmm_array_2(P_ x, P_ y) { + return (y, x); +} ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile ===================================== @@ -0,0 +1,4 @@ +.PHONY: GHCiPrimCall +GHCiPrimCall: + '$(TEST_HC)' $(TEST_HC_OPTS) -fPIC -v0 -c GHCiPrimCall_cmm.cmm + -'$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -e main GHCiPrimCall.hs GHCiPrimCall_cmm.o || echo $$? >&2 ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/all.T ===================================== @@ -0,0 +1,2 @@ +test('GHCiPrimCall', [req_interp], makefile_test, ['GHCiPrimCall']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/992606f2051629f53b6ab81163ed03dc3599b935 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/992606f2051629f53b6ab81163ed03dc3599b935 You're receiving 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 Jan 9 10:54:04 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 09 Jan 2023 05:54:04 -0500 Subject: [Git][ghc/ghc][wip/no_fixup_chains_2] 2 commits: Store bootstrap_llvm_target and use it to set LlvmTarget in bindists Message-ID: <63bbf24cf40dc_136d981dc91ce8293795@gitlab.mail> Matthew Pickering pushed to branch wip/no_fixup_chains_2 at Glasgow Haskell Compiler / GHC Commits: 5ad22a80 by Matthew Pickering at 2023-01-09T10:44:48+00:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 5f53e30a by Matthew Pickering at 2023-01-09T10:50:37+00:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. - - - - - 3 changed files: - configure.ac - distrib/configure.ac.in - m4/ghc_llvm_target.m4 Changes: ===================================== configure.ac ===================================== @@ -667,6 +667,8 @@ GHC_LLVM_TARGET_SET_VAR # we intend to pass trough --targets to llvm as is. LLVMTarget_CPP=` echo "$LlvmTarget"` AC_SUBST(LLVMTarget_CPP) +# The target is substituted into the distrib/configure.ac file +AC_SUBST(LlvmTarget) dnl ** See whether cc supports --target= and set dnl CONF_CC_OPTS_STAGE[012] accordingly. ===================================== distrib/configure.ac.in ===================================== @@ -18,6 +18,8 @@ dnl-------------------------------------------------------------------- dnl Various things from the source distribution configure bootstrap_target=@TargetPlatform@ +bootstrap_llvm_target=@LlvmTarget@ + TargetHasRTSLinker=@TargetHasRTSLinker@ AC_SUBST(TargetHasRTSLinker) @@ -169,6 +171,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG # Stage 3 won't be supported by cross-compilation FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) +FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) +FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + AC_SUBST(CONF_CC_OPTS_STAGE0) AC_SUBST(CONF_CC_OPTS_STAGE1) AC_SUBST(CONF_CC_OPTS_STAGE2) ===================================== m4/ghc_llvm_target.m4 ===================================== @@ -50,5 +50,10 @@ AC_DEFUN([GHC_LLVM_TARGET], [ # require it. AC_DEFUN([GHC_LLVM_TARGET_SET_VAR], [ AC_REQUIRE([FPTOOLS_SET_PLATFORMS_VARS]) - GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + if test "$bootstrap_llvm_target" != "" + then + $5=$bootstrap_llvm_target + else + GHC_LLVM_TARGET([$target],[$TargetArch],[$TargetVendor],[$TargetOS],[LlvmTarget]) + fi ]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/81d2e4c6aef5b8bf250f7ff07f3e18a1421798c3...5f53e30aa55f6414e2494165d1b368b02a09e5bc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/81d2e4c6aef5b8bf250f7ff07f3e18a1421798c3...5f53e30aa55f6414e2494165d1b368b02a09e5bc You're receiving 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 Jan 9 11:03:39 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 09 Jan 2023 06:03:39 -0500 Subject: [Git][ghc/ghc][master] 2 commits: Disable split sections on aarch64-deb10 build Message-ID: <63bbf48becafa_136d98142d6b802995dd@gitlab.mail> Matthew Pickering pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 7 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - + testsuite/tests/printer/HsDocTy.hs - testsuite/tests/printer/Makefile - testsuite/tests/printer/all.T - utils/check-exact/ExactPrint.hs - utils/check-exact/Main.hs Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -813,7 +813,7 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , standardBuilds Amd64 Darwin , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin - , standardBuilds AArch64 (Linux Debian10) + , standardBuildsWithConfig AArch64 (Linux Debian10) (splitSectionsBroken vanilla) , disableValidate (standardBuildsWithConfig AArch64 (Linux Debian10) llvm) , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla) , standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static) ===================================== .gitlab/jobs.yaml ===================================== @@ -1926,7 +1926,7 @@ "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release": { + "release-aarch64-linux-deb10-release+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1936,7 +1936,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release.tar.xz", + "ghc-aarch64-linux-deb10-release+llvm.tar.xz", "junit.xml" ], "reports": { @@ -1978,15 +1978,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", + "BUILD_FLAVOUR": "release+llvm", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release", + "TEST_ENV": "aarch64-linux-deb10-release+llvm", "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release+llvm": { + "release-aarch64-linux-deb10-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1996,7 +1996,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release+llvm.tar.xz", + "ghc-aarch64-linux-deb10-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2038,11 +2038,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", - "BUILD_FLAVOUR": "release+llvm", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release+llvm", + "TEST_ENV": "aarch64-linux-deb10-release+no_split_sections", "XZ_OPT": "-9" } }, ===================================== testsuite/tests/printer/HsDocTy.hs ===================================== @@ -0,0 +1,6 @@ +{-# OPTIONS_GHC -haddock #-} +module HsDocTy where + +class C1 a where + f1 :: a -> Int + -- ^ comment on Int ===================================== testsuite/tests/printer/Makefile ===================================== @@ -769,3 +769,9 @@ Test21355: Test21805: $(CHECK_PPR) $(LIBDIR) Test21805.hs $(CHECK_EXACT) $(LIBDIR) Test21805.hs + +.PHONY: HsDocTy +HsDocTy: + # See comment on pprWithDocString, this won't round trip + # $(CHECK_PPR) $(LIBDIR) HsDocTy.hs + $(CHECK_EXACT) $(LIBDIR) HsDocTy.hs ===================================== testsuite/tests/printer/all.T ===================================== @@ -185,4 +185,5 @@ test('Test21805', [ignore_stderr, req_ppr_deps], makefile_test, ['Test21805']) test('T22488', normal, ghci_script, ['T22488.script']) test('T22488_docHead', normal, compile_and_run, ['-package ghc']) test('T20531', extra_files(['T20531_defs.hs']), ghci_script, ['T20531.script']) -test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) \ No newline at end of file +test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) +test('HsDocTy', [ignore_stderr, req_ppr_deps], makefile_test, ['HsDocTy']) \ No newline at end of file ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -3898,6 +3898,10 @@ instance ExactPrint (HsType GhcPs) where exact (HsSpliceTy a splice) = do splice' <- markAnnotated splice return (HsSpliceTy a splice') + exact (HsDocTy an ty doc) = do + ty' <- markAnnotated ty + doc' <- markAnnotated doc + return (HsDocTy an ty' doc') exact (HsBangTy an (HsSrcBang mt up str) ty) = do an0 <- case mt of ===================================== utils/check-exact/Main.hs ===================================== @@ -59,7 +59,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../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) - "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) + -- "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3a.hs" (Just changeWhereIn3a) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3b.hs" (Just changeWhereIn3b) -- "../../testsuite/tests/ghc-api/exactprint/AddLocalDecl1.hs" (Just addLocaLDecl1) @@ -203,6 +203,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../testsuite/tests/ghc-api/exactprint/Test20239.hs" Nothing -- "../../testsuite/tests/printer/PprArrowLambdaCase.hs" Nothing -- "../../testsuite/tests/printer/Test16279.hs" Nothing + "../../testsuite/tests/printer/HsDocTy.hs" Nothing -- cloneT does not need a test, function can be retired View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8c0ea25fb4a27d4729aabf73f4c00b912bb0c58d...965a273510adfac4f041a31182c2fec82e614e47 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8c0ea25fb4a27d4729aabf73f4c00b912bb0c58d...965a273510adfac4f041a31182c2fec82e614e47 You're receiving 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 Jan 9 11:05:32 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 09 Jan 2023 06:05:32 -0500 Subject: [Git][ghc/ghc][wip/no_fixup_chains_2] 4 commits: Disable split sections on aarch64-deb10 build Message-ID: <63bbf4fc7570b_136d98115038e8307154@gitlab.mail> Matthew Pickering pushed to branch wip/no_fixup_chains_2 at Glasgow Haskell Compiler / GHC Commits: 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 490caaea by Matthew Pickering at 2023-01-09T11:05:06+00:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 4c38ab8f by Matthew Pickering at 2023-01-09T11:05:06+00:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. - - - - - 10 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - configure.ac - distrib/configure.ac.in - m4/ghc_llvm_target.m4 - + testsuite/tests/printer/HsDocTy.hs - testsuite/tests/printer/Makefile - testsuite/tests/printer/all.T - utils/check-exact/ExactPrint.hs - utils/check-exact/Main.hs Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -813,7 +813,7 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , standardBuilds Amd64 Darwin , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin - , standardBuilds AArch64 (Linux Debian10) + , standardBuildsWithConfig AArch64 (Linux Debian10) (splitSectionsBroken vanilla) , disableValidate (standardBuildsWithConfig AArch64 (Linux Debian10) llvm) , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla) , standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static) ===================================== .gitlab/jobs.yaml ===================================== @@ -1926,7 +1926,7 @@ "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release": { + "release-aarch64-linux-deb10-release+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1936,7 +1936,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release.tar.xz", + "ghc-aarch64-linux-deb10-release+llvm.tar.xz", "junit.xml" ], "reports": { @@ -1978,15 +1978,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", + "BUILD_FLAVOUR": "release+llvm", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release", + "TEST_ENV": "aarch64-linux-deb10-release+llvm", "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release+llvm": { + "release-aarch64-linux-deb10-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1996,7 +1996,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release+llvm.tar.xz", + "ghc-aarch64-linux-deb10-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2038,11 +2038,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", - "BUILD_FLAVOUR": "release+llvm", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release+llvm", + "TEST_ENV": "aarch64-linux-deb10-release+no_split_sections", "XZ_OPT": "-9" } }, ===================================== configure.ac ===================================== @@ -667,6 +667,8 @@ GHC_LLVM_TARGET_SET_VAR # we intend to pass trough --targets to llvm as is. LLVMTarget_CPP=` echo "$LlvmTarget"` AC_SUBST(LLVMTarget_CPP) +# The target is substituted into the distrib/configure.ac file +AC_SUBST(LlvmTarget) dnl ** See whether cc supports --target= and set dnl CONF_CC_OPTS_STAGE[012] accordingly. ===================================== distrib/configure.ac.in ===================================== @@ -18,6 +18,8 @@ dnl-------------------------------------------------------------------- dnl Various things from the source distribution configure bootstrap_target=@TargetPlatform@ +bootstrap_llvm_target=@LlvmTarget@ + TargetHasRTSLinker=@TargetHasRTSLinker@ AC_SUBST(TargetHasRTSLinker) @@ -169,6 +171,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG # Stage 3 won't be supported by cross-compilation FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) +FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) +FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + AC_SUBST(CONF_CC_OPTS_STAGE0) AC_SUBST(CONF_CC_OPTS_STAGE1) AC_SUBST(CONF_CC_OPTS_STAGE2) ===================================== m4/ghc_llvm_target.m4 ===================================== @@ -50,5 +50,10 @@ AC_DEFUN([GHC_LLVM_TARGET], [ # require it. AC_DEFUN([GHC_LLVM_TARGET_SET_VAR], [ AC_REQUIRE([FPTOOLS_SET_PLATFORMS_VARS]) - GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + if test "$bootstrap_llvm_target" != "" + then + $5=$bootstrap_llvm_target + else + GHC_LLVM_TARGET([$target],[$TargetArch],[$TargetVendor],[$TargetOS],[LlvmTarget]) + fi ]) ===================================== testsuite/tests/printer/HsDocTy.hs ===================================== @@ -0,0 +1,6 @@ +{-# OPTIONS_GHC -haddock #-} +module HsDocTy where + +class C1 a where + f1 :: a -> Int + -- ^ comment on Int ===================================== testsuite/tests/printer/Makefile ===================================== @@ -769,3 +769,9 @@ Test21355: Test21805: $(CHECK_PPR) $(LIBDIR) Test21805.hs $(CHECK_EXACT) $(LIBDIR) Test21805.hs + +.PHONY: HsDocTy +HsDocTy: + # See comment on pprWithDocString, this won't round trip + # $(CHECK_PPR) $(LIBDIR) HsDocTy.hs + $(CHECK_EXACT) $(LIBDIR) HsDocTy.hs ===================================== testsuite/tests/printer/all.T ===================================== @@ -185,4 +185,5 @@ test('Test21805', [ignore_stderr, req_ppr_deps], makefile_test, ['Test21805']) test('T22488', normal, ghci_script, ['T22488.script']) test('T22488_docHead', normal, compile_and_run, ['-package ghc']) test('T20531', extra_files(['T20531_defs.hs']), ghci_script, ['T20531.script']) -test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) \ No newline at end of file +test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) +test('HsDocTy', [ignore_stderr, req_ppr_deps], makefile_test, ['HsDocTy']) \ No newline at end of file ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -3898,6 +3898,10 @@ instance ExactPrint (HsType GhcPs) where exact (HsSpliceTy a splice) = do splice' <- markAnnotated splice return (HsSpliceTy a splice') + exact (HsDocTy an ty doc) = do + ty' <- markAnnotated ty + doc' <- markAnnotated doc + return (HsDocTy an ty' doc') exact (HsBangTy an (HsSrcBang mt up str) ty) = do an0 <- case mt of ===================================== utils/check-exact/Main.hs ===================================== @@ -59,7 +59,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../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) - "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) + -- "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3a.hs" (Just changeWhereIn3a) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3b.hs" (Just changeWhereIn3b) -- "../../testsuite/tests/ghc-api/exactprint/AddLocalDecl1.hs" (Just addLocaLDecl1) @@ -203,6 +203,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../testsuite/tests/ghc-api/exactprint/Test20239.hs" Nothing -- "../../testsuite/tests/printer/PprArrowLambdaCase.hs" Nothing -- "../../testsuite/tests/printer/Test16279.hs" Nothing + "../../testsuite/tests/printer/HsDocTy.hs" Nothing -- cloneT does not need a test, function can be retired View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5f53e30aa55f6414e2494165d1b368b02a09e5bc...4c38ab8fefb355ccd25e6a6b0306ce4bf08d1287 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5f53e30aa55f6414e2494165d1b368b02a09e5bc...4c38ab8fefb355ccd25e6a6b0306ce4bf08d1287 You're receiving 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 Jan 9 11:09:36 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 09 Jan 2023 06:09:36 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] 3 commits: Disable split sections on aarch64-deb10 build Message-ID: <63bbf5f0694cb_136d983df048c3088f8@gitlab.mail> Matthew Pickering pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - b3af4540 by Luite Stegeman at 2023-01-09T11:09:19+00:00 Add PrimCallConv suppport to GHCi This adds support for calling Cmm code from bytecode using the native calling convention, allowing modules that use `foreign import prim` to be loaded and debugged in GHCi. This patch introduces a new `PRIMCALL` bytecode instruction and a helper stack frame `stg_primcall`. The code is based on the existing functionality for dealing with unboxed tuples in bytecode, which has been generalised to handle arbitrary calls. Fixes #22051 - - - - - 28 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Foreign.hs - rts/Disassembler.c - rts/Interpreter.c - rts/RtsSymbols.c - rts/StgMiscClosures.cmm - rts/include/rts/Bytecodes.h - rts/include/stg/MiscClosures.h - testsuite/tests/ghci/prog014/prog014.T - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout-ws-32 - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm - + testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile - + testsuite/tests/ghci/should_run/GHCiPrimCall/all.T - + testsuite/tests/printer/HsDocTy.hs - testsuite/tests/printer/Makefile - testsuite/tests/printer/all.T - utils/check-exact/ExactPrint.hs - utils/check-exact/Main.hs Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -813,7 +813,7 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , standardBuilds Amd64 Darwin , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin - , standardBuilds AArch64 (Linux Debian10) + , standardBuildsWithConfig AArch64 (Linux Debian10) (splitSectionsBroken vanilla) , disableValidate (standardBuildsWithConfig AArch64 (Linux Debian10) llvm) , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla) , standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static) ===================================== .gitlab/jobs.yaml ===================================== @@ -1926,7 +1926,7 @@ "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release": { + "release-aarch64-linux-deb10-release+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1936,7 +1936,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release.tar.xz", + "ghc-aarch64-linux-deb10-release+llvm.tar.xz", "junit.xml" ], "reports": { @@ -1978,15 +1978,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", + "BUILD_FLAVOUR": "release+llvm", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release", + "TEST_ENV": "aarch64-linux-deb10-release+llvm", "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release+llvm": { + "release-aarch64-linux-deb10-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1996,7 +1996,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release+llvm.tar.xz", + "ghc-aarch64-linux-deb10-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2038,11 +2038,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", - "BUILD_FLAVOUR": "release+llvm", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release+llvm", + "TEST_ENV": "aarch64-linux-deb10-release+no_split_sections", "XZ_OPT": "-9" } }, ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -12,7 +12,7 @@ module GHC.ByteCode.Asm ( bcoFreeNames, SizedSeq, sizeSS, ssElts, iNTERP_STACK_CHECK_THRESH, - mkTupleInfoLit + mkNativeCallInfoLit ) where import GHC.Prelude @@ -32,7 +32,6 @@ import GHC.Types.Unique.DSet import GHC.Utils.Outputable import GHC.Utils.Panic -import GHC.Utils.Panic.Plain import GHC.Core.TyCon import GHC.Data.FastString @@ -40,7 +39,7 @@ import GHC.Data.SizedSeq import GHC.StgToCmm.Layout ( ArgRep(..) ) import GHC.Cmm.Expr -import GHC.Cmm.CallConv ( tupleRegsCover ) +import GHC.Cmm.CallConv ( allArgRegsCover ) import GHC.Platform import GHC.Platform.Profile @@ -202,7 +201,8 @@ assembleBCO platform (ProtoBCO { protoBCOName = nm (final_insns, final_lits, final_ptrs) <- flip execStateT initial_state $ runAsm platform long_jumps env asm -- precomputed size should be equal to final size - massert (n_insns == sizeSS final_insns) + massertPpr (n_insns == sizeSS final_insns) + (text "bytecode instruction count mismatch") let asm_insns = ssElts final_insns insns_arr = Array.listArray (0, fromIntegral n_insns - 1) asm_insns @@ -351,7 +351,8 @@ largeArg platform w = case platformWordSize platform of fromIntegral (w `shiftR` 32), fromIntegral (w `shiftR` 16), fromIntegral w] - PW4 -> assert (w < fromIntegral (maxBound :: Word32)) $ + PW4 -> assertPpr (w < fromIntegral (maxBound :: Word32)) + (text "largeArg too big:" <+> ppr w) $ [fromIntegral (w `shiftR` 16), fromIntegral w] @@ -388,14 +389,14 @@ assembleI platform i = case i of -> do let ul_bco = assembleBCO platform proto p <- ioptr (liftM BCOPtrBCO ul_bco) emit (push_alts pk) [Op p] - PUSH_ALTS_TUPLE proto tuple_info tuple_proto + PUSH_ALTS_TUPLE proto call_info tuple_proto -> do let ul_bco = assembleBCO platform proto ul_tuple_bco = assembleBCO platform tuple_proto p <- ioptr (liftM BCOPtrBCO ul_bco) p_tup <- ioptr (liftM BCOPtrBCO ul_tuple_bco) info <- int (fromIntegral $ - mkTupleInfoSig platform tuple_info) + mkNativeCallInfoSig platform call_info) emit bci_PUSH_ALTS_T [Op p, Op info, Op p_tup] PUSH_PAD8 -> emit bci_PUSH_PAD8 [] @@ -491,6 +492,7 @@ assembleI platform i = case i of RETURN_TUPLE -> emit bci_RETURN_T [] CCALL off m_addr i -> do np <- addr m_addr emit bci_CCALL [SmallOp off, Op np, SmallOp i] + PRIMCALL -> emit bci_PRIMCALL [] BRK_FUN index uniq cc -> do p1 <- ptr BCOPtrBreakArray q <- int (getKey uniq) np <- addr cc @@ -582,39 +584,47 @@ return_unlifted V64 = error "return_unlifted: vector" platform). -} -maxTupleNativeStackSize :: WordOff -maxTupleNativeStackSize = 62 +maxTupleReturnNativeStackSize :: WordOff +maxTupleReturnNativeStackSize = 62 + +maxPrimCallNativeStackSize :: WordOff +maxPrimCallNativeStackSize = 255 {- - Construct the tuple_info word that stg_ctoi_t and stg_ret_t use - to convert a tuple between the native calling convention and the + Construct the call_info word that stg_ctoi_t, stg_ret_t and stg_primcall + use to convert arguments between the native calling convention and the interpreter. - See Note [GHCi tuple layout] for more information. + See Note [GHCi and native call registers] for more information. -} -mkTupleInfoSig :: Platform -> TupleInfo -> Word32 -mkTupleInfoSig platform TupleInfo{..} - | tupleNativeStackSize > maxTupleNativeStackSize - = pprPanic "mkTupleInfoSig: tuple too big for the bytecode compiler" - (ppr tupleNativeStackSize <+> text "stack words." <+> +mkNativeCallInfoSig :: Platform -> NativeCallInfo -> Word32 +mkNativeCallInfoSig platform NativeCallInfo{..} + | nativeCallType == NativePrimCall && nativeCallStackSpillSize > maxPrimCallNativeStackSize + = pprPanic "mkNativeCallInfoSig: native call too big for the bytecode compiler" + (ppr nativeCallStackSpillSize <+> text "stack words." <+> + text "Use -fobject-code to get around this limit" + ) + | nativeCallType == NativeTupleReturn && nativeCallStackSpillSize > maxTupleReturnNativeStackSize + = pprPanic "mkNativeCallInfoSig: tuple too big for the bytecode compiler" + (ppr nativeCallStackSpillSize <+> text "stack words." <+> text "Use -fobject-code to get around this limit" ) | otherwise - = assert (length regs <= 24) {- 24 bits for bitmap -} - assert (tupleNativeStackSize < 255) {- 8 bits for stack size -} - assert (all (`elem` regs) (regSetToList tupleRegs)) {- all regs accounted for -} + = assertPpr (length regs <= 24) (text "too many registers for bitmap:" <+> ppr (length regs)) {- 24 bits for bitmap -} + assertPpr (nativeCallStackSpillSize < 255) (text "stack spill size too large:" <+> ppr nativeCallStackSpillSize) {- 8 bits for stack size -} + assertPpr (all (`elem` regs) (regSetToList nativeCallRegs)) (text "not all registers accounted for") {- all regs accounted for -} foldl' reg_bit 0 (zip regs [0..]) .|. - (fromIntegral tupleNativeStackSize `shiftL` 24) + (fromIntegral nativeCallStackSpillSize `shiftL` 24) where reg_bit :: Word32 -> (GlobalReg, Int) -> Word32 reg_bit x (r, n) - | r `elemRegSet` tupleRegs = x .|. 1 `shiftL` n - | otherwise = x - regs = tupleRegsCover platform + | r `elemRegSet` nativeCallRegs = x .|. 1 `shiftL` n + | otherwise = x + regs = allArgRegsCover platform -mkTupleInfoLit :: Platform -> TupleInfo -> Literal -mkTupleInfoLit platform tuple_info = - mkLitWord platform . fromIntegral $ mkTupleInfoSig platform tuple_info +mkNativeCallInfoLit :: Platform -> NativeCallInfo -> Literal +mkNativeCallInfoLit platform call_info = + mkLitWord platform . fromIntegral $ mkNativeCallInfoSig platform call_info -- Make lists of host-sized words for literals, so that when the -- words are placed in memory at increasing addresses, the ===================================== compiler/GHC/ByteCode/Instr.hs ===================================== @@ -90,7 +90,7 @@ data BCInstr | PUSH_ALTS (ProtoBCO Name) | PUSH_ALTS_UNLIFTED (ProtoBCO Name) ArgRep | PUSH_ALTS_TUPLE (ProtoBCO Name) -- continuation - !TupleInfo + !NativeCallInfo (ProtoBCO Name) -- tuple return BCO -- Pushing 8, 16 and 32 bits of padding (for constructors). @@ -184,6 +184,8 @@ data BCInstr -- (XXX: inefficient, but I don't know -- what the alignment constraints are.) + | PRIMCALL + -- For doing magic ByteArray passing to foreign calls | SWIZZLE Word16 -- to the ptr N words down the stack, Word16 -- add M (interpreted as a signed 16-bit entity) @@ -269,8 +271,8 @@ instance Outputable BCInstr where ppr (PUSH_ALTS bco) = hang (text "PUSH_ALTS") 2 (ppr bco) ppr (PUSH_ALTS_UNLIFTED bco pk) = hang (text "PUSH_ALTS_UNLIFTED" <+> ppr pk) 2 (ppr bco) - ppr (PUSH_ALTS_TUPLE bco tuple_info tuple_bco) = - hang (text "PUSH_ALTS_TUPLE" <+> ppr tuple_info) + ppr (PUSH_ALTS_TUPLE bco call_info tuple_bco) = + hang (text "PUSH_ALTS_TUPLE" <+> ppr call_info) 2 (ppr tuple_bco $+$ ppr bco) @@ -340,6 +342,7 @@ instance Outputable BCInstr where 0x1 -> text "(interruptible)" 0x2 -> text "(unsafe)" _ -> empty) + ppr PRIMCALL = text "PRIMCALL" ppr (SWIZZLE stkoff n) = text "SWIZZLE " <+> text "stkoff" <+> ppr stkoff <+> text "by" <+> ppr n ppr ENTER = text "ENTER" @@ -382,11 +385,11 @@ bciStackUse (PUSH_ALTS bco) = 2 {- profiling only, restore CCCS -} + bciStackUse (PUSH_ALTS_UNLIFTED bco _) = 2 {- profiling only, restore CCCS -} + 4 + protoBCOStackUse bco bciStackUse (PUSH_ALTS_TUPLE bco info _) = - -- (tuple_bco, tuple_info word, cont_bco, stg_ctoi_t) + -- (tuple_bco, call_info word, cont_bco, stg_ctoi_t) -- tuple - -- (tuple_info, tuple_bco, stg_ret_t) + -- (call_info, tuple_bco, stg_ret_t) 1 {- profiling only -} + - 7 + fromIntegral (tupleSize info) + protoBCOStackUse bco + 7 + fromIntegral (nativeCallSize info) + protoBCOStackUse bco bciStackUse (PUSH_PAD8) = 1 -- overapproximation bciStackUse (PUSH_PAD16) = 1 -- overapproximation bciStackUse (PUSH_PAD32) = 1 -- overapproximation on 64bit arch @@ -443,6 +446,7 @@ bciStackUse RETURN{} = 0 bciStackUse RETURN_UNLIFTED{} = 1 -- pushes stg_ret_X for some X bciStackUse RETURN_TUPLE{} = 1 -- pushes stg_ret_t header bciStackUse CCALL{} = 0 +bciStackUse PRIMCALL{} = 1 -- pushes stg_primcall bciStackUse SWIZZLE{} = 0 bciStackUse BRK_FUN{} = 0 ===================================== compiler/GHC/ByteCode/Types.hs ===================================== @@ -10,7 +10,7 @@ module GHC.ByteCode.Types ( CompiledByteCode(..), seqCompiledByteCode , FFIInfo(..) , RegBitmap(..) - , TupleInfo(..), voidTupleInfo + , NativeCallType(..), NativeCallInfo(..), voidTupleReturnInfo, voidPrimCallInfo , ByteOff(..), WordOff(..) , UnlinkedBCO(..), BCOPtr(..), BCONPtr(..) , ItblEnv, ItblPtr(..) @@ -105,22 +105,32 @@ newtype RegBitmap = RegBitmap { unRegBitmap :: Word32 } See GHC.StgToByteCode.layoutTuple for more details. -} -data TupleInfo = TupleInfo - { tupleSize :: !WordOff -- total size of tuple in words - , tupleRegs :: !GlobalRegSet - , tupleNativeStackSize :: !WordOff {- words spilled on the stack by - GHCs native calling convention -} - } deriving (Show) - -instance Outputable TupleInfo where - ppr TupleInfo{..} = text " ppr tupleSize <+> - text "stack" <+> ppr tupleNativeStackSize <+> - text "regs" <+> - ppr (map (text @SDoc . show) $ regSetToList tupleRegs) <> - char '>' - -voidTupleInfo :: TupleInfo -voidTupleInfo = TupleInfo 0 emptyRegSet 0 + +data NativeCallType = NativePrimCall + | NativeTupleReturn + deriving (Eq) + +data NativeCallInfo = NativeCallInfo + { nativeCallType :: !NativeCallType + , nativeCallSize :: !WordOff -- total size of arguments in words + , nativeCallRegs :: !GlobalRegSet + , nativeCallStackSpillSize :: !WordOff {- words spilled on the stack by + GHCs native calling convention -} + } + +instance Outputable NativeCallInfo where + ppr NativeCallInfo{..} = text " ppr nativeCallSize <+> + text "stack" <+> ppr nativeCallStackSpillSize <+> + text "regs" <+> + ppr (map (text @SDoc . show) $ regSetToList nativeCallRegs) <> + char '>' + + +voidTupleReturnInfo :: NativeCallInfo +voidTupleReturnInfo = NativeCallInfo NativeTupleReturn 0 emptyRegSet 0 + +voidPrimCallInfo :: NativeCallInfo +voidPrimCallInfo = NativeCallInfo NativePrimCall 0 emptyRegSet 0 type ItblEnv = NameEnv (Name, ItblPtr) -- We need the Name in the range so we know which ===================================== compiler/GHC/Cmm/CallConv.hs ===================================== @@ -3,7 +3,7 @@ module GHC.Cmm.CallConv ( assignArgumentsPos, assignStack, realArgRegsCover, - tupleRegsCover + allArgRegsCover ) where import GHC.Prelude @@ -220,12 +220,104 @@ realArgRegsCover platform realLongRegs platform -- we don't save XMM registers if they are not used for parameter passing --- Like realArgRegsCover but always includes the node. This covers the real --- and virtual registers used for unboxed tuples. --- --- Note: if anything changes in how registers for unboxed tuples overlap, --- make sure to also update GHC.StgToByteCode.layoutTuple. -tupleRegsCover :: Platform -> [GlobalReg] -tupleRegsCover platform = +{- + + Note [GHCi and native call registers] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + The GHCi bytecode interpreter does not have access to the STG registers + that the native calling convention uses for passing arguments. It uses + helper stack frames to move values between the stack and registers. + + If only a single register needs to be moved, GHCi uses a specific stack + frame. For example stg_ctoi_R1p saves a heap pointer value from STG register + R1 and stg_ctoi_D1 saves a double precision floating point value from D1. + In the other direction, helpers stg_ret_p and stg_ret_d move a value from + the stack to the R1 and D1 registers, respectively. + + When GHCi needs to move more than one register it cannot use a specific + helper frame. It would simply be impossible to create a helper for all + possible combinations of register values. Instead, there are generic helper + stack frames that use a call_info word that describes the active registers + and the number of stack words used by the arguments of a call. + + These helper stack frames are currently: + + - stg_ret_t: return a tuple to the continuation at the top of + the stack + - stg_ctoi_t: convert a tuple return value to be used in + bytecode + - stg_primcall: call a function + + + The call_info word contains a bitmap of the active registers + for the call and and a stack offset. The layout is as follows: + + - bit 0-23: Bitmap of active registers for the call, the + order corresponds to the list returned by + allArgRegsCover. For example if bit 0 (the least + significant bit) is set, the first register in the + allArgRegsCover list is active. Bit 1 for the + second register in the list and so on. + + - bit 24-31: Unsigned byte, indicating the stack usage of the + call in words (not counting the space ) + + The upper 32 bits on 64 bit platforms are currently unused. + + If a register is smaller than a word on the stack (for example a + single precision float on a 64 bit system), then the stack slot + is padded to a whole word. + + Example: + + If a call has three arguments passed registers and and + additional five words of arguments on the stack, then + three bits in the bitmap in bits 0-23 would be set. And + Bit 24-31 would be 00000010 (two in binary). + + The values on the stack before a call to POP_ARG_REGS would + be as follows: + + ... + stack_arg_1 + stack_arg_2 + register_arg_3 + register_arg_2 + register_arg_1 <- Sp + + A call to POP_ARG_REGS(call_info) would move register_arg_1 + to the register corresponding to the lowest set bit in the + call_info word. register_arg_2 would be moved to the register + corresponding to the second lowest set bit, and so on. + + After POP_ARG_REGS(call_info), the stack pointer Sp points + to the first stack slot below the stack arguments. The stack + arguments are still on the stack above Sp, so the stack looks + as follows: + + ... <- Sp + stack_arg_1 + stack_arg_2 + + At this point all the arguments are in place and we are ready + to jump to the native function. + + On x86_64, the double precision (Dn) and single precision + floating (Fn) point registers overlap, e.g. D1 uses the same + physical register as F1. On this platform, the list returned + by allArgRegsCover contains only entries for the double + precision registers. If an argument is passed in register + Fn, the bit corresponding to Dn should be set. + + Note: if anything changes in how registers for native calls overlap, + make sure to also update GHC.StgToByteCode.layoutNativeCall + -} + +-- Like realArgRegsCover but always includes the node. This covers all real +-- and virtual registers actually used for passing arguments. + +allArgRegsCover :: Platform -> [GlobalReg] +allArgRegsCover platform = nub (VanillaReg 1 VGcPtr : realArgRegsCover platform) ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -1233,8 +1233,8 @@ stmtMacros = listToUFM [ ( fsLit "SAVE_REGS", \[] -> emitSaveRegs ), ( fsLit "RESTORE_REGS", \[] -> emitRestoreRegs ), - ( fsLit "PUSH_TUPLE_REGS", \[live_regs] -> emitPushTupleRegs live_regs ), - ( fsLit "POP_TUPLE_REGS", \[live_regs] -> emitPopTupleRegs live_regs ), + ( fsLit "PUSH_ARG_REGS", \[live_regs] -> emitPushArgRegs live_regs ), + ( fsLit "POP_ARG_REGS", \[live_regs] -> emitPopArgRegs live_regs ), ( fsLit "LDV_ENTER", \[e] -> ldvEnter e ), ( fsLit "LDV_RECORD_CREATE", \[e] -> ldvRecordCreate e ), ===================================== compiler/GHC/Cmm/Reg.hs ===================================== @@ -223,7 +223,7 @@ instance Eq GlobalReg where _r1 == _r2 = False -- NOTE: this Ord instance affects the tuple layout in GHCi, see --- Note [GHCi tuple layout] +-- Note [GHCi and native call registers] instance Ord GlobalReg where compare (VanillaReg i _) (VanillaReg j _) = compare i j -- Ignore type when seeking clashes ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -58,7 +58,7 @@ import GHC.Data.FastString import GHC.Utils.Panic import GHC.Utils.Panic.Plain import GHC.Utils.Exception (evaluate) -import GHC.StgToCmm.Closure ( NonVoid(..), fromNonVoid, nonVoidIds ) +import GHC.StgToCmm.Closure ( NonVoid(..), fromNonVoid, nonVoidIds, argPrimRep ) import GHC.StgToCmm.Layout import GHC.Runtime.Heap.Layout hiding (WordOff, ByteOff, wordsToBytes) import GHC.Data.Bitmap @@ -464,10 +464,10 @@ returnUnliftedReps d s szb reps = do [rep] -> return (unitOL $ RETURN_UNLIFTED (toArgRep platform rep)) -- otherwise use RETURN_TUPLE with a tuple descriptor nv_reps -> do - let (tuple_info, args_offsets) = layoutTuple profile 0 (primRepCmmType platform) nv_reps + let (call_info, args_offsets) = layoutNativeCall profile NativeTupleReturn 0 (primRepCmmType platform) nv_reps args_ptrs = map (\(rep, off) -> (isFollowableArg (toArgRep platform rep), off)) args_offsets - tuple_bco <- emitBc (tupleBCO platform tuple_info args_ptrs) - return $ PUSH_UBX (mkTupleInfoLit platform tuple_info) 1 `consOL` + tuple_bco <- emitBc (tupleBCO platform call_info args_ptrs) + return $ PUSH_UBX (mkNativeCallInfoLit platform call_info) 1 `consOL` PUSH_BCO tuple_bco `consOL` unitOL RETURN_TUPLE return ( mkSlideB platform szb (d - s) -- clear to sequel @@ -484,7 +484,11 @@ returnUnboxedTuple d s p es = do profile <- getProfile let platform = profilePlatform profile arg_ty e = primRepCmmType platform (atomPrimRep e) - (tuple_info, tuple_components) = layoutTuple profile d arg_ty es + (call_info, tuple_components) = layoutNativeCall profile + NativeTupleReturn + d + arg_ty + es go _ pushes [] = return (reverse pushes) go !dd pushes ((a, off):cs) = do (push, szb) <- pushAtom dd p a massert (off == dd + szb) @@ -492,7 +496,7 @@ returnUnboxedTuple d s p es = do pushes <- go d [] tuple_components ret <- returnUnliftedReps d s - (wordsToBytes platform $ tupleSize tuple_info) + (wordsToBytes platform $ nativeCallSize call_info) (map atomPrimRep es) return (mconcat pushes `appOL` ret) @@ -648,14 +652,14 @@ schemeT d s p app -- Case 1 schemeT d s p (StgOpApp (StgFCallOp (CCall ccall_spec) _ty) args result_ty) = if isSupportedCConv ccall_spec - then generateCCall d s p ccall_spec result_ty (reverse args) + then generateCCall d s p ccall_spec result_ty args else unsupportedCConvException schemeT d s p (StgOpApp (StgPrimOp op) args _ty) = doTailCall d s p (primOpId op) (reverse args) -schemeT _d _s _p (StgOpApp StgPrimCallOp{} _args _ty) - = unsupportedCConvException +schemeT d s p (StgOpApp (StgPrimCallOp (PrimCall label unit)) args result_ty) + = generatePrimCall d s p label (Just unit) result_ty args -- Case 2: Unboxed tuple schemeT d s p (StgConApp con _cn args _tys) @@ -840,18 +844,18 @@ doCase d s p scrut bndr alts | ubx_frame = wordSize platform | otherwise = 0 - (bndr_size, tuple_info, args_offsets) + (bndr_size, call_info, args_offsets) | ubx_tuple_frame = let bndr_ty = primRepCmmType platform bndr_reps = filter (not.isVoidRep) (bcIdPrimReps bndr) - (tuple_info, args_offsets) = - layoutTuple profile 0 bndr_ty bndr_reps - in ( wordsToBytes platform (tupleSize tuple_info) - , tuple_info + (call_info, args_offsets) = + layoutNativeCall profile NativeTupleReturn 0 bndr_ty bndr_reps + in ( wordsToBytes platform (nativeCallSize call_info) + , call_info , args_offsets ) | otherwise = ( wordsToBytes platform (idSizeW platform bndr) - , voidTupleInfo + , voidTupleReturnInfo , [] ) @@ -885,17 +889,18 @@ doCase d s p scrut bndr alts | isUnboxedTupleType bndr_ty || isUnboxedSumType bndr_ty = let bndr_ty = primRepCmmType platform . bcIdPrimRep tuple_start = d_bndr - (tuple_info, args_offsets) = - layoutTuple profile - 0 - bndr_ty - bndrs + (call_info, args_offsets) = + layoutNativeCall profile + NativeTupleReturn + 0 + bndr_ty + bndrs stack_bot = d_alts p' = Map.insertList [ (arg, tuple_start - - wordsToBytes platform (tupleSize tuple_info) + + wordsToBytes platform (nativeCallSize call_info) + offset) | (arg, offset) <- args_offsets , not (isVoidRep $ bcIdPrimRep arg)] @@ -981,8 +986,8 @@ doCase d s p scrut bndr alts -- unboxed tuples get two more words, the second is a pointer (tuple_bco) (extra_pointers, extra_slots) - | ubx_tuple_frame && profiling = ([1], 3) -- tuple_info, tuple_BCO, CCCS - | ubx_tuple_frame = ([1], 2) -- tuple_info, tuple_BCO + | ubx_tuple_frame && profiling = ([1], 3) -- call_info, tuple_BCO, CCCS + | ubx_tuple_frame = ([1], 2) -- call_info, tuple_BCO | otherwise = ([], 0) bitmap_size = trunc16W $ fromIntegral extra_slots + @@ -1028,8 +1033,8 @@ doCase d s p scrut bndr alts let args_ptrs = map (\(rep, off) -> (isFollowableArg (toArgRep platform rep), off)) args_offsets - tuple_bco <- emitBc (tupleBCO platform tuple_info args_ptrs) - return (PUSH_ALTS_TUPLE alt_bco' tuple_info tuple_bco + tuple_bco <- emitBc (tupleBCO platform call_info args_ptrs) + return (PUSH_ALTS_TUPLE alt_bco' call_info tuple_bco `consOL` scrut_code) else let push_alts | not ubx_frame @@ -1050,14 +1055,15 @@ doCase d s p scrut bndr alts -- The native calling convention uses registers for tuples, but in the -- bytecode interpreter, all values live on the stack. -layoutTuple :: Profile - -> ByteOff - -> (a -> CmmType) - -> [a] - -> ( TupleInfo -- See Note [GHCi TupleInfo] - , [(a, ByteOff)] -- argument, offset on stack - ) -layoutTuple profile start_off arg_ty reps = +layoutNativeCall :: Profile + -> NativeCallType + -> ByteOff + -> (a -> CmmType) + -> [a] + -> ( NativeCallInfo -- See Note [GHCi TupleInfo] + , [(a, ByteOff)] -- argument, offset on stack + ) +layoutNativeCall profile call_type start_off arg_ty reps = let platform = profilePlatform profile (orig_stk_bytes, pos) = assignArgumentsPos profile 0 @@ -1070,7 +1076,7 @@ layoutTuple profile start_off arg_ty reps = -- sort the register parameters by register and add them to the stack regs_order :: Map.Map GlobalReg Int - regs_order = Map.fromList $ zip (tupleRegsCover platform) [0..] + regs_order = Map.fromList $ zip (allArgRegsCover platform) [0..] reg_order :: GlobalReg -> (Int, GlobalReg) reg_order reg | Just n <- Map.lookup reg regs_order = (n, reg) @@ -1099,10 +1105,11 @@ layoutTuple profile start_off arg_ty reps = get_byte_off _ = panic "GHC.StgToByteCode.layoutTuple get_byte_off" - in ( TupleInfo - { tupleSize = bytesToWords platform (ByteOff new_stk_bytes) - , tupleRegs = regs_set - , tupleNativeStackSize = bytesToWords platform + in ( NativeCallInfo + { nativeCallType = call_type + , nativeCallSize = bytesToWords platform (ByteOff new_stk_bytes) + , nativeCallRegs = regs_set + , nativeCallStackSpillSize = bytesToWords platform (ByteOff orig_stk_bytes) } , sortBy (comparing snd) $ @@ -1127,7 +1134,7 @@ usePlainReturn t ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We have the bytecode instructions RETURN_TUPLE and PUSH_ALTS_TUPLE to return and receive arbitrary unboxed tuples, respectively. These - instructions use the helper data tuple_BCO and tuple_info. + instructions use the helper data tuple_BCO and call_info. The helper data is used to convert tuples between GHCs native calling convention (object code), which uses stack and registers, and the bytecode @@ -1139,7 +1146,7 @@ usePlainReturn t ================= Bytecode that returns a tuple first pushes all the tuple fields followed - by the appropriate tuple_info and tuple_BCO onto the stack. It then + by the appropriate call_info and tuple_BCO onto the stack. It then executes the RETURN_TUPLE instruction, which causes the interpreter to push stg_ret_t_info to the top of the stack. The stack (growing down) then looks as follows: @@ -1150,14 +1157,14 @@ usePlainReturn t tuple_field_2 ... tuple_field_n - tuple_info + call_info tuple_BCO stg_ret_t_info <- Sp If next_frame is bytecode, the interpreter will start executing it. If it's object code, the interpreter jumps back to the scheduler, which in turn jumps to stg_ret_t. stg_ret_t converts the tuple to the native - calling convention using the description in tuple_info, and then jumps + calling convention using the description in call_info, and then jumps to next_frame. @@ -1169,13 +1176,13 @@ usePlainReturn t tuple. The PUSH_ALTS_TUPLE instuction contains three pieces of data: * cont_BCO: the continuation that receives the tuple - * tuple_info: see below + * call_info: see below * tuple_BCO: see below The interpreter pushes these onto the stack when the PUSH_ALTS_TUPLE instruction is executed, followed by stg_ctoi_tN_info, with N depending on the number of stack words used by the tuple in the GHC native calling - convention. N is derived from tuple_info. + convention. N is derived from call_info. For example if we expect a tuple with three words on the stack, the stack looks as follows after PUSH_ALTS_TUPLE: @@ -1186,7 +1193,7 @@ usePlainReturn t cont_free_var_2 ... cont_free_var_n - tuple_info + call_info tuple_BCO cont_BCO stg_ctoi_t3_info <- Sp @@ -1206,20 +1213,20 @@ usePlainReturn t that is already on the stack. - The tuple_info word + The call_info word =================== - The tuple_info word describes the stack and STG register (e.g. R1..R6, - D1..D6) usage for the tuple. tuple_info contains enough information to + The call_info word describes the stack and STG register (e.g. R1..R6, + D1..D6) usage for the tuple. call_info contains enough information to convert the tuple between the stack-only bytecode and stack+registers GHC native calling conventions. - See Note [GHCi tuple layout] for more details of how the data is packed - in a single word. + See Note [GHCi and native call registers] for more details of how the + data is packed in a single word. -} -tupleBCO :: Platform -> TupleInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name +tupleBCO :: Platform -> NativeCallInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name tupleBCO platform info pointers = mkProtoBCO platform invented_name body_code (Left []) 0{-no arity-} bitmap_size bitmap False{-is alts-} @@ -1233,15 +1240,103 @@ tupleBCO platform info pointers = -} invented_name = mkSystemVarName (mkPseudoUniqueE 0) (fsLit "tuple") - -- the first word in the frame is the tuple_info word, + -- the first word in the frame is the call_info word, -- which is not a pointer - bitmap_size = trunc16W $ 1 + tupleSize info + bitmap_size = trunc16W $ 1 + nativeCallSize info bitmap = intsToReverseBitmap platform (fromIntegral bitmap_size) $ map ((+1) . fromIntegral . bytesToWords platform . snd) (filter fst pointers) body_code = mkSlideW 0 1 -- pop frame header `snocOL` RETURN_TUPLE -- and add it again +primCallBCO :: Platform -> NativeCallInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name +primCallBCO platform args_info pointers = + mkProtoBCO platform invented_name body_code (Left []) + 0{-no arity-} bitmap_size bitmap False{-is alts-} + + where + {- + The primcall BCO is never referred to by name, so we can get away + with using a fake name here. We will need to change this if we want + to save some memory by sharing the BCO between places that have + the same tuple shape + -} + invented_name = mkSystemVarName (mkPseudoUniqueE 0) (fsLit "primcall") + + -- the first three words in the frame are the BCO describing the + -- pointers in the frame, the call_info word and the pointer + -- to the Cmm function being called. None of these is a pointer that + -- should be followed by the garbage collector + bitmap_size = trunc16W $ 2 + nativeCallSize args_info + bitmap = intsToReverseBitmap platform (fromIntegral bitmap_size) $ + map ((+2) . fromIntegral . bytesToWords platform . snd) + (filter fst pointers) + -- if the primcall BCO is ever run it's a bug, since the BCO should only + -- be pushed immediately before running the PRIMCALL bytecode instruction, + -- which immediately leaves the interpreter to jump to the stg_primcall_info + -- Cmm function + body_code = unitOL CASEFAIL + +-- ----------------------------------------------------------------------------- +-- Deal with a primitive call to native code. + +generatePrimCall + :: StackDepth + -> Sequel + -> BCEnv + -> CLabelString -- where to call + -> Maybe Unit + -> Type + -> [StgArg] -- args (atoms) + -> BcM BCInstrList +generatePrimCall d s p target _mb_unit _result_ty args + = do + profile <- getProfile + let + platform = profilePlatform profile + + non_void VoidRep = False + non_void _ = True + + nv_args :: [StgArg] + nv_args = filter (non_void . argPrimRep) args + + (args_info, args_offsets) = + layoutNativeCall profile + NativePrimCall + d + (primRepCmmType platform . argPrimRep) + nv_args + + args_ptrs :: [(Bool, ByteOff)] + args_ptrs = + map (\(r, off) -> + (isFollowableArg (toArgRep platform . argPrimRep $ r), off)) + args_offsets + + push_target = PUSH_UBX (LitLabel target Nothing IsFunction) 1 + push_info = PUSH_UBX (mkNativeCallInfoLit platform args_info) 1 + {- + compute size to move payload (without stg_primcall_info header) + + size of arguments plus three words for: + - function pointer to the target + - call_info word + - BCO to describe the stack frame + -} + szb = wordsToBytes platform (nativeCallSize args_info + 3) + go _ pushes [] = return (reverse pushes) + go !dd pushes ((a, off):cs) = do (push, szb) <- pushAtom dd p a + massert (off == dd + szb) + go (dd + szb) (push:pushes) cs + push_args <- go d [] args_offsets + args_bco <- emitBc (primCallBCO platform args_info args_ptrs) + return $ mconcat push_args `appOL` + (push_target `consOL` + push_info `consOL` + PUSH_BCO args_bco `consOL` + (mkSlideB platform szb (d - s) `appOL` unitOL PRIMCALL)) + -- ----------------------------------------------------------------------------- -- Deal with a CCall. @@ -1259,11 +1354,17 @@ generateCCall -> Type -> [StgArg] -- args (atoms) -> BcM BCInstrList -generateCCall d0 s p (CCallSpec target cconv safety) result_ty args_r_to_l +generateCCall d0 s p (CCallSpec target PrimCallConv _) result_ty args + | (StaticTarget _ label mb_unit _) <- target + = generatePrimCall d0 s p label mb_unit result_ty args + | otherwise + = panic "GHC.StgToByteCode.generateCCall: primcall convention only supports static targets" +generateCCall d0 s p (CCallSpec target cconv safety) result_ty args = do profile <- getProfile let + args_r_to_l = reverse args platform = profilePlatform profile -- useful constants addr_size_b :: ByteOff @@ -2007,7 +2108,7 @@ isSupportedCConv :: CCallSpec -> Bool isSupportedCConv (CCallSpec _ cconv _) = case cconv of CCallConv -> True -- we explicitly pattern match on every StdCallConv -> True -- convention to ensure that a warning - PrimCallConv -> False -- is triggered when a new one is added + PrimCallConv -> True -- is triggered when a new one is added JavaScriptCallConv -> False CApiConv -> True ===================================== compiler/GHC/StgToCmm/Foreign.hs ===================================== @@ -15,8 +15,8 @@ module GHC.StgToCmm.Foreign ( emitLoadThreadState, emitSaveRegs, emitRestoreRegs, - emitPushTupleRegs, - emitPopTupleRegs, + emitPushArgRegs, + emitPopArgRegs, loadThreadState, emitOpenNursery, emitCloseNursery, @@ -349,7 +349,7 @@ emitRestoreRegs = do -- bytecode interpreter. -- -- The "live registers" bitmap corresponds to the list of registers given by --- 'tupleRegsCover', with the least significant bit indicating liveness of +-- 'allArgRegsCover', with the least significant bit indicating liveness of -- the first register in the list. -- -- Each register is saved to a stack slot of one or more machine words, even @@ -362,12 +362,12 @@ emitRestoreRegs = do -- if((mask & 2) != 0) { Sp_adj(-1); Sp(0) = R2; } -- if((mask & 1) != 0) { Sp_adj(-1); Sp(0) = R1; } -- --- See Note [GHCi tuple layout] +-- See Note [GHCi and native call registers] -emitPushTupleRegs :: CmmExpr -> FCode () -emitPushTupleRegs regs_live = do +emitPushArgRegs :: CmmExpr -> FCode () +emitPushArgRegs regs_live = do platform <- getPlatform - let regs = zip (tupleRegsCover platform) [0..] + let regs = zip (allArgRegsCover platform) [0..] save_arg (reg, n) = let mask = CmmLit (CmmInt (1 `shiftL` n) (wordWidth platform)) live = cmmAndWord platform regs_live mask @@ -381,11 +381,11 @@ emitPushTupleRegs regs_live = do in mkCmmIfThen cond $ catAGraphs [adj_sp, save_reg] emit . catAGraphs =<< mapM save_arg (reverse regs) --- | Pop a subset of STG registers from the stack (see 'emitPushTupleRegs') -emitPopTupleRegs :: CmmExpr -> FCode () -emitPopTupleRegs regs_live = do +-- | Pop a subset of STG registers from the stack (see 'emitPushArgRegs') +emitPopArgRegs :: CmmExpr -> FCode () +emitPopArgRegs regs_live = do platform <- getPlatform - let regs = zip (tupleRegsCover platform) [0..] + let regs = zip (allArgRegsCover platform) [0..] save_arg (reg, n) = let mask = CmmLit (CmmInt (1 `shiftL` n) (wordWidth platform)) live = cmmAndWord platform regs_live mask ===================================== rts/Disassembler.c ===================================== @@ -83,6 +83,9 @@ disInstr ( StgBCO *bco, int pc ) debugBelch("CCALL marshaller at 0x%" FMT_HexWord "\n", literals[instrs[pc]] ); pc += 1; break; + case bci_PRIMCALL: + debugBelch("PRIMCALL\n"); + break; case bci_STKCHECK: { StgWord stk_words_reqd = BCO_GET_LARGE_ARG + 1; debugBelch("STKCHECK %" FMT_Word "\n", (W_)stk_words_reqd ); ===================================== rts/Interpreter.c ===================================== @@ -2038,6 +2038,12 @@ run_BCO: goto nextInsn; } + case bci_PRIMCALL: { + Sp_subW(1); + SpW(0) = (W_)&stg_primcall_info; + RETURN_TO_SCHEDULER_NO_PAUSE(ThreadRunGHC, ThreadYielding); + } + case bci_CCALL: { void *tok; int stk_offset = BCO_NEXT; ===================================== rts/RtsSymbols.c ===================================== @@ -602,6 +602,7 @@ extern char **environ; SymI_HasDataProto(stg_ret_l_info) \ SymI_HasDataProto(stg_ret_t_info) \ SymI_HasDataProto(stg_ctoi_t) \ + SymI_HasDataProto(stg_primcall_info) \ SymI_HasDataProto(stg_gc_prim_p) \ SymI_HasDataProto(stg_gc_prim_pp) \ SymI_HasDataProto(stg_gc_prim_n) \ ===================================== rts/StgMiscClosures.cmm ===================================== @@ -366,20 +366,10 @@ MK_STG_CTOI_T(61) MK_STG_CTOI_T(62) /* - Note [GHCi tuple layout] - ~~~~~~~~~~~~~~~~~~~~~~~~ - the tuple_info word describes the register and stack usage of the tuple: + Convert a tuple return value to be used in bytecode. - [ ssss ssss rrrr rrrr rrrr rrrr rrrr rrrr ] - - - r: bitmap of live registers, corresponding to the list of registers - returned by GHC.Cmm.CallConv.tupleRegsCover (the least significant - bit corresponds to the first element in the list) - - s: number of words on stack (in addition to registers) - - The order of the live registers in the bitmap is the same as the list - given by GHC.Cmm.CallConv.tupleRegsCover, with the least significant - bit corresponding to the first register in the list. + See Note [GHCi and native call registers] for information on how + values are moved between the stack and registers. */ stg_ctoi_t @@ -402,7 +392,7 @@ stg_ctoi_t Sp = Sp - WDS(tuple_stack); - PUSH_TUPLE_REGS(tuple_info); + PUSH_ARG_REGS(tuple_info); /* jump to the BCO that will finish the return of the tuple */ Sp_adj(-3); @@ -423,13 +413,57 @@ INFO_TABLE_RET( stg_ret_t, RET_BCO ) /* number of words spilled on stack */ tuple_stack = (tuple_info >> 24) & 0xff; - POP_TUPLE_REGS(tuple_info); + POP_ARG_REGS(tuple_info); /* Sp points to the topmost argument now */ jump %ENTRY_CODE(Sp(tuple_stack)) [*]; // NB. all registers live! } + /* + + The stg_primcall frame is used by the bytecode interpreter to call + a Cmm function. The frame contains a call_info word that contains + a bitmap describing the register arguments. + + When the target function is called, Sp points to the topmost stack + argument. + + ... + next_stack_frame + arg_1 + arg_2 + ... + arg_n + target_funptr (pointer to the function we're calling) + call_info (describes the registers containing the arguments) + primcall_BCO (contains bitmap describing pointers in args) + stg_primcall_info <- Sp + + See Note [GHCi and native call registers] for information on the call_info + word and how registers are moved between the stack and registers. + + */ + +INFO_TABLE_RET ( stg_primcall, RET_BCO ) +{ + W_ args_info, prim_fun; + + /* Sp(1) would be the BCO containing the stack description bitmap */ + args_info = Sp(2); + prim_fun = Sp(3); + + Sp_adj(4); + + /* Sp points to the top of the register arguments now, + load them into actual registers */ + POP_ARG_REGS(args_info); + + /* Sp points to the topmost stack argument now */ + + jump prim_fun [*]; // NB. all registers live! +} + /* * Dummy info table pushed on the top of the stack when the interpreter * should apply the BCO on the stack to its arguments, also on the ===================================== rts/include/rts/Bytecodes.h ===================================== @@ -112,6 +112,8 @@ #define bci_TESTLT_W8 85 #define bci_TESTEQ_W8 86 +#define bci_PRIMCALL 87 + /* If you need to go past 255 then you will run into the flags */ /* If you need to go below 0x0100 then you will run into the instructions */ ===================================== rts/include/stg/MiscClosures.h ===================================== @@ -160,6 +160,7 @@ RTS_RET(stg_ctoi_t60); RTS_RET(stg_ctoi_t61); RTS_RET(stg_ctoi_t62); +RTS_RET(stg_primcall); RTS_RET(stg_apply_interp); RTS_RET(stg_dead_thread); ===================================== testsuite/tests/ghci/prog014/prog014.T ===================================== @@ -1,6 +1,5 @@ test('prog014', [extra_files(['Primop.hs', 'dummy.c']), - expect_fail, # bytecode compiler doesn't support foreign import prim extra_run_opts('dummy.o'), pre_cmd('$MAKE -s --no-print-directory prog014')], ghci_script, ['prog014.script']) ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs ===================================== @@ -0,0 +1,224 @@ +{-# LANGUAGE ForeignFunctionInterface, GHCForeignImportPrim, UnliftedFFITypes, MagicHash, UnboxedTuples #-} + +module Main where + +import GHC.Int +import GHC.Word +import GHC.Prim +import GHC.Exts +import GHC.Types +import Unsafe.Coerce +import GHC.IO + +data Box (a :: UnliftedType) = MkBox a + +i2a :: Int -> Any +i2a = unsafeCoerce + +a2i :: Any -> Int +a2i = unsafeCoerce + +main :: IO () +main = do + + let i8s :: [Int8] + i8s = [0, -1, 1, minBound, maxBound] + + i16s :: [Int16] + i16s = [0, -1, 1, minBound, maxBound] + + i32s :: [Int32] + i32s = [0, -1, 1, minBound, maxBound] + + i64s :: [Int64] + i64s = [0, -1, 1, minBound, maxBound] + + ws :: [Word] + ws = [0, 1, 2, maxBound] + + fs :: [Float] + fs = [-0, 0, -1, 1, -2, 2, 1/0, 1e37, -1e-37] + + ds :: [Double] + ds = [-0, 0, -1, 1, -2, 2, 1/0, 1e307, -1e-307] + + ls :: [Word64] + ls = [0, 1, 2, 4294967296, maxBound] + + mi2a :: Maybe Integer -> Any + mi2a = unsafeCoerce + + a2mi :: Any -> Maybe Integer + a2mi = unsafeCoerce + + a0, a1, a2, a3 :: Any + a0 = mi2a Nothing + a1 = mi2a (Just 1) + a2 = mi2a (Just 18446744073709551617) + a3 = mi2a (Just (-18446744073709551617)) + + as :: [Any] + as = [a0, a1, a2, a3] + + + putStrLn "zero arguments" + IO (\st -> case cmm_zero st of (# st' #) -> (# st', () #)) + print =<< IO (\st -> case cmm_zero_w st of (# st', w #) -> (# st', W# w #)) + print =<< IO (\st -> case cmm_zero_d st of (# st', w #) -> (# st', D# w #)) + print =<< IO (\st -> case cmm_zero_f st of (# st', w #) -> (# st', F# w #)) + + -- XXX zero argument functions + + putStrLn "one argument functions" + print [ I8# (cmm_one1_i8 x) | (I8# x) <- i8s ] + print [ I16# (cmm_one1_i16 x) | (I16# x) <- i16s ] + print [ I32# (cmm_one1_i32 x) | (I32# x) <- i32s ] + print [ I64# (cmm_one1_i64 x) | (I64# x) <- i64s ] + print [ case cmm_one1_p x of (# y #) -> a2mi y | x <- as ] + print [ W# (cmm_one1_w x) | (W# x) <- ws ] + print [ F# (cmm_one1_f x) | (F# x) <- fs ] + print [ D# (cmm_one1_d x) | (D# x) <- ds ] + print [ W64# (cmm_one1_l x) | (W64# x) <- ls ] + + print [ case cmm_one2_i8 x of (# y1, y2 #) -> (I8# y1, I8# y2) | (I8# x) <- i8s ] + print [ case cmm_one2_i16 x of (# y1, y2 #) -> (I16# y1, I16# y2) | (I16# x) <- i16s ] + print [ case cmm_one2_i32 x of (# y1, y2 #) -> (I32# y1, I32# y2) | (I32# x) <- i32s ] + print [ case cmm_one2_i64 x of (# y1, y2 #) -> (I64# y1, I64# y2) | (I64# x) <- i64s ] + print [ case cmm_one2_p x of (# y1, y2 #) -> (a2mi y1, a2mi y2) | x <- as ] + print [ case cmm_one2_w x of (# y1, y2 #) -> (W# y1, W# y2) | (W# x) <- ws ] + print [ case cmm_one2_f x of (# y1, y2 #) -> (F# y1, F# y2) | (F# x) <- fs ] + print [ case cmm_one2_d x of (# y1, y2 #) -> (D# y1, D# y2) | (D# x) <- ds ] + print [ case cmm_one2_l x of (# y1, y2 #) -> (W64# y1, W64# y2) | (W64# x) <- ls ] + + putStrLn "two argument functions" + print [ I8# (cmm_two1_i8 x1 x2) | (I8# x1) <- i8s, (I8# x2) <- i8s ] + print [ I16# (cmm_two1_i16 x1 x2) | (I16# x1) <- i16s, (I16# x2) <- i16s ] + print [ I32# (cmm_two1_i32 x1 x2) | (I32# x1) <- i32s, (I32# x2) <- i32s ] + print [ I64# (cmm_two1_i64 x1 x2) | (I64# x1) <- i64s, (I64# x2) <- i64s ] + print [ case cmm_two1_p x1 x2 of (# y #) -> a2mi y | x1 <- as, x2 <- as ] + print [ W# (cmm_two1_w x1 x2) | (W# x1) <- ws, (W# x2) <- ws ] + print [ F# (cmm_two1_f x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_two1_d x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ W64# (cmm_two1_l x1 x2) | (W64# x1) <- ls, (W64# x2) <- ls ] + + print [ I8# (cmm_two2_i8 x1 x2) | (I8# x1) <- i8s, (I8# x2) <- i8s ] + print [ I16# (cmm_two2_i16 x1 x2) | (I16# x1) <- i16s, (I16# x2) <- i16s ] + print [ I32# (cmm_two2_i32 x1 x2) | (I32# x1) <- i32s, (I32# x2) <- i32s ] + print [ I64# (cmm_two2_i64 x1 x2) | (I64# x1) <- i64s, (I64# x2) <- i64s ] + print [ case cmm_two2_p x1 x2 of (# y #) -> a2mi y | x1 <- as, x2 <- as ] + print [ W# (cmm_two2_w x1 x2) | (W# x1) <- ws, (W# x2) <- ws ] + print [ F# (cmm_two2_f x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_two2_d x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ W64# (cmm_two2_l x1 x2) | (W64# x1) <- ls, (W64# x2) <- ls ] + + putStrLn "additional floating point tests" + print [ F# (cmm_floating_1 x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_floating_2 x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ F# (cmm_floating_3 x1 x2) | (F# x1) <- fs, (D# x2) <- ds ] + print [ D# (cmm_floating_4 x1 x2) | (F# x1) <- fs, (D# x2) <- ds ] + print [ case cmm_floating_5 x1 x2 3.0e1# 4.0e2## 5.0e3# 6.0e4## 7.0e5# 8.0e6## of (# y1, y2 #) -> (F# y1, D# y2) + | (F# x1) <- fs, (D# x2) <- ds ] + print [ case cmm_floating_6 x1 x2 3.0e1## 4.0e2# 5.0e3## 6.0e4# 7.0e5## 8.0e6# of (# y1, y2 #) -> (D# y1, F# y2) + | (D# x1) <- ds, (F# x2) <- fs ] + print [ case cmm_floating_7 w1 x1 x2 + 4## 5.0e1# 6.0e2## + 7## 8.0e3# 9.0e4## + 10## 11.0e5# 12.0e6## + 13## 14.0e7# 15.0e8## + 16## 17.0e9# 18.0e10## + 19## 20.0e11# 21.0e12## of (# y1, y2, y3 #) -> (W# y1, F# y2, D# y3) + | (W# w1) <- ws, (F# x1) <- fs, (D# x2) <- ds ] + + putStrLn "various sized tuple returns" + print [ case cmm_tuple_1 x1 x2 3## of (# y1, y2, y3 #) -> (W# y1, W# y2, W# y3) | (W# x1) <- ws, (W# x2) <- ws] + print [ case cmm_tuple_2 x1 x2 3## 4## a0 a1 7.0## 8.0## a2 a3 11.0# 12.0# + of (# y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12 #) -> + (F# y1, F# y2, a2mi y3, a2mi y4, D# y5, D# y6, a2mi y7, a2mi y8, W# y9, W# y10, a2mi y11, a2mi y12) + | x1 <- as, x2 <- as ] + print [ case cmm_tuple_3 x1 x2 a0 3.0## a1 5.0# + of (# y1, y2, y3, y4, y5, y6 #) -> (F# y1, a2mi y2, D# y3, a2mi y4, W# y5, a2mi y6) + | x1 <- as, (W# x2) <- ws ] + print [ case cmm_tuple_4 x1 x2 of (# y1, y2 #) -> (a2mi y1, a2mi y2) | x1 <- as, x2 <- as ] + + putStrLn "arrays" + MkBox marr0 <- IO (\s -> case newArray# 10# a0 s of (# s', a #) -> (# s', MkBox a #)) + MkBox marr1 <- IO (\s -> case newArray# 12# a1 s of (# s', a #) -> (# s', MkBox a #)) + MkBox arr0 <- IO (\s -> case unsafeFreezeArray# marr0 s of (# s', a #) -> (# s', MkBox a #)) + MkBox arr1 <- IO (\s -> case unsafeFreezeArray# marr1 s of (# s', a #) -> (# s', MkBox a #)) + print (I# (cmm_array_1 arr0), I# (cmm_array_1 arr1)) + case cmm_array_2 arr0 arr1 of (# arr2, arr3 #) -> print (I# (cmm_array_1 arr2), I# (cmm_array_1 arr3)) + + +-- XXX why don't we accept State# RealWorld -> State# RealWorld ? +foreign import prim cmm_zero :: State# RealWorld -> (# State# RealWorld #) +foreign import prim cmm_zero_w :: State# RealWorld -> (# State# RealWorld, Word# #) +foreign import prim cmm_zero_d :: State# RealWorld -> (# State# RealWorld, Double# #) +foreign import prim cmm_zero_f :: State# RealWorld -> (# State# RealWorld, Float# #) + +-- one argument functions +foreign import prim cmm_one1_i8 :: Int8# -> Int8# +foreign import prim cmm_one1_i16 :: Int16# -> Int16# +foreign import prim cmm_one1_i32 :: Int32# -> Int32# +foreign import prim cmm_one1_i64 :: Int64# -> Int64# +foreign import prim cmm_one1_p :: Any -> (# Any #) +foreign import prim cmm_one1_w :: Word# -> Word# +foreign import prim cmm_one1_f :: Float# -> Float# +foreign import prim cmm_one1_d :: Double# -> Double# +foreign import prim cmm_one1_l :: Word64# -> Word64# + +foreign import prim cmm_one2_i8 :: Int8# -> (# Int8#, Int8# #) +foreign import prim cmm_one2_i16 :: Int16# -> (# Int16#, Int16# #) +foreign import prim cmm_one2_i32 :: Int32# -> (# Int32#, Int32# #) +foreign import prim cmm_one2_i64 :: Int64# -> (# Int64#, Int64# #) +foreign import prim cmm_one2_p :: Any -> (# Any, Any #) +foreign import prim cmm_one2_w :: Word# -> (# Word#, Word# #) +foreign import prim cmm_one2_f :: Float# -> (# Float#, Float# #) +foreign import prim cmm_one2_d :: Double# -> (# Double#, Double# #) +foreign import prim cmm_one2_l :: Word64# -> (# Word64#, Word64# #) + +-- two argument functions +foreign import prim cmm_two1_i8 :: Int8# -> Int8# -> Int8# +foreign import prim cmm_two1_i16 :: Int16# -> Int16# -> Int16# +foreign import prim cmm_two1_i32 :: Int32# -> Int32# -> Int32# +foreign import prim cmm_two1_i64 :: Int64# -> Int64# -> Int64# +foreign import prim cmm_two1_p :: Any -> Any -> (# Any #) +foreign import prim cmm_two1_w :: Word# -> Word# -> Word# +foreign import prim cmm_two1_f :: Float# -> Float# -> Float# +foreign import prim cmm_two1_d :: Double# -> Double# -> Double# +foreign import prim cmm_two1_l :: Word64# -> Word64# -> Word64# + +foreign import prim cmm_two2_i8 :: Int8# -> Int8# -> Int8# +foreign import prim cmm_two2_i16 :: Int16# -> Int16# -> Int16# +foreign import prim cmm_two2_i32 :: Int32# -> Int32# -> Int32# +foreign import prim cmm_two2_i64 :: Int64# -> Int64# -> Int64# +foreign import prim cmm_two2_p :: Any -> Any -> (# Any #) +foreign import prim cmm_two2_w :: Word# -> Word# -> Word# +foreign import prim cmm_two2_f :: Float# -> Float# -> Float# +foreign import prim cmm_two2_d :: Double# -> Double# -> Double# +foreign import prim cmm_two2_l :: Word64# -> Word64# -> Word64# + +{- additional tests for floating point, since D_ and F_ registers + overlap on some platforms -} + +foreign import prim cmm_floating_1 :: Float# -> Float# -> Float# +foreign import prim cmm_floating_2 :: Double# -> Double# -> Double# +foreign import prim cmm_floating_3 :: Float# -> Double# -> Float# +foreign import prim cmm_floating_4 :: Float# -> Double# -> Double# +foreign import prim cmm_floating_5 :: Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> (# Float#, Double# #) +foreign import prim cmm_floating_6 :: Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> (# Double#, Float# #) +foreign import prim cmm_floating_7 :: Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> (# Word#, Float#, Double# #) +-- various sized tuple returns + +foreign import prim cmm_tuple_1 :: Word# -> Word# -> Word# -> (# Word# , Word#, Word# #) +foreign import prim cmm_tuple_2 :: Any -> Any -> Word# -> Word# -> Any -> Any -> Double# -> Double# -> Any -> Any -> Float# -> Float# -> + (# Float#, Float#, Any, Any, Double#, Double#, Any, Any, Word#, Word#, Any, Any #) +foreign import prim cmm_tuple_3 :: Any -> Word# -> Any -> Double# -> Any -> Float# -> + (# Float#, Any, Double#, Any, Word#, Any #) +foreign import prim cmm_tuple_4 :: Any -> Any -> (# Any, Any #) + +-- boxed primitive types + +-- get the length of an array +foreign import prim cmm_array_1 :: Array# Any -> Int# +-- return some arrays +foreign import prim cmm_array_2 :: Array# Any -> Array# Any -> (# Array# Any, Array# Any #) ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout ===================================== @@ -0,0 +1,58 @@ +zero arguments +123 +1.0 +1.0 +one argument functions +[0,-1,1,-128,127] +[0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,18446744073709551615] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615] +[(0,0),(-1,-1),(1,1),(-128,-128),(127,127)] +[(0,0),(-1,-1),(1,1),(-32768,-32768),(32767,32767)] +[(0,0),(-1,-1),(1,1),(-2147483648,-2147483648),(2147483647,2147483647)] +[(0,0),(-1,-1),(1,1),(-9223372036854775808,-9223372036854775808),(9223372036854775807,9223372036854775807)] +[(Nothing,Nothing),(Just 1,Just 1),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just (-18446744073709551617))] +[(0,0),(1,1),(2,2),(18446744073709551615,18446744073709551615)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e37,1.0e37),(-1.0e-37,-1.0e-37)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e307,1.0e307),(-1.0e-307,-1.0e-307)] +[(0,0),(1,1),(2,2),(4294967296,4294967296),(18446744073709551615,18446744073709551615)] +two argument functions +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-128,-128,-128,-128,-128,127,127,127,127,127] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-32768,-32768,-32768,-32768,-32768,32767,32767,32767,32767,32767] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,2147483647,2147483647,2147483647,2147483647,2147483647] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807] +[Nothing,Nothing,Nothing,Nothing,Just 1,Just 1,Just 1,Just 1,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617)] +[0,0,0,0,1,1,1,1,2,2,2,2,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307] +[0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,4294967296,4294967296,4294967296,4294967296,4294967296,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127] +[0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,18446744073709551615,0,1,2,18446744073709551615,0,1,2,18446744073709551615,0,1,2,18446744073709551615] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615] +additional floating point tests +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e37,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e37,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e37,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e37,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,Infinity,2.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-2.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e307,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e307,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e307,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e307,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,Infinity,2.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-2.0e-307] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e307),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e307),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e307),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e307),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e307),(Infinity,8060400.0),(1.0e37,8060400.0),(1.0e37,8060400.0),(1.0e37,8060399.0),(1.0e37,8060401.0),(1.0e37,8060398.0),(1.0e37,8060402.0),(1.0e37,Infinity),(1.0e37,1.0e307),(1.0e37,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0)] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e37),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e37),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e37),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e37),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e37),(Infinity,8060400.0),(1.0e307,8060400.0),(1.0e307,8060400.0),(1.0e307,8060399.0),(1.0e307,8060401.0),(1.0e307,8060398.0),(1.0e307,8060402.0),(1.0e307,Infinity),(1.0e307,1.0e37),(1.0e307,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0)] +[(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.1181512090599e13),(69,Infinity,2.1181512090601e13),(69,Infinity,2.1181512090598e13),(69,Infinity,2.1181512090602e13),(69,Infinity,Infinity),(69,Infinity,1.0e307),(69,Infinity,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.1181512090599e13),(69,1.0e37,2.1181512090601e13),(69,1.0e37,2.1181512090598e13),(69,1.0e37,2.1181512090602e13),(69,1.0e37,Infinity),(69,1.0e37,1.0e307),(69,1.0e37,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.1181512090599e13),(70,Infinity,2.1181512090601e13),(70,Infinity,2.1181512090598e13),(70,Infinity,2.1181512090602e13),(70,Infinity,Infinity),(70,Infinity,1.0e307),(70,Infinity,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.1181512090599e13),(70,1.0e37,2.1181512090601e13),(70,1.0e37,2.1181512090598e13),(70,1.0e37,2.1181512090602e13),(70,1.0e37,Infinity),(70,1.0e37,1.0e307),(70,1.0e37,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.1181512090599e13),(71,Infinity,2.1181512090601e13),(71,Infinity,2.1181512090598e13),(71,Infinity,2.1181512090602e13),(71,Infinity,Infinity),(71,Infinity,1.0e307),(71,Infinity,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.1181512090599e13),(71,1.0e37,2.1181512090601e13),(71,1.0e37,2.1181512090598e13),(71,1.0e37,2.1181512090602e13),(71,1.0e37,Infinity),(71,1.0e37,1.0e307),(71,1.0e37,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.1181512090599e13),(68,Infinity,2.1181512090601e13),(68,Infinity,2.1181512090598e13),(68,Infinity,2.1181512090602e13),(68,Infinity,Infinity),(68,Infinity,1.0e307),(68,Infinity,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.1181512090599e13),(68,1.0e37,2.1181512090601e13),(68,1.0e37,2.1181512090598e13),(68,1.0e37,2.1181512090602e13),(68,1.0e37,Infinity),(68,1.0e37,1.0e307),(68,1.0e37,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13)] +various sized tuple returns +[(3,0,0),(3,1,0),(3,2,0),(3,18446744073709551615,0),(3,0,1),(3,1,1),(3,2,1),(3,18446744073709551615,1),(3,0,2),(3,1,2),(3,2,2),(3,18446744073709551615,2),(3,0,18446744073709551615),(3,1,18446744073709551615),(3,2,18446744073709551615),(3,18446744073709551615,18446744073709551615)] +[(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just (-18446744073709551617))] +[(5.0,Just 1,3.0,Nothing,0,Nothing),(5.0,Just 1,3.0,Nothing,1,Nothing),(5.0,Just 1,3.0,Nothing,2,Nothing),(5.0,Just 1,3.0,Nothing,18446744073709551615,Nothing),(5.0,Just 1,3.0,Nothing,0,Just 1),(5.0,Just 1,3.0,Nothing,1,Just 1),(5.0,Just 1,3.0,Nothing,2,Just 1),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just 1),(5.0,Just 1,3.0,Nothing,0,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,1,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,2,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,0,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,1,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,2,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just (-18446744073709551617))] +[(Nothing,Nothing),(Just 1,Nothing),(Just 18446744073709551617,Nothing),(Just (-18446744073709551617),Nothing),(Nothing,Just 1),(Just 1,Just 1),(Just 18446744073709551617,Just 1),(Just (-18446744073709551617),Just 1),(Nothing,Just 18446744073709551617),(Just 1,Just 18446744073709551617),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just 18446744073709551617),(Nothing,Just (-18446744073709551617)),(Just 1,Just (-18446744073709551617)),(Just 18446744073709551617,Just (-18446744073709551617)),(Just (-18446744073709551617),Just (-18446744073709551617))] +arrays +(11,13) +(13,11) ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout-ws-32 ===================================== @@ -0,0 +1,58 @@ +zero arguments +123 +1.0 +1.0 +one argument functions +[0,-1,1,-128,127] +[0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,4294967295] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615] +[(0,0),(-1,-1),(1,1),(-128,-128),(127,127)] +[(0,0),(-1,-1),(1,1),(-32768,-32768),(32767,32767)] +[(0,0),(-1,-1),(1,1),(-2147483648,-2147483648),(2147483647,2147483647)] +[(0,0),(-1,-1),(1,1),(-9223372036854775808,-9223372036854775808),(9223372036854775807,9223372036854775807)] +[(Nothing,Nothing),(Just 1,Just 1),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just (-18446744073709551617))] +[(0,0),(1,1),(2,2),(4294967295,4294967295)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e37,1.0e37),(-1.0e-37,-1.0e-37)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e307,1.0e307),(-1.0e-307,-1.0e-307)] +[(0,0),(1,1),(2,2),(4294967296,4294967296),(18446744073709551615,18446744073709551615)] +two argument functions +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-128,-128,-128,-128,-128,127,127,127,127,127] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-32768,-32768,-32768,-32768,-32768,32767,32767,32767,32767,32767] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,2147483647,2147483647,2147483647,2147483647,2147483647] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807] +[Nothing,Nothing,Nothing,Nothing,Just 1,Just 1,Just 1,Just 1,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617)] +[0,0,0,0,1,1,1,1,2,2,2,2,4294967295,4294967295,4294967295,4294967295] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307] +[0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,4294967296,4294967296,4294967296,4294967296,4294967296,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127] +[0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,4294967295,0,1,2,4294967295,0,1,2,4294967295,0,1,2,4294967295] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615] +additional floating point tests +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e37,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e37,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e37,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e37,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,Infinity,2.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-2.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e307,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e307,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e307,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e307,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,Infinity,2.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-2.0e-307] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e307),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e307),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e307),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e307),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e307),(Infinity,8060400.0),(1.0e37,8060400.0),(1.0e37,8060400.0),(1.0e37,8060399.0),(1.0e37,8060401.0),(1.0e37,8060398.0),(1.0e37,8060402.0),(1.0e37,Infinity),(1.0e37,1.0e307),(1.0e37,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0)] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e37),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e37),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e37),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e37),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e37),(Infinity,8060400.0),(1.0e307,8060400.0),(1.0e307,8060400.0),(1.0e307,8060399.0),(1.0e307,8060401.0),(1.0e307,8060398.0),(1.0e307,8060402.0),(1.0e307,Infinity),(1.0e307,1.0e37),(1.0e307,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0)] +[(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.1181512090599e13),(69,Infinity,2.1181512090601e13),(69,Infinity,2.1181512090598e13),(69,Infinity,2.1181512090602e13),(69,Infinity,Infinity),(69,Infinity,1.0e307),(69,Infinity,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.1181512090599e13),(69,1.0e37,2.1181512090601e13),(69,1.0e37,2.1181512090598e13),(69,1.0e37,2.1181512090602e13),(69,1.0e37,Infinity),(69,1.0e37,1.0e307),(69,1.0e37,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.1181512090599e13),(70,Infinity,2.1181512090601e13),(70,Infinity,2.1181512090598e13),(70,Infinity,2.1181512090602e13),(70,Infinity,Infinity),(70,Infinity,1.0e307),(70,Infinity,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.1181512090599e13),(70,1.0e37,2.1181512090601e13),(70,1.0e37,2.1181512090598e13),(70,1.0e37,2.1181512090602e13),(70,1.0e37,Infinity),(70,1.0e37,1.0e307),(70,1.0e37,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.1181512090599e13),(71,Infinity,2.1181512090601e13),(71,Infinity,2.1181512090598e13),(71,Infinity,2.1181512090602e13),(71,Infinity,Infinity),(71,Infinity,1.0e307),(71,Infinity,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.1181512090599e13),(71,1.0e37,2.1181512090601e13),(71,1.0e37,2.1181512090598e13),(71,1.0e37,2.1181512090602e13),(71,1.0e37,Infinity),(71,1.0e37,1.0e307),(71,1.0e37,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.1181512090599e13),(68,Infinity,2.1181512090601e13),(68,Infinity,2.1181512090598e13),(68,Infinity,2.1181512090602e13),(68,Infinity,Infinity),(68,Infinity,1.0e307),(68,Infinity,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.1181512090599e13),(68,1.0e37,2.1181512090601e13),(68,1.0e37,2.1181512090598e13),(68,1.0e37,2.1181512090602e13),(68,1.0e37,Infinity),(68,1.0e37,1.0e307),(68,1.0e37,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13)] +various sized tuple returns +[(3,0,0),(3,1,0),(3,2,0),(3,4294967295,0),(3,0,1),(3,1,1),(3,2,1),(3,4294967295,1),(3,0,2),(3,1,2),(3,2,2),(3,4294967295,2),(3,0,4294967295),(3,1,4294967295),(3,2,4294967295),(3,4294967295,4294967295)] +[(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just (-18446744073709551617))] +[(5.0,Just 1,3.0,Nothing,0,Nothing),(5.0,Just 1,3.0,Nothing,1,Nothing),(5.0,Just 1,3.0,Nothing,2,Nothing),(5.0,Just 1,3.0,Nothing,4294967295,Nothing),(5.0,Just 1,3.0,Nothing,0,Just 1),(5.0,Just 1,3.0,Nothing,1,Just 1),(5.0,Just 1,3.0,Nothing,2,Just 1),(5.0,Just 1,3.0,Nothing,4294967295,Just 1),(5.0,Just 1,3.0,Nothing,0,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,1,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,2,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,4294967295,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,0,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,1,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,2,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,4294967295,Just (-18446744073709551617))] +[(Nothing,Nothing),(Just 1,Nothing),(Just 18446744073709551617,Nothing),(Just (-18446744073709551617),Nothing),(Nothing,Just 1),(Just 1,Just 1),(Just 18446744073709551617,Just 1),(Just (-18446744073709551617),Just 1),(Nothing,Just 18446744073709551617),(Just 1,Just 18446744073709551617),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just 18446744073709551617),(Nothing,Just (-18446744073709551617)),(Just 1,Just (-18446744073709551617)),(Just 18446744073709551617,Just (-18446744073709551617)),(Just (-18446744073709551617),Just (-18446744073709551617))] +arrays +(11,13) +(13,11) ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm ===================================== @@ -0,0 +1,145 @@ +#include "Cmm.h" + +/* zero arguments */ +cmm_zero() { /* ccall puts("cmm_zero"); buffering gets in the way */ return (); } +cmm_zero_w() { return (123::W_); } +cmm_zero_d() { return (1.0::D_); } +cmm_zero_f() { return (1.0::F_); } +cmm_zero_l() { return (123::L_); } + +/* one argument functions */ +cmm_one1_i8(I8 x) { return (x); } +cmm_one1_i16(I16 x) { return (x); } +cmm_one1_i32(I32 x) { return (x); } +cmm_one1_i64(I64 x) { return (x); } +cmm_one1_p(P_ x) { return (x); } +cmm_one1_w(W_ x) { return (x); } +cmm_one1_f(F_ x) { return (x); } +cmm_one1_d(D_ x) { return (x); } +cmm_one1_l(L_ x) { return (x); } + +cmm_one2_i8(I8 x) { return (x,x); } +cmm_one2_i16(I16 x) { return (x,x); } +cmm_one2_i32(I32 x) { return (x,x); } +cmm_one2_i64(I64 x) { return (x,x); } +cmm_one2_p(P_ x) { return (x,x); } +cmm_one2_w(W_ x) { return (x,x); } +cmm_one2_f(F_ x) { return (x,x); } +cmm_one2_d(D_ x) { return (x,x); } +cmm_one2_l(L_ x) { return (x,x); } + + +/* two argument functions */ +cmm_two1_i8(I8 x, I8 y) { return (x); } +cmm_two1_i16(I16 x, I16 y) { return (x); } +cmm_two1_i32(I32 x, I32 y) { return (x); } +cmm_two1_i64(I64 x, I64 y) { return (x); } +cmm_two1_p(P_ x, P_ y) { return (x); } +cmm_two1_w(W_ x, W_ y) { return (x); } +cmm_two1_f(F_ x, F_ y) { return (x); } +cmm_two1_d(D_ x, D_ y) { return (x); } +cmm_two1_l(L_ x, L_ y) { return (x); } + +cmm_two2_i8(I8 x, I8 y) { return (y); } +cmm_two2_i16(I16 x, I16 y) { return (y); } +cmm_two2_i32(I32 x, I32 y) { return (y); } +cmm_two2_i64(I64 x, I64 y) { return (y); } +cmm_two2_p(P_ x, P_ y) { return (y); } +cmm_two2_w(W_ x, W_ y) { return (y); } +cmm_two2_f(F_ x, F_ y) { return (y); } +cmm_two2_d(D_ x, D_ y) { return (y); } +cmm_two2_l(L_ x, L_ y) { return (y); } + +/* additional tests for floating point, since D_ and F_ registers + overlap on some platforms */ +cmm_floating_1(F_ x, F_ y) { F_ z; z = %fadd(x, y); return (z); } +cmm_floating_2(D_ x, D_ y) { D_ z; z = %fadd(x, y); return (z); } +cmm_floating_3(F_ x, D_ y) { return (x); } +cmm_floating_4(F_ x, D_ y) { return (y); } + + +cmm_floating_5(F_ x1, D_ x2, F_ x3, D_ x4, F_ x5, D_ x6, F_ x7, D_ x8) { + F_ y1; + D_ y2; + + y1 = %fadd(x1,x3); + y1 = %fadd(y1,x5); + y1 = %fadd(y1,x7); + + y2 = %fadd(x2,x4); + y2 = %fadd(y2,x6); + y2 = %fadd(y2,x8); + + return (y1, y2); +} + + +cmm_floating_6(D_ x1, F_ x2, D_ x3, F_ x4, D_ x5, F_ x6, D_ x7, F_ x8) { + D_ y1; + F_ y2; + + y1 = %fadd(x1,x3); + y1 = %fadd(y1,x5); + y1 = %fadd(y1,x7); + + y2 = %fadd(x2,x4); + y2 = %fadd(y2,x6); + y2 = %fadd(y2,x8); + + return (y1, y2); +} + + +cmm_floating_7( W_ x1, F_ x2, D_ x3 + , W_ x4, F_ x5, D_ x6 + , W_ x7, F_ x8, D_ x9 + , W_ x10, F_ x11, D_ x12 + , W_ x13, F_ x14, D_ x15 + , W_ x16, F_ x17, D_ x18 + , W_ x19, F_ x20, D_ x21 + ) { + W_ y1; + F_ y2; + D_ y3; + y1 = x1+x4+x7+x10+x13+x16+x19; + + y2 = %fadd(x2,x5); + y2 = %fadd(y2,x8); + y2 = %fadd(y2,x11); + y2 = %fadd(y2,x14); + y2 = %fadd(y2,x17); + y2 = %fadd(y2,x20); + + y3 = %fadd(x3,x6); + y3 = %fadd(y3,x9); + y3 = %fadd(y3,x12); + y3 = %fadd(y3,x15); + y3 = %fadd(y3,x18); + y3 = %fadd(y3,x21); + + return ( y1, y2, y3 ); +} + + +/* various sized tuple returns */ + +cmm_tuple_1(W_ x, W_ y, W_ z) { return (z, y, x); } +cmm_tuple_2(P_ p1, P_ p2, W_ w1, W_ w2, P_ p3, P_ p4, D_ d1, D_ d2, P_ p5, P_ p6, F_ f1, F_ f2) { + return (f2, f1, p6, p5, d2, d1, p4, p3, w2, w1, p2, p1); +} +cmm_tuple_3(P_ p1, W_ w1, P_ p2, D_ d1, P_ p3, F_ f1) { + return (f1, p3, d1, p2, w1, p1); +} +cmm_tuple_4(P_ p1, P_ p2) { return (p2, p1); } + +/* working with arrays */ +cmm_array_1(P_ x) { + W_ size; + size = StgMutArrPtrs_size(x); + return (size); +} + +/* return two arrays */ +cmm_array_2(P_ x, P_ y) { + return (y, x); +} ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile ===================================== @@ -0,0 +1,4 @@ +.PHONY: GHCiPrimCall +GHCiPrimCall: + '$(TEST_HC)' $(TEST_HC_OPTS) -fPIC -v0 -c GHCiPrimCall_cmm.cmm + -'$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -e main GHCiPrimCall.hs GHCiPrimCall_cmm.o || echo $$? >&2 ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/all.T ===================================== @@ -0,0 +1,2 @@ +test('GHCiPrimCall', [req_interp], makefile_test, ['GHCiPrimCall']) + ===================================== testsuite/tests/printer/HsDocTy.hs ===================================== @@ -0,0 +1,6 @@ +{-# OPTIONS_GHC -haddock #-} +module HsDocTy where + +class C1 a where + f1 :: a -> Int + -- ^ comment on Int ===================================== testsuite/tests/printer/Makefile ===================================== @@ -769,3 +769,9 @@ Test21355: Test21805: $(CHECK_PPR) $(LIBDIR) Test21805.hs $(CHECK_EXACT) $(LIBDIR) Test21805.hs + +.PHONY: HsDocTy +HsDocTy: + # See comment on pprWithDocString, this won't round trip + # $(CHECK_PPR) $(LIBDIR) HsDocTy.hs + $(CHECK_EXACT) $(LIBDIR) HsDocTy.hs ===================================== testsuite/tests/printer/all.T ===================================== @@ -185,4 +185,5 @@ test('Test21805', [ignore_stderr, req_ppr_deps], makefile_test, ['Test21805']) test('T22488', normal, ghci_script, ['T22488.script']) test('T22488_docHead', normal, compile_and_run, ['-package ghc']) test('T20531', extra_files(['T20531_defs.hs']), ghci_script, ['T20531.script']) -test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) \ No newline at end of file +test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) +test('HsDocTy', [ignore_stderr, req_ppr_deps], makefile_test, ['HsDocTy']) \ No newline at end of file ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -3898,6 +3898,10 @@ instance ExactPrint (HsType GhcPs) where exact (HsSpliceTy a splice) = do splice' <- markAnnotated splice return (HsSpliceTy a splice') + exact (HsDocTy an ty doc) = do + ty' <- markAnnotated ty + doc' <- markAnnotated doc + return (HsDocTy an ty' doc') exact (HsBangTy an (HsSrcBang mt up str) ty) = do an0 <- case mt of ===================================== utils/check-exact/Main.hs ===================================== @@ -59,7 +59,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../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) - "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) + -- "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3a.hs" (Just changeWhereIn3a) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3b.hs" (Just changeWhereIn3b) -- "../../testsuite/tests/ghc-api/exactprint/AddLocalDecl1.hs" (Just addLocaLDecl1) @@ -203,6 +203,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../testsuite/tests/ghc-api/exactprint/Test20239.hs" Nothing -- "../../testsuite/tests/printer/PprArrowLambdaCase.hs" Nothing -- "../../testsuite/tests/printer/Test16279.hs" Nothing + "../../testsuite/tests/printer/HsDocTy.hs" Nothing -- cloneT does not need a test, function can be retired View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/992606f2051629f53b6ab81163ed03dc3599b935...b3af454027b1ffd4444161d12f086349b4094945 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/992606f2051629f53b6ab81163ed03dc3599b935...b3af454027b1ffd4444161d12f086349b4094945 You're receiving 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 Jan 9 11:13:01 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 09 Jan 2023 06:13:01 -0500 Subject: [Git][ghc/ghc][wip/no_fixup_chains_2] 2 commits: Store bootstrap_llvm_target and use it to set LlvmTarget in bindists Message-ID: <63bbf6bdf2f03_136d98142d6b80311674@gitlab.mail> Matthew Pickering pushed to branch wip/no_fixup_chains_2 at Glasgow Haskell Compiler / GHC Commits: 8d62a0e1 by Matthew Pickering at 2023-01-09T11:12:53+00:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - e3669c95 by Matthew Pickering at 2023-01-09T11:12:53+00:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. - - - - - 3 changed files: - configure.ac - distrib/configure.ac.in - m4/ghc_llvm_target.m4 Changes: ===================================== configure.ac ===================================== @@ -667,6 +667,8 @@ GHC_LLVM_TARGET_SET_VAR # we intend to pass trough --targets to llvm as is. LLVMTarget_CPP=` echo "$LlvmTarget"` AC_SUBST(LLVMTarget_CPP) +# The target is substituted into the distrib/configure.ac file +AC_SUBST(LlvmTarget) dnl ** See whether cc supports --target= and set dnl CONF_CC_OPTS_STAGE[012] accordingly. ===================================== distrib/configure.ac.in ===================================== @@ -18,6 +18,8 @@ dnl-------------------------------------------------------------------- dnl Various things from the source distribution configure bootstrap_target=@TargetPlatform@ +bootstrap_llvm_target=@LlvmTarget@ + TargetHasRTSLinker=@TargetHasRTSLinker@ AC_SUBST(TargetHasRTSLinker) @@ -169,6 +171,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG # Stage 3 won't be supported by cross-compilation FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) +FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) +FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + AC_SUBST(CONF_CC_OPTS_STAGE0) AC_SUBST(CONF_CC_OPTS_STAGE1) AC_SUBST(CONF_CC_OPTS_STAGE2) ===================================== m4/ghc_llvm_target.m4 ===================================== @@ -50,5 +50,10 @@ AC_DEFUN([GHC_LLVM_TARGET], [ # require it. AC_DEFUN([GHC_LLVM_TARGET_SET_VAR], [ AC_REQUIRE([FPTOOLS_SET_PLATFORMS_VARS]) - GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + if test "$bootstrap_llvm_target" != "" + then + $5=$bootstrap_llvm_target + else + GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + fi ]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4c38ab8fefb355ccd25e6a6b0306ce4bf08d1287...e3669c95d66a4904f0ac1848a9565ad4cd634e45 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4c38ab8fefb355ccd25e6a6b0306ce4bf08d1287...e3669c95d66a4904f0ac1848a9565ad4cd634e45 You're receiving 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 Jan 9 11:33:51 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 09 Jan 2023 06:33:51 -0500 Subject: [Git][ghc/ghc][wip/T22718] Handle shadowing in DmdAnal (#22718) Message-ID: <63bbfb9f27fc2_3b1bf95260c4351@gitlab.mail> Sebastian Graf pushed to branch wip/T22718 at Glasgow Haskell Compiler / GHC Commits: eb366515 by Sebastian Graf at 2023-01-09T12:33:38+01:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. - - - - - 1 changed file: - compiler/GHC/Core/Opt/DmdAnal.hs Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -333,7 +333,8 @@ dmdAnalBindLetUp :: TopLevelFlag -> WithDmdType (DmdResult CoreBind a) dmdAnalBindLetUp top_lvl env id rhs anal_body = WithDmdType final_ty (R (NonRec id' rhs') (body')) where - WithDmdType body_ty body' = anal_body env + WithDmdType body_ty body' = anal_body (addInScopeAnalEnv env id) + -- See Note [Bringing a new variable into scope] WithDmdType body_ty' id_dmd = findBndrDmd env body_ty id -- See Note [Finalising boxity for demand signatures] @@ -473,7 +474,8 @@ dmdAnal' env dmd (App fun arg) dmdAnal' env dmd (Lam var body) | isTyVar var = let - WithDmdType body_ty body' = dmdAnal env dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) dmd body + -- See Note [Bringing a new variable into scope] in WithDmdType body_ty (Lam var body') @@ -481,7 +483,8 @@ dmdAnal' env dmd (Lam var body) = let (n, body_dmd) = peelCallDmd dmd -- body_dmd: a demand to analyze the body - WithDmdType body_ty body' = dmdAnal env body_dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) body_dmd body + -- See Note [Bringing a new variable into scope] WithDmdType lam_ty var' = annotateLamIdBndr env body_ty var new_dmd_type = multDmdType n lam_ty in @@ -493,7 +496,9 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt_con bndrs rhs]) -- can consider its field demands when analysing the scrutinee. | want_precise_field_dmds alt_con = let - WithDmdType rhs_ty rhs' = dmdAnal env dmd rhs + rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + WithDmdType rhs_ty rhs' = dmdAnal rhs_env dmd rhs WithDmdType alt_ty1 fld_dmds = findBndrsDmds env rhs_ty bndrs WithDmdType alt_ty2 case_bndr_dmd = findBndrDmd env alt_ty1 case_bndr !case_bndr' = setIdDemandInfo case_bndr case_bndr_dmd @@ -629,7 +634,9 @@ dmdAnalSumAlts env dmd case_bndr (alt:alts) dmdAnalSumAlt :: AnalEnv -> SubDemand -> Id -> CoreAlt -> WithDmdType CoreAlt dmdAnalSumAlt env dmd case_bndr (Alt con bndrs rhs) - | WithDmdType rhs_ty rhs' <- dmdAnal env dmd rhs + | let rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + , WithDmdType rhs_ty rhs' <- dmdAnal rhs_env dmd rhs , WithDmdType alt_ty dmds <- findBndrsDmds env rhs_ty bndrs , let (_ :* case_bndr_sd) = findIdDemand alt_ty case_bndr -- See Note [Demand on case-alternative binders] @@ -2399,7 +2406,7 @@ enterDFun bind env emptySigEnv :: SigEnv emptySigEnv = emptyVarEnv --- | Extend an environment with the strictness IDs attached to the id +-- | Extend an environment with the strictness sigs attached to the Ids extendAnalEnvs :: TopLevelFlag -> AnalEnv -> [Id] -> AnalEnv extendAnalEnvs top_lvl env vars = env { ae_sigs = extendSigEnvs top_lvl (ae_sigs env) vars } @@ -2418,6 +2425,12 @@ extendSigEnv top_lvl sigs var sig = extendVarEnv sigs var (sig, top_lvl) lookupSigEnv :: AnalEnv -> Id -> Maybe (DmdSig, TopLevelFlag) lookupSigEnv env id = lookupVarEnv (ae_sigs env) id +addInScopeAnalEnv :: AnalEnv -> Var -> AnalEnv +addInScopeAnalEnv env id = env { ae_sigs = delVarEnv (ae_sigs env) id } + +addInScopeAnalEnvs :: AnalEnv -> [Var] -> AnalEnv +addInScopeAnalEnvs env ids = env { ae_sigs = delVarEnvList (ae_sigs env) ids } + nonVirgin :: AnalEnv -> AnalEnv nonVirgin env = env { ae_virgin = False } @@ -2456,7 +2469,18 @@ findBndrDmd env dmd_ty id fam_envs = ae_fam_envs env -{- Note [Making dictionary parameters strict] +{- Note [Bringing a new variable into scope] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + f x = blah + g = ...(\f. ...f...)... + +In the body of the '\f', any occurrence of `f` refers to the lambda-bound `f`, +not the top-level `f` (which will be in `ae_sigs`). So it's very important +to delete `f` from `ae_sigs` when we pass a lambda/case/let-up binding of `f`. +Otherwise chaos results (#22718). + +Note [Making dictionary parameters strict] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eb366515d8e67258408a9f61164a82837c145fe6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eb366515d8e67258408a9f61164a82837c145fe6 You're receiving 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 Jan 9 11:40:28 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 09 Jan 2023 06:40:28 -0500 Subject: [Git][ghc/ghc][wip/T22718] Handle shadowing in DmdAnal (#22718) Message-ID: <63bbfd2ce611e_3b1bf955be06633@gitlab.mail> Sebastian Graf pushed to branch wip/T22718 at Glasgow Haskell Compiler / GHC Commits: a0dcdcf4 by Sebastian Graf at 2023-01-09T12:38:53+01:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - 1 changed file: - compiler/GHC/Core/Opt/DmdAnal.hs Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -333,7 +333,8 @@ dmdAnalBindLetUp :: TopLevelFlag -> WithDmdType (DmdResult CoreBind a) dmdAnalBindLetUp top_lvl env id rhs anal_body = WithDmdType final_ty (R (NonRec id' rhs') (body')) where - WithDmdType body_ty body' = anal_body env + WithDmdType body_ty body' = anal_body (addInScopeAnalEnv env id) + -- See Note [Bringing a new variable into scope] WithDmdType body_ty' id_dmd = findBndrDmd env body_ty id -- See Note [Finalising boxity for demand signatures] @@ -473,7 +474,8 @@ dmdAnal' env dmd (App fun arg) dmdAnal' env dmd (Lam var body) | isTyVar var = let - WithDmdType body_ty body' = dmdAnal env dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) dmd body + -- See Note [Bringing a new variable into scope] in WithDmdType body_ty (Lam var body') @@ -481,7 +483,8 @@ dmdAnal' env dmd (Lam var body) = let (n, body_dmd) = peelCallDmd dmd -- body_dmd: a demand to analyze the body - WithDmdType body_ty body' = dmdAnal env body_dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) body_dmd body + -- See Note [Bringing a new variable into scope] WithDmdType lam_ty var' = annotateLamIdBndr env body_ty var new_dmd_type = multDmdType n lam_ty in @@ -493,7 +496,9 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt_con bndrs rhs]) -- can consider its field demands when analysing the scrutinee. | want_precise_field_dmds alt_con = let - WithDmdType rhs_ty rhs' = dmdAnal env dmd rhs + rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + WithDmdType rhs_ty rhs' = dmdAnal rhs_env dmd rhs WithDmdType alt_ty1 fld_dmds = findBndrsDmds env rhs_ty bndrs WithDmdType alt_ty2 case_bndr_dmd = findBndrDmd env alt_ty1 case_bndr !case_bndr' = setIdDemandInfo case_bndr case_bndr_dmd @@ -629,7 +634,9 @@ dmdAnalSumAlts env dmd case_bndr (alt:alts) dmdAnalSumAlt :: AnalEnv -> SubDemand -> Id -> CoreAlt -> WithDmdType CoreAlt dmdAnalSumAlt env dmd case_bndr (Alt con bndrs rhs) - | WithDmdType rhs_ty rhs' <- dmdAnal env dmd rhs + | let rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + , WithDmdType rhs_ty rhs' <- dmdAnal rhs_env dmd rhs , WithDmdType alt_ty dmds <- findBndrsDmds env rhs_ty bndrs , let (_ :* case_bndr_sd) = findIdDemand alt_ty case_bndr -- See Note [Demand on case-alternative binders] @@ -2399,7 +2406,7 @@ enterDFun bind env emptySigEnv :: SigEnv emptySigEnv = emptyVarEnv --- | Extend an environment with the strictness IDs attached to the id +-- | Extend an environment with the strictness sigs attached to the Ids extendAnalEnvs :: TopLevelFlag -> AnalEnv -> [Id] -> AnalEnv extendAnalEnvs top_lvl env vars = env { ae_sigs = extendSigEnvs top_lvl (ae_sigs env) vars } @@ -2418,6 +2425,12 @@ extendSigEnv top_lvl sigs var sig = extendVarEnv sigs var (sig, top_lvl) lookupSigEnv :: AnalEnv -> Id -> Maybe (DmdSig, TopLevelFlag) lookupSigEnv env id = lookupVarEnv (ae_sigs env) id +addInScopeAnalEnv :: AnalEnv -> Var -> AnalEnv +addInScopeAnalEnv env id = env { ae_sigs = delVarEnv (ae_sigs env) id } + +addInScopeAnalEnvs :: AnalEnv -> [Var] -> AnalEnv +addInScopeAnalEnvs env ids = env { ae_sigs = delVarEnvList (ae_sigs env) ids } + nonVirgin :: AnalEnv -> AnalEnv nonVirgin env = env { ae_virgin = False } @@ -2456,7 +2469,18 @@ findBndrDmd env dmd_ty id fam_envs = ae_fam_envs env -{- Note [Making dictionary parameters strict] +{- Note [Bringing a new variable into scope] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + f x = blah + g = ...(\f. ...f...)... + +In the body of the '\f', any occurrence of `f` refers to the lambda-bound `f`, +not the top-level `f` (which will be in `ae_sigs`). So it's very important +to delete `f` from `ae_sigs` when we pass a lambda/case/let-up binding of `f`. +Otherwise chaos results (#22718). + +Note [Making dictionary parameters strict] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a0dcdcf4f1d78845d6e3d383b25c379c84d5862a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a0dcdcf4f1d78845d6e3d383b25c379c84d5862a You're receiving 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 Jan 9 11:41:55 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 09 Jan 2023 06:41:55 -0500 Subject: [Git][ghc/ghc][wip/T22718] Handle shadowing in DmdAnal (#22718) Message-ID: <63bbfd8310a8d_3b1bf959e5c8938@gitlab.mail> Sebastian Graf pushed to branch wip/T22718 at Glasgow Haskell Compiler / GHC Commits: f7f55043 by Sebastian Graf at 2023-01-09T12:41:31+01:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - 1 changed file: - compiler/GHC/Core/Opt/DmdAnal.hs Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -333,7 +333,8 @@ dmdAnalBindLetUp :: TopLevelFlag -> WithDmdType (DmdResult CoreBind a) dmdAnalBindLetUp top_lvl env id rhs anal_body = WithDmdType final_ty (R (NonRec id' rhs') (body')) where - WithDmdType body_ty body' = anal_body env + WithDmdType body_ty body' = anal_body (addInScopeAnalEnv env id) + -- See Note [Bringing a new variable into scope] WithDmdType body_ty' id_dmd = findBndrDmd env body_ty id -- See Note [Finalising boxity for demand signatures] @@ -473,7 +474,8 @@ dmdAnal' env dmd (App fun arg) dmdAnal' env dmd (Lam var body) | isTyVar var = let - WithDmdType body_ty body' = dmdAnal env dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) dmd body + -- See Note [Bringing a new variable into scope] in WithDmdType body_ty (Lam var body') @@ -481,7 +483,8 @@ dmdAnal' env dmd (Lam var body) = let (n, body_dmd) = peelCallDmd dmd -- body_dmd: a demand to analyze the body - WithDmdType body_ty body' = dmdAnal env body_dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) body_dmd body + -- See Note [Bringing a new variable into scope] WithDmdType lam_ty var' = annotateLamIdBndr env body_ty var new_dmd_type = multDmdType n lam_ty in @@ -493,7 +496,9 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt_con bndrs rhs]) -- can consider its field demands when analysing the scrutinee. | want_precise_field_dmds alt_con = let - WithDmdType rhs_ty rhs' = dmdAnal env dmd rhs + rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + WithDmdType rhs_ty rhs' = dmdAnal rhs_env dmd rhs WithDmdType alt_ty1 fld_dmds = findBndrsDmds env rhs_ty bndrs WithDmdType alt_ty2 case_bndr_dmd = findBndrDmd env alt_ty1 case_bndr !case_bndr' = setIdDemandInfo case_bndr case_bndr_dmd @@ -629,7 +634,9 @@ dmdAnalSumAlts env dmd case_bndr (alt:alts) dmdAnalSumAlt :: AnalEnv -> SubDemand -> Id -> CoreAlt -> WithDmdType CoreAlt dmdAnalSumAlt env dmd case_bndr (Alt con bndrs rhs) - | WithDmdType rhs_ty rhs' <- dmdAnal env dmd rhs + | let rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + , WithDmdType rhs_ty rhs' <- dmdAnal rhs_env dmd rhs , WithDmdType alt_ty dmds <- findBndrsDmds env rhs_ty bndrs , let (_ :* case_bndr_sd) = findIdDemand alt_ty case_bndr -- See Note [Demand on case-alternative binders] @@ -2399,7 +2406,7 @@ enterDFun bind env emptySigEnv :: SigEnv emptySigEnv = emptyVarEnv --- | Extend an environment with the strictness IDs attached to the id +-- | Extend an environment with the strictness sigs attached to the Ids extendAnalEnvs :: TopLevelFlag -> AnalEnv -> [Id] -> AnalEnv extendAnalEnvs top_lvl env vars = env { ae_sigs = extendSigEnvs top_lvl (ae_sigs env) vars } @@ -2418,6 +2425,12 @@ extendSigEnv top_lvl sigs var sig = extendVarEnv sigs var (sig, top_lvl) lookupSigEnv :: AnalEnv -> Id -> Maybe (DmdSig, TopLevelFlag) lookupSigEnv env id = lookupVarEnv (ae_sigs env) id +addInScopeAnalEnv :: AnalEnv -> Var -> AnalEnv +addInScopeAnalEnv env id = env { ae_sigs = delVarEnv (ae_sigs env) id } + +addInScopeAnalEnvs :: AnalEnv -> [Var] -> AnalEnv +addInScopeAnalEnvs env ids = env { ae_sigs = delVarEnvList (ae_sigs env) ids } + nonVirgin :: AnalEnv -> AnalEnv nonVirgin env = env { ae_virgin = False } @@ -2456,7 +2469,18 @@ findBndrDmd env dmd_ty id fam_envs = ae_fam_envs env -{- Note [Making dictionary parameters strict] +{- Note [Bringing a new variable into scope] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + f x = blah + g = ...(\f. ...f...)... + +In the body of the '\f', any occurrence of `f` refers to the lambda-bound `f`, +not the top-level `f` (which will be in `ae_sigs`). So it's very important +to delete `f` from `ae_sigs` when we pass a lambda/case/let-up binding of `f`. +Otherwise chaos results (#22718). + +Note [Making dictionary parameters strict] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f7f550433a697343c747579751a11c43d405e733 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f7f550433a697343c747579751a11c43d405e733 You're receiving 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 Jan 9 11:57:47 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 09 Jan 2023 06:57:47 -0500 Subject: [Git][ghc/ghc][wip/T22718] 3 commits: Disable split sections on aarch64-deb10 build Message-ID: <63bc013b5fd0_3b1bf952620196ed@gitlab.mail> Sebastian Graf pushed to branch wip/T22718 at Glasgow Haskell Compiler / GHC Commits: 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 6489219b by Sebastian Graf at 2023-01-09T11:57:41+00:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - 8 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Core/Opt/DmdAnal.hs - + testsuite/tests/printer/HsDocTy.hs - testsuite/tests/printer/Makefile - testsuite/tests/printer/all.T - utils/check-exact/ExactPrint.hs - utils/check-exact/Main.hs Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -813,7 +813,7 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , standardBuilds Amd64 Darwin , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin - , standardBuilds AArch64 (Linux Debian10) + , standardBuildsWithConfig AArch64 (Linux Debian10) (splitSectionsBroken vanilla) , disableValidate (standardBuildsWithConfig AArch64 (Linux Debian10) llvm) , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla) , standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static) ===================================== .gitlab/jobs.yaml ===================================== @@ -1926,7 +1926,7 @@ "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release": { + "release-aarch64-linux-deb10-release+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1936,7 +1936,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release.tar.xz", + "ghc-aarch64-linux-deb10-release+llvm.tar.xz", "junit.xml" ], "reports": { @@ -1978,15 +1978,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", + "BUILD_FLAVOUR": "release+llvm", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release", + "TEST_ENV": "aarch64-linux-deb10-release+llvm", "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release+llvm": { + "release-aarch64-linux-deb10-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1996,7 +1996,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release+llvm.tar.xz", + "ghc-aarch64-linux-deb10-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2038,11 +2038,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", - "BUILD_FLAVOUR": "release+llvm", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release+llvm", + "TEST_ENV": "aarch64-linux-deb10-release+no_split_sections", "XZ_OPT": "-9" } }, ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -333,7 +333,8 @@ dmdAnalBindLetUp :: TopLevelFlag -> WithDmdType (DmdResult CoreBind a) dmdAnalBindLetUp top_lvl env id rhs anal_body = WithDmdType final_ty (R (NonRec id' rhs') (body')) where - WithDmdType body_ty body' = anal_body env + WithDmdType body_ty body' = anal_body (addInScopeAnalEnv env id) + -- See Note [Bringing a new variable into scope] WithDmdType body_ty' id_dmd = findBndrDmd env body_ty id -- See Note [Finalising boxity for demand signatures] @@ -473,7 +474,8 @@ dmdAnal' env dmd (App fun arg) dmdAnal' env dmd (Lam var body) | isTyVar var = let - WithDmdType body_ty body' = dmdAnal env dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) dmd body + -- See Note [Bringing a new variable into scope] in WithDmdType body_ty (Lam var body') @@ -481,7 +483,8 @@ dmdAnal' env dmd (Lam var body) = let (n, body_dmd) = peelCallDmd dmd -- body_dmd: a demand to analyze the body - WithDmdType body_ty body' = dmdAnal env body_dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) body_dmd body + -- See Note [Bringing a new variable into scope] WithDmdType lam_ty var' = annotateLamIdBndr env body_ty var new_dmd_type = multDmdType n lam_ty in @@ -493,7 +496,9 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt_con bndrs rhs]) -- can consider its field demands when analysing the scrutinee. | want_precise_field_dmds alt_con = let - WithDmdType rhs_ty rhs' = dmdAnal env dmd rhs + rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + WithDmdType rhs_ty rhs' = dmdAnal rhs_env dmd rhs WithDmdType alt_ty1 fld_dmds = findBndrsDmds env rhs_ty bndrs WithDmdType alt_ty2 case_bndr_dmd = findBndrDmd env alt_ty1 case_bndr !case_bndr' = setIdDemandInfo case_bndr case_bndr_dmd @@ -629,7 +634,9 @@ dmdAnalSumAlts env dmd case_bndr (alt:alts) dmdAnalSumAlt :: AnalEnv -> SubDemand -> Id -> CoreAlt -> WithDmdType CoreAlt dmdAnalSumAlt env dmd case_bndr (Alt con bndrs rhs) - | WithDmdType rhs_ty rhs' <- dmdAnal env dmd rhs + | let rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + , WithDmdType rhs_ty rhs' <- dmdAnal rhs_env dmd rhs , WithDmdType alt_ty dmds <- findBndrsDmds env rhs_ty bndrs , let (_ :* case_bndr_sd) = findIdDemand alt_ty case_bndr -- See Note [Demand on case-alternative binders] @@ -2399,7 +2406,7 @@ enterDFun bind env emptySigEnv :: SigEnv emptySigEnv = emptyVarEnv --- | Extend an environment with the strictness IDs attached to the id +-- | Extend an environment with the strictness sigs attached to the Ids extendAnalEnvs :: TopLevelFlag -> AnalEnv -> [Id] -> AnalEnv extendAnalEnvs top_lvl env vars = env { ae_sigs = extendSigEnvs top_lvl (ae_sigs env) vars } @@ -2418,6 +2425,12 @@ extendSigEnv top_lvl sigs var sig = extendVarEnv sigs var (sig, top_lvl) lookupSigEnv :: AnalEnv -> Id -> Maybe (DmdSig, TopLevelFlag) lookupSigEnv env id = lookupVarEnv (ae_sigs env) id +addInScopeAnalEnv :: AnalEnv -> Var -> AnalEnv +addInScopeAnalEnv env id = env { ae_sigs = delVarEnv (ae_sigs env) id } + +addInScopeAnalEnvs :: AnalEnv -> [Var] -> AnalEnv +addInScopeAnalEnvs env ids = env { ae_sigs = delVarEnvList (ae_sigs env) ids } + nonVirgin :: AnalEnv -> AnalEnv nonVirgin env = env { ae_virgin = False } @@ -2456,7 +2469,18 @@ findBndrDmd env dmd_ty id fam_envs = ae_fam_envs env -{- Note [Making dictionary parameters strict] +{- Note [Bringing a new variable into scope] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + f x = blah + g = ...(\f. ...f...)... + +In the body of the '\f', any occurrence of `f` refers to the lambda-bound `f`, +not the top-level `f` (which will be in `ae_sigs`). So it's very important +to delete `f` from `ae_sigs` when we pass a lambda/case/let-up binding of `f`. +Otherwise chaos results (#22718). + +Note [Making dictionary parameters strict] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? ===================================== testsuite/tests/printer/HsDocTy.hs ===================================== @@ -0,0 +1,6 @@ +{-# OPTIONS_GHC -haddock #-} +module HsDocTy where + +class C1 a where + f1 :: a -> Int + -- ^ comment on Int ===================================== testsuite/tests/printer/Makefile ===================================== @@ -769,3 +769,9 @@ Test21355: Test21805: $(CHECK_PPR) $(LIBDIR) Test21805.hs $(CHECK_EXACT) $(LIBDIR) Test21805.hs + +.PHONY: HsDocTy +HsDocTy: + # See comment on pprWithDocString, this won't round trip + # $(CHECK_PPR) $(LIBDIR) HsDocTy.hs + $(CHECK_EXACT) $(LIBDIR) HsDocTy.hs ===================================== testsuite/tests/printer/all.T ===================================== @@ -185,4 +185,5 @@ test('Test21805', [ignore_stderr, req_ppr_deps], makefile_test, ['Test21805']) test('T22488', normal, ghci_script, ['T22488.script']) test('T22488_docHead', normal, compile_and_run, ['-package ghc']) test('T20531', extra_files(['T20531_defs.hs']), ghci_script, ['T20531.script']) -test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) \ No newline at end of file +test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) +test('HsDocTy', [ignore_stderr, req_ppr_deps], makefile_test, ['HsDocTy']) \ No newline at end of file ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -3898,6 +3898,10 @@ instance ExactPrint (HsType GhcPs) where exact (HsSpliceTy a splice) = do splice' <- markAnnotated splice return (HsSpliceTy a splice') + exact (HsDocTy an ty doc) = do + ty' <- markAnnotated ty + doc' <- markAnnotated doc + return (HsDocTy an ty' doc') exact (HsBangTy an (HsSrcBang mt up str) ty) = do an0 <- case mt of ===================================== utils/check-exact/Main.hs ===================================== @@ -59,7 +59,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../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) - "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) + -- "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3a.hs" (Just changeWhereIn3a) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3b.hs" (Just changeWhereIn3b) -- "../../testsuite/tests/ghc-api/exactprint/AddLocalDecl1.hs" (Just addLocaLDecl1) @@ -203,6 +203,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../testsuite/tests/ghc-api/exactprint/Test20239.hs" Nothing -- "../../testsuite/tests/printer/PprArrowLambdaCase.hs" Nothing -- "../../testsuite/tests/printer/Test16279.hs" Nothing + "../../testsuite/tests/printer/HsDocTy.hs" Nothing -- cloneT does not need a test, function can be retired View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f7f550433a697343c747579751a11c43d405e733...6489219b9722eec5dbe8dcade8efe2c3eb0ad702 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f7f550433a697343c747579751a11c43d405e733...6489219b9722eec5dbe8dcade8efe2c3eb0ad702 You're receiving 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 Jan 9 11:59:00 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 09 Jan 2023 06:59:00 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/revert-lea Message-ID: <63bc01845c87a_3b1bf952620201a8@gitlab.mail> Matthew Pickering pushed new branch wip/revert-lea at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/revert-lea You're receiving 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 Jan 9 12:11:54 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 09 Jan 2023 07:11:54 -0500 Subject: [Git][ghc/ghc][wip/T22428] 201 commits: Properly cast values when writing/reading unboxed sums. Message-ID: <63bc048ad92d9_3b1bf955be028118@gitlab.mail> Sebastian Graf pushed to branch wip/T22428 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. - - - - - 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 - - - - - 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]. - - - - - 2eb0fb87 by Matthew Pickering at 2022-12-15T03:54:39-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 - - - - - 552b7908 by Ben Gamari at 2022-12-15T03:55:15-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. - - - - - 933d61a4 by Simon Peyton Jones at 2022-12-15T03:55:51-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. - - - - - 03ed0b95 by Ryan Scott at 2022-12-15T03:56:26-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. - - - - - ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/ThreadPaused: Ordering fixes - - - - - 914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00 eventlog: Silence spurious data race - - - - - fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts: Use fences instead of explicit barriers - - - - - 2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - 70999283 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 98689f77 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - 86f20258 by Ben Gamari at 2022-12-16T16:12:45-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. - - - - - f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate access to capabilities array - - - - - 7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate sched_state - - - - - 1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Style fix - - - - - 82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00 compiler: Use release store in eager blackholing - - - - - eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Fix ordering of makeStableName - - - - - ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Note race with wakeBlockingQueue - - - - - 5acf33dd by Bodigrim at 2022-12-16T16:13:22-05:00 Bump submodule directory to 1.3.8.0 and hpc to HEAD - - - - - 0dd95421 by Bodigrim at 2022-12-16T16:13:22-05:00 Accept allocations increase on Windows This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips between lists and ByteArray. See #22625 for discussion. Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T10547 T12150 T12227 T12234 T12425 T13035 T13253 T13253-spj T13701 T13719 T15703 T16875 T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T21839r T5837 T6048 T9198 T9961 TcPlugin_RewritePerf hard_hole_fits - - - - - ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00 testsuite: Mark T9405 as fragile instead of broken on Windows It's starting to pass again, and the unexpected pass blocks CI. - - - - - 1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: remove obsolete commented code in wasm NCG It was just a temporary hack to workaround a bug in the relooper, that bug has been fixed long before the wasm backend is merged. - - - - - e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm Also removes some unreachable code here. - - - - - 1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: change fallback function signature to Cmm function signature in wasm NCG In the wasm NCG, when handling a `CLabel` of undefined function without knowing its function signature, we used to fallback to `() -> ()` which is accepted by `wasm-ld`. This patch changes it to the signature of Cmm functions, which equally works, but would be required when we emit tail call instructions. - - - - - 8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add optional tail-call support in wasm NCG When the `-mtail-call` clang flag is passed at configure time, wasm tail-call extension is enabled, and the wasm NCG will emit `return_call`/`return_call_indirect` instructions to take advantage of it and avoid the `StgRun` trampoline overhead. Closes #22461. - - - - - d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00 base: add missing autoconf checks for waitpid/umask These are not present in wasi-libc. Required for fixing #22589 - - - - - da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00 compiler: make .wasm the default executable extension on wasm32 Following convention as in other wasm toolchains. Fixes #22594. - - - - - ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00 ci: support hello.wasm in ci.sh cross testing logic - - - - - 6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00 Correct `exitWith` Haddocks The `IOError`-specific `catch` in the Prelude is long gone. - - - - - b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-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. - - - - - 761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00 rts/libdw: Silence uninitialized usage warnings As noted in #22538, previously some GCC versions warned that various locals in Libdw.c may be used uninitialized. Although this wasn't strictly true (since they were initialized in an inline assembler block) we fix this by providing explicit empty initializers. Fixes #22538 - - - - - 5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00 testsuite: Mark T16392 as fragile on windows See #22649 - - - - - 703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00 Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`. - - - - - 9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05: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 - - - - - 7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Drop uses of AC_PROG_CC_C99 As noted in #22566, this macro is deprecated as of autoconf-2.70 `AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself. Closes #22566. - - - - - 36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Use AS_HELP_STRING instead of AC_HELP_STRING The latter has been deprecated. See #22566. - - - - - befe6ff8 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: fix various usages of head and tail - - - - - 666d0ba7 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: avoid head and tail in parseCallEscape and around - - - - - 5d96fd50 by Bodigrim at 2022-12-20T21:16:37-05:00 Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty - - - - - 3ce2ab94 by Bodigrim at 2022-12-21T06:17:56-05:00 Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian - - - - - 954de93a by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule haskeline to HEAD (to allow transformers-0.6) - - - - - cefbeec3 by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule transformers to 0.6.0.4 - - - - - b4730b62 by Bodigrim at 2022-12-21T06:17:56-05:00 Fix tests T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations Metric Increase: T13253 - - - - - 0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05: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. - - - - - df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00 rts: explicitly store return value of ccall checkClosure to prevent type error (#22617) - - - - - e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix shadowing lacuna in OccurAnal Issue #22623 demonstrated another lacuna in the implementation of wrinkle (BS3) in Note [The binder-swap substitution] in the occurrence analyser. I was failing to add TyVar lambda binders using addInScope/addOneInScope and that led to a totally bogus binder-swap transformation. Very easy to fix. - - - - - 3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix an assertion check in addToEqualCtList The old assertion saw that a constraint ct could rewrite itself (of course it can) and complained (stupid). Fixes #22645 - - - - - ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00 configure: Bump version to 9.6 - - - - - fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00 base: Bump version to 4.18 Requires various submodule bumps. - - - - - 93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00 ghc-boot: Fix bootstrapping - - - - - fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00 Bump GHC version to 9.7 - - - - - 914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05: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. - - - - - 32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00 hadrian bindist: Install manpages to share/man/man1/ghc.1 When the installation makefile was copied over the manpages were no longer installed in the correct place. Now we install it into share/man/man1/ghc.1 as the make build system did. Fixes #22371 - - - - - b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00 rts: Drop paths from configure from cabal file A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them. - - - - - b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00 Bump libffi-tarballs submodule We will now use libffi-3.4.4. - - - - - 3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00 EPA: Make EOF position part of AnnsModule Closes #20951 Closes #19697 - - - - - 99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00 JS: fix support for -outputdir (#22641) The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug. - - - - - 02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00 Refactor mkRuntimeError This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions. - - - - - 35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00 base: Fix event manager shutdown race on non-Linux platforms During shutdown it's possible that we will attempt to use a closed fd to wakeup another capability's event manager. On the Linux eventfd path we were careful to handle this. However on the non-Linux path we failed to do so. Fix this. - - - - - 317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00 Fix unifier bug: failing to decompose over-saturated type family This simple patch fixes #22647 - - - - - 14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00 rts/m32: Fix sanity checking Previously we would attempt to clear pages which were marked as read-only. Fix this. - - - - - 16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00 ci: Move wasm pipelines into nightly rather than master See #22664 for the changes which need to be made to bring one of these back to the validate pipeline. - - - - - 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-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). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Bodigrim at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - 541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - 28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00 Add support for sized literals in the bytecode interpreter. The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945 - - - - - ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00 rts: MUT_VAR is not a StgMutArrPtrs There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs. - - - - - 6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s - - - - - 73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. - - - - - 8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 55028c0d by Sebastian Graf at 2023-01-09T13:11:42+01:00 Fix contification with stable unfoldings (#22428) Many functions now return a `TailUsageDetails` that adorns a `UsageDetails` with a `JoinArity` that reflects the number of join point binders around the body for which the `UsageDetails` was computed. `TailUsageDetails` is now returned by `occAnalLamTail` as well as `occAnalUnfolding` and `occAnalRules`. I adjusted `Note [Join points and unfoldings/rules]` and `Note [Adjusting right-hand sides]` to account for the new machinery. I also wrote a new `Note [Join arity prediction based on joinRhsArity]` and refer to it when we combine `TailUsageDetails` for a recursive RHS. I also renamed * `occAnalLam` to `occAnalLamTail` * `adjustRhsUsage` to `adjustTailUsage` * a few other less important functions and properly documented the that each call of `occAnalLamTail` must pair up with `adjustTailUsage`. I removed `Note [Unfoldings and join points]` because it was redundant with `Note [Occurrences in stable unfoldings]`. While in town, I refactored `mkLoopBreakerNodes` so that it returns a condensed `NodeDetails` called `SimpleNodeDetails`. Fixes #22428. Metric Decrease: T12150 T12425 T21839c T21839r T9961 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - compiler/CodeGen.Platform.h - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info/Build.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.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6b80ac4bb2146a59ff99749b8b4998af3f9a94e9...55028c0d11bd74977ee5f88fde793c080b88e9d2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6b80ac4bb2146a59ff99749b8b4998af3f9a94e9...55028c0d11bd74977ee5f88fde793c080b88e9d2 You're receiving 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 Jan 9 15:36:45 2023 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Mon, 09 Jan 2023 10:36:45 -0500 Subject: [Git][ghc/ghc][wip/req_smp] 212 commits: Make Functor a quantified superclass of Bifunctor. Message-ID: <63bc348dcbf31_3b1bf93c57d8c57620@gitlab.mail> doyougnu pushed to branch wip/req_smp 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. - - - - - 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 - - - - - 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]. - - - - - 2eb0fb87 by Matthew Pickering at 2022-12-15T03:54:39-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 - - - - - 552b7908 by Ben Gamari at 2022-12-15T03:55:15-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. - - - - - 933d61a4 by Simon Peyton Jones at 2022-12-15T03:55:51-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. - - - - - 03ed0b95 by Ryan Scott at 2022-12-15T03:56:26-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. - - - - - ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/ThreadPaused: Ordering fixes - - - - - 914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00 eventlog: Silence spurious data race - - - - - fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts: Use fences instead of explicit barriers - - - - - 2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - 70999283 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 98689f77 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - 86f20258 by Ben Gamari at 2022-12-16T16:12:45-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. - - - - - f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate access to capabilities array - - - - - 7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate sched_state - - - - - 1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Style fix - - - - - 82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00 compiler: Use release store in eager blackholing - - - - - eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Fix ordering of makeStableName - - - - - ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Note race with wakeBlockingQueue - - - - - 5acf33dd by Bodigrim at 2022-12-16T16:13:22-05:00 Bump submodule directory to 1.3.8.0 and hpc to HEAD - - - - - 0dd95421 by Bodigrim at 2022-12-16T16:13:22-05:00 Accept allocations increase on Windows This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips between lists and ByteArray. See #22625 for discussion. Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T10547 T12150 T12227 T12234 T12425 T13035 T13253 T13253-spj T13701 T13719 T15703 T16875 T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T21839r T5837 T6048 T9198 T9961 TcPlugin_RewritePerf hard_hole_fits - - - - - ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00 testsuite: Mark T9405 as fragile instead of broken on Windows It's starting to pass again, and the unexpected pass blocks CI. - - - - - 1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: remove obsolete commented code in wasm NCG It was just a temporary hack to workaround a bug in the relooper, that bug has been fixed long before the wasm backend is merged. - - - - - e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm Also removes some unreachable code here. - - - - - 1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: change fallback function signature to Cmm function signature in wasm NCG In the wasm NCG, when handling a `CLabel` of undefined function without knowing its function signature, we used to fallback to `() -> ()` which is accepted by `wasm-ld`. This patch changes it to the signature of Cmm functions, which equally works, but would be required when we emit tail call instructions. - - - - - 8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add optional tail-call support in wasm NCG When the `-mtail-call` clang flag is passed at configure time, wasm tail-call extension is enabled, and the wasm NCG will emit `return_call`/`return_call_indirect` instructions to take advantage of it and avoid the `StgRun` trampoline overhead. Closes #22461. - - - - - d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00 base: add missing autoconf checks for waitpid/umask These are not present in wasi-libc. Required for fixing #22589 - - - - - da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00 compiler: make .wasm the default executable extension on wasm32 Following convention as in other wasm toolchains. Fixes #22594. - - - - - ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00 ci: support hello.wasm in ci.sh cross testing logic - - - - - 6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00 Correct `exitWith` Haddocks The `IOError`-specific `catch` in the Prelude is long gone. - - - - - b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-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. - - - - - 761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00 rts/libdw: Silence uninitialized usage warnings As noted in #22538, previously some GCC versions warned that various locals in Libdw.c may be used uninitialized. Although this wasn't strictly true (since they were initialized in an inline assembler block) we fix this by providing explicit empty initializers. Fixes #22538 - - - - - 5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00 testsuite: Mark T16392 as fragile on windows See #22649 - - - - - 703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00 Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`. - - - - - 9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05: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 - - - - - 7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Drop uses of AC_PROG_CC_C99 As noted in #22566, this macro is deprecated as of autoconf-2.70 `AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself. Closes #22566. - - - - - 36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Use AS_HELP_STRING instead of AC_HELP_STRING The latter has been deprecated. See #22566. - - - - - befe6ff8 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: fix various usages of head and tail - - - - - 666d0ba7 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: avoid head and tail in parseCallEscape and around - - - - - 5d96fd50 by Bodigrim at 2022-12-20T21:16:37-05:00 Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty - - - - - 3ce2ab94 by Bodigrim at 2022-12-21T06:17:56-05:00 Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian - - - - - 954de93a by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule haskeline to HEAD (to allow transformers-0.6) - - - - - cefbeec3 by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule transformers to 0.6.0.4 - - - - - b4730b62 by Bodigrim at 2022-12-21T06:17:56-05:00 Fix tests T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations Metric Increase: T13253 - - - - - 0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05: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. - - - - - df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00 rts: explicitly store return value of ccall checkClosure to prevent type error (#22617) - - - - - e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix shadowing lacuna in OccurAnal Issue #22623 demonstrated another lacuna in the implementation of wrinkle (BS3) in Note [The binder-swap substitution] in the occurrence analyser. I was failing to add TyVar lambda binders using addInScope/addOneInScope and that led to a totally bogus binder-swap transformation. Very easy to fix. - - - - - 3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix an assertion check in addToEqualCtList The old assertion saw that a constraint ct could rewrite itself (of course it can) and complained (stupid). Fixes #22645 - - - - - ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00 configure: Bump version to 9.6 - - - - - fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00 base: Bump version to 4.18 Requires various submodule bumps. - - - - - 93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00 ghc-boot: Fix bootstrapping - - - - - fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00 Bump GHC version to 9.7 - - - - - 914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05: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. - - - - - 32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00 hadrian bindist: Install manpages to share/man/man1/ghc.1 When the installation makefile was copied over the manpages were no longer installed in the correct place. Now we install it into share/man/man1/ghc.1 as the make build system did. Fixes #22371 - - - - - b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00 rts: Drop paths from configure from cabal file A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them. - - - - - b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00 Bump libffi-tarballs submodule We will now use libffi-3.4.4. - - - - - 3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00 EPA: Make EOF position part of AnnsModule Closes #20951 Closes #19697 - - - - - 99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00 JS: fix support for -outputdir (#22641) The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug. - - - - - 02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00 Refactor mkRuntimeError This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions. - - - - - 35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00 base: Fix event manager shutdown race on non-Linux platforms During shutdown it's possible that we will attempt to use a closed fd to wakeup another capability's event manager. On the Linux eventfd path we were careful to handle this. However on the non-Linux path we failed to do so. Fix this. - - - - - 317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00 Fix unifier bug: failing to decompose over-saturated type family This simple patch fixes #22647 - - - - - 14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00 rts/m32: Fix sanity checking Previously we would attempt to clear pages which were marked as read-only. Fix this. - - - - - 16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00 ci: Move wasm pipelines into nightly rather than master See #22664 for the changes which need to be made to bring one of these back to the validate pipeline. - - - - - 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-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). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Bodigrim at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - 541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - 28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00 Add support for sized literals in the bytecode interpreter. The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945 - - - - - ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00 rts: MUT_VAR is not a StgMutArrPtrs There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs. - - - - - 6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s - - - - - 73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. - - - - - 8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 63f968e9 by Sylvain Henry at 2023-01-09T10:01:46-05:00 WIP: fix req_smp (target vs ghc) - - - - - 56c188de by doyougnu at 2023-01-09T10:02:24-05:00 add flag to separate bootstrapper - - - - - 30447f90 by doyougnu at 2023-01-09T10:02:25-05:00 split req_smp -> req_target_smp and req_ghc_smp - - - - - f282d210 by doyougnu at 2023-01-09T10:02:26-05:00 update tests smp flags - - - - - f9c96d10 by doyougnu at 2023-01-09T10:02:26-05:00 cleanup and add some docstrings - - - - - 815146c5 by doyougnu at 2023-01-09T10:03:00-05:00 only set ghc_with_smp to bootstrapper on S1 or CC Only set ghc_with_smp to bootstrapperWithSMP of when testing stage 1 and cross compiling - - - - - 778b79e9 by doyougnu at 2023-01-09T10:03:56-05:00 test the RTS in config/ghc not hadrian - - - - - 2939a350 by doyougnu at 2023-01-09T10:03:57-05:00 re-add ghc_with_smp - - - - - e1156bf1 by doyougnu at 2023-01-09T10:03:57-05:00 fix and align req names - - - - - 5c5dc559 by doyougnu at 2023-01-09T10:03:57-05:00 fix T11760 to use req_host_smp - - - - - 680ca4eb by doyougnu at 2023-01-09T10:03:57-05:00 test the rts directly, avoid python 3.5 limitation - - - - - 83fbb47a by doyougnu at 2023-01-09T10:36:25-05:00 test the compiler in a try block - - - - - 7a5db3ff by doyougnu at 2023-01-09T10:36:26-05:00 align out of tree and in tree withSMP flags - - - - - 5dd0c547 by doyougnu at 2023-01-09T10:36:26-05:00 mark failing tests as host req smp - - - - - 67a66dbc by doyougnu at 2023-01-09T10:36:26-05:00 testsuite: req_host_smp --> req_ghc_smp - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - compiler/CodeGen.Platform.h - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info/Build.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.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/84c4bd6c36b7e5a4599c9e371ce06fa96f29d744...67a66dbcbad78abe59fe212f67eb6f8aecc738b5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/84c4bd6c36b7e5a4599c9e371ce06fa96f29d744...67a66dbcbad78abe59fe212f67eb6f8aecc738b5 You're receiving 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 Jan 9 15:53:16 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 09 Jan 2023 10:53:16 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22725 Message-ID: <63bc386c6c42a_3b1bf95264860021@gitlab.mail> Simon Peyton Jones pushed new branch wip/T22725 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22725 You're receiving 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 Jan 9 16:17:32 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 09 Jan 2023 11:17:32 -0500 Subject: [Git][ghc/ghc][wip/no_fixup_chains_2] 2 commits: Store bootstrap_llvm_target and use it to set LlvmTarget in bindists Message-ID: <63bc3e1c4c279_3b1bf952648666d9@gitlab.mail> Matthew Pickering pushed to branch wip/no_fixup_chains_2 at Glasgow Haskell Compiler / GHC Commits: 036c4034 by Matthew Pickering at 2023-01-09T16:17:19+00:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 4e70977a by Matthew Pickering at 2023-01-09T16:17:19+00:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. - - - - - 6 changed files: - configure.ac - distrib/configure.ac.in - libraries/base/GHC/Stack/CloneStack.hs - m4/ghc_llvm_target.m4 - testsuite/tests/rts/decodeMyStack.stdout - testsuite/tests/rts/decodeMyStack_underflowFrames.hs Changes: ===================================== configure.ac ===================================== @@ -667,6 +667,8 @@ GHC_LLVM_TARGET_SET_VAR # we intend to pass trough --targets to llvm as is. LLVMTarget_CPP=` echo "$LlvmTarget"` AC_SUBST(LLVMTarget_CPP) +# The target is substituted into the distrib/configure.ac file +AC_SUBST(LlvmTarget) dnl ** See whether cc supports --target= and set dnl CONF_CC_OPTS_STAGE[012] accordingly. ===================================== distrib/configure.ac.in ===================================== @@ -18,6 +18,8 @@ dnl-------------------------------------------------------------------- dnl Various things from the source distribution configure bootstrap_target=@TargetPlatform@ +bootstrap_llvm_target=@LlvmTarget@ + TargetHasRTSLinker=@TargetHasRTSLinker@ AC_SUBST(TargetHasRTSLinker) @@ -169,6 +171,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG # Stage 3 won't be supported by cross-compilation FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) +FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) +FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + AC_SUBST(CONF_CC_OPTS_STAGE0) AC_SUBST(CONF_CC_OPTS_STAGE1) AC_SUBST(CONF_CC_OPTS_STAGE2) ===================================== libraries/base/GHC/Stack/CloneStack.hs ===================================== @@ -26,6 +26,7 @@ import Control.Concurrent.MVar import Data.Maybe (catMaybes) import Foreign import GHC.Conc.Sync +import GHC.ClosureTypes import GHC.Exts (Int (I#), RealWorld, StackSnapshot#, ThreadId#, Array#, sizeofArray#, indexArray#, State#, StablePtr#) import GHC.IO (IO (..)) import GHC.InfoProv (InfoProv (..), InfoProvEnt, ipLoc, ipeProv, peekInfoProv) @@ -207,7 +208,7 @@ data StackEntry = StackEntry { functionName :: String, moduleName :: String, srcLoc :: String, - closureType :: Word + closureType :: ClosureType } deriving (Show, Eq) @@ -246,8 +247,7 @@ decode stackSnapshot = do { functionName = ipLabel infoProv, moduleName = ipMod infoProv, srcLoc = ipLoc infoProv, - -- read looks dangerous, be we can trust that the closure type is always there. - closureType = read . ipDesc $ infoProv + closureType = ipDesc $ infoProv } getDecodedStackArray :: StackSnapshot -> IO [Ptr InfoProvEnt] ===================================== m4/ghc_llvm_target.m4 ===================================== @@ -50,5 +50,10 @@ AC_DEFUN([GHC_LLVM_TARGET], [ # require it. AC_DEFUN([GHC_LLVM_TARGET_SET_VAR], [ AC_REQUIRE([FPTOOLS_SET_PLATFORMS_VARS]) - GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + if test "$bootstrap_llvm_target" != "" + then + LlvmTarget=$bootstrap_llvm_target + else + GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + fi ]) ===================================== testsuite/tests/rts/decodeMyStack.stdout ===================================== @@ -1,12 +1,12 @@ -StackEntry {functionName = "main.(...)", moduleName = "Main", srcLoc = "decodeMyStack.hs:22:27-41", closureType = 53} -StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = 53} -StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = 53} -StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = 53} -StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = 53} -StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = 53} -StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = 53} -StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = 53} -StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = 53} -StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = 53} -StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = 53} -StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:13:7-21", closureType = 53} +StackEntry {functionName = "main.(...)", moduleName = "Main", srcLoc = "decodeMyStack.hs:22:27-41", closureType = STACK} +StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = STACK} +StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = STACK} +StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = STACK} +StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = STACK} +StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = STACK} +StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = STACK} +StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = STACK} +StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = STACK} +StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = STACK} +StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:18:26-28", closureType = STACK} +StackEntry {functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", srcLoc = "decodeMyStack.hs:13:7-21", closureType = STACK} ===================================== testsuite/tests/rts/decodeMyStack_underflowFrames.hs ===================================== @@ -1,6 +1,7 @@ module Main where import GHC.Stack.CloneStack +import GHC.ClosureTypes import System.IO.Unsafe import Control.Monad @@ -34,16 +35,16 @@ main = do StackEntry { functionName = "assertEqual", moduleName = "Main", - srcLoc = "decodeMyStack_underflowFrames.hs:23:11", - closureType = 53 + srcLoc = "decodeMyStack_underflowFrames.hs:24:11", + closureType = STACK } assertEqual (stack !! 1) StackEntry { functionName = "main.(...)", moduleName = "Main", - srcLoc = "decodeMyStack_underflowFrames.hs:29:20-36", - closureType = 53 + srcLoc = "decodeMyStack_underflowFrames.hs:30:20-36", + closureType = STACK } forM_ [2 .. 1001] @@ -53,8 +54,8 @@ main = do StackEntry { functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", - srcLoc = "decodeMyStack_underflowFrames.hs:19:26-28", - closureType = 53 + srcLoc = "decodeMyStack_underflowFrames.hs:20:26-28", + closureType = STACK } ) assertEqual @@ -62,6 +63,6 @@ main = do StackEntry { functionName = "getDeepStack.getDeepStackCase", moduleName = "Main", - srcLoc = "decodeMyStack_underflowFrames.hs:14:7-21", - closureType = 53 + srcLoc = "decodeMyStack_underflowFrames.hs:15:7-21", + closureType = STACK } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e3669c95d66a4904f0ac1848a9565ad4cd634e45...4e70977ac02f6b7f0a3013bed76aceb813e5d03b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e3669c95d66a4904f0ac1848a9565ad4cd634e45...4e70977ac02f6b7f0a3013bed76aceb813e5d03b You're receiving 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 Jan 9 16:33:40 2023 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Mon, 09 Jan 2023 11:33:40 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] Add PrimCallConv support to GHCi Message-ID: <63bc41e48c25a_3b1bf952634818e1@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 00577d1a by Luite Stegeman at 2023-01-10T01:31:36+09:00 Add PrimCallConv support to GHCi This adds support for calling Cmm code from bytecode using the native calling convention, allowing modules that use `foreign import prim` to be loaded and debugged in GHCi. This patch introduces a new `PRIMCALL` bytecode instruction and a helper stack frame `stg_primcall`. The code is based on the existing functionality for dealing with unboxed tuples in bytecode, which has been generalised to handle arbitrary calls. Fixes #22051 - - - - - 21 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Foreign.hs - rts/Disassembler.c - rts/Interpreter.c - rts/RtsSymbols.c - rts/StgMiscClosures.cmm - rts/include/rts/Bytecodes.h - rts/include/stg/MiscClosures.h - testsuite/tests/ghci/prog014/prog014.T - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout-ws-32 - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm - + testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile - + testsuite/tests/ghci/should_run/GHCiPrimCall/all.T Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -12,7 +12,7 @@ module GHC.ByteCode.Asm ( bcoFreeNames, SizedSeq, sizeSS, ssElts, iNTERP_STACK_CHECK_THRESH, - mkTupleInfoLit + mkNativeCallInfoLit ) where import GHC.Prelude @@ -32,7 +32,6 @@ import GHC.Types.Unique.DSet import GHC.Utils.Outputable import GHC.Utils.Panic -import GHC.Utils.Panic.Plain import GHC.Core.TyCon import GHC.Data.FastString @@ -40,7 +39,7 @@ import GHC.Data.SizedSeq import GHC.StgToCmm.Layout ( ArgRep(..) ) import GHC.Cmm.Expr -import GHC.Cmm.CallConv ( tupleRegsCover ) +import GHC.Cmm.CallConv ( allArgRegsCover ) import GHC.Platform import GHC.Platform.Profile @@ -202,7 +201,8 @@ assembleBCO platform (ProtoBCO { protoBCOName = nm (final_insns, final_lits, final_ptrs) <- flip execStateT initial_state $ runAsm platform long_jumps env asm -- precomputed size should be equal to final size - massert (n_insns == sizeSS final_insns) + massertPpr (n_insns == sizeSS final_insns) + (text "bytecode instruction count mismatch") let asm_insns = ssElts final_insns insns_arr = Array.listArray (0, fromIntegral n_insns - 1) asm_insns @@ -351,7 +351,8 @@ largeArg platform w = case platformWordSize platform of fromIntegral (w `shiftR` 32), fromIntegral (w `shiftR` 16), fromIntegral w] - PW4 -> assert (w < fromIntegral (maxBound :: Word32)) $ + PW4 -> assertPpr (w < fromIntegral (maxBound :: Word32)) + (text "largeArg too big:" <+> ppr w) $ [fromIntegral (w `shiftR` 16), fromIntegral w] @@ -388,14 +389,14 @@ assembleI platform i = case i of -> do let ul_bco = assembleBCO platform proto p <- ioptr (liftM BCOPtrBCO ul_bco) emit (push_alts pk) [Op p] - PUSH_ALTS_TUPLE proto tuple_info tuple_proto + PUSH_ALTS_TUPLE proto call_info tuple_proto -> do let ul_bco = assembleBCO platform proto ul_tuple_bco = assembleBCO platform tuple_proto p <- ioptr (liftM BCOPtrBCO ul_bco) p_tup <- ioptr (liftM BCOPtrBCO ul_tuple_bco) info <- int (fromIntegral $ - mkTupleInfoSig platform tuple_info) + mkNativeCallInfoSig platform call_info) emit bci_PUSH_ALTS_T [Op p, Op info, Op p_tup] PUSH_PAD8 -> emit bci_PUSH_PAD8 [] @@ -491,6 +492,7 @@ assembleI platform i = case i of RETURN_TUPLE -> emit bci_RETURN_T [] CCALL off m_addr i -> do np <- addr m_addr emit bci_CCALL [SmallOp off, Op np, SmallOp i] + PRIMCALL -> emit bci_PRIMCALL [] BRK_FUN index uniq cc -> do p1 <- ptr BCOPtrBreakArray q <- int (getKey uniq) np <- addr cc @@ -582,39 +584,47 @@ return_unlifted V64 = error "return_unlifted: vector" platform). -} -maxTupleNativeStackSize :: WordOff -maxTupleNativeStackSize = 62 +maxTupleReturnNativeStackSize :: WordOff +maxTupleReturnNativeStackSize = 62 + +maxPrimCallNativeStackSize :: WordOff +maxPrimCallNativeStackSize = 255 {- - Construct the tuple_info word that stg_ctoi_t and stg_ret_t use - to convert a tuple between the native calling convention and the + Construct the call_info word that stg_ctoi_t, stg_ret_t and stg_primcall + use to convert arguments between the native calling convention and the interpreter. - See Note [GHCi tuple layout] for more information. + See Note [GHCi and native call registers] for more information. -} -mkTupleInfoSig :: Platform -> TupleInfo -> Word32 -mkTupleInfoSig platform TupleInfo{..} - | tupleNativeStackSize > maxTupleNativeStackSize - = pprPanic "mkTupleInfoSig: tuple too big for the bytecode compiler" - (ppr tupleNativeStackSize <+> text "stack words." <+> +mkNativeCallInfoSig :: Platform -> NativeCallInfo -> Word32 +mkNativeCallInfoSig platform NativeCallInfo{..} + | nativeCallType == NativePrimCall && nativeCallStackSpillSize > maxPrimCallNativeStackSize + = pprPanic "mkNativeCallInfoSig: native call too big for the bytecode compiler" + (ppr nativeCallStackSpillSize <+> text "stack words." <+> + text "Use -fobject-code to get around this limit" + ) + | nativeCallType == NativeTupleReturn && nativeCallStackSpillSize > maxTupleReturnNativeStackSize + = pprPanic "mkNativeCallInfoSig: tuple too big for the bytecode compiler" + (ppr nativeCallStackSpillSize <+> text "stack words." <+> text "Use -fobject-code to get around this limit" ) | otherwise - = assert (length regs <= 24) {- 24 bits for bitmap -} - assert (tupleNativeStackSize < 255) {- 8 bits for stack size -} - assert (all (`elem` regs) (regSetToList tupleRegs)) {- all regs accounted for -} + = assertPpr (length regs <= 24) (text "too many registers for bitmap:" <+> ppr (length regs)) {- 24 bits for bitmap -} + assertPpr (nativeCallStackSpillSize < 255) (text "stack spill size too large:" <+> ppr nativeCallStackSpillSize) {- 8 bits for stack size -} + assertPpr (all (`elem` regs) (regSetToList nativeCallRegs)) (text "not all registers accounted for") {- all regs accounted for -} foldl' reg_bit 0 (zip regs [0..]) .|. - (fromIntegral tupleNativeStackSize `shiftL` 24) + (fromIntegral nativeCallStackSpillSize `shiftL` 24) where reg_bit :: Word32 -> (GlobalReg, Int) -> Word32 reg_bit x (r, n) - | r `elemRegSet` tupleRegs = x .|. 1 `shiftL` n - | otherwise = x - regs = tupleRegsCover platform + | r `elemRegSet` nativeCallRegs = x .|. 1 `shiftL` n + | otherwise = x + regs = allArgRegsCover platform -mkTupleInfoLit :: Platform -> TupleInfo -> Literal -mkTupleInfoLit platform tuple_info = - mkLitWord platform . fromIntegral $ mkTupleInfoSig platform tuple_info +mkNativeCallInfoLit :: Platform -> NativeCallInfo -> Literal +mkNativeCallInfoLit platform call_info = + mkLitWord platform . fromIntegral $ mkNativeCallInfoSig platform call_info -- Make lists of host-sized words for literals, so that when the -- words are placed in memory at increasing addresses, the ===================================== compiler/GHC/ByteCode/Instr.hs ===================================== @@ -90,7 +90,7 @@ data BCInstr | PUSH_ALTS (ProtoBCO Name) | PUSH_ALTS_UNLIFTED (ProtoBCO Name) ArgRep | PUSH_ALTS_TUPLE (ProtoBCO Name) -- continuation - !TupleInfo + !NativeCallInfo (ProtoBCO Name) -- tuple return BCO -- Pushing 8, 16 and 32 bits of padding (for constructors). @@ -184,6 +184,8 @@ data BCInstr -- (XXX: inefficient, but I don't know -- what the alignment constraints are.) + | PRIMCALL + -- For doing magic ByteArray passing to foreign calls | SWIZZLE Word16 -- to the ptr N words down the stack, Word16 -- add M (interpreted as a signed 16-bit entity) @@ -269,8 +271,8 @@ instance Outputable BCInstr where ppr (PUSH_ALTS bco) = hang (text "PUSH_ALTS") 2 (ppr bco) ppr (PUSH_ALTS_UNLIFTED bco pk) = hang (text "PUSH_ALTS_UNLIFTED" <+> ppr pk) 2 (ppr bco) - ppr (PUSH_ALTS_TUPLE bco tuple_info tuple_bco) = - hang (text "PUSH_ALTS_TUPLE" <+> ppr tuple_info) + ppr (PUSH_ALTS_TUPLE bco call_info tuple_bco) = + hang (text "PUSH_ALTS_TUPLE" <+> ppr call_info) 2 (ppr tuple_bco $+$ ppr bco) @@ -340,6 +342,7 @@ instance Outputable BCInstr where 0x1 -> text "(interruptible)" 0x2 -> text "(unsafe)" _ -> empty) + ppr PRIMCALL = text "PRIMCALL" ppr (SWIZZLE stkoff n) = text "SWIZZLE " <+> text "stkoff" <+> ppr stkoff <+> text "by" <+> ppr n ppr ENTER = text "ENTER" @@ -382,11 +385,11 @@ bciStackUse (PUSH_ALTS bco) = 2 {- profiling only, restore CCCS -} + bciStackUse (PUSH_ALTS_UNLIFTED bco _) = 2 {- profiling only, restore CCCS -} + 4 + protoBCOStackUse bco bciStackUse (PUSH_ALTS_TUPLE bco info _) = - -- (tuple_bco, tuple_info word, cont_bco, stg_ctoi_t) + -- (tuple_bco, call_info word, cont_bco, stg_ctoi_t) -- tuple - -- (tuple_info, tuple_bco, stg_ret_t) + -- (call_info, tuple_bco, stg_ret_t) 1 {- profiling only -} + - 7 + fromIntegral (tupleSize info) + protoBCOStackUse bco + 7 + fromIntegral (nativeCallSize info) + protoBCOStackUse bco bciStackUse (PUSH_PAD8) = 1 -- overapproximation bciStackUse (PUSH_PAD16) = 1 -- overapproximation bciStackUse (PUSH_PAD32) = 1 -- overapproximation on 64bit arch @@ -443,6 +446,7 @@ bciStackUse RETURN{} = 0 bciStackUse RETURN_UNLIFTED{} = 1 -- pushes stg_ret_X for some X bciStackUse RETURN_TUPLE{} = 1 -- pushes stg_ret_t header bciStackUse CCALL{} = 0 +bciStackUse PRIMCALL{} = 1 -- pushes stg_primcall bciStackUse SWIZZLE{} = 0 bciStackUse BRK_FUN{} = 0 ===================================== compiler/GHC/ByteCode/Types.hs ===================================== @@ -10,7 +10,7 @@ module GHC.ByteCode.Types ( CompiledByteCode(..), seqCompiledByteCode , FFIInfo(..) , RegBitmap(..) - , TupleInfo(..), voidTupleInfo + , NativeCallType(..), NativeCallInfo(..), voidTupleReturnInfo, voidPrimCallInfo , ByteOff(..), WordOff(..) , UnlinkedBCO(..), BCOPtr(..), BCONPtr(..) , ItblEnv, ItblPtr(..) @@ -105,22 +105,32 @@ newtype RegBitmap = RegBitmap { unRegBitmap :: Word32 } See GHC.StgToByteCode.layoutTuple for more details. -} -data TupleInfo = TupleInfo - { tupleSize :: !WordOff -- total size of tuple in words - , tupleRegs :: !GlobalRegSet - , tupleNativeStackSize :: !WordOff {- words spilled on the stack by - GHCs native calling convention -} - } deriving (Show) - -instance Outputable TupleInfo where - ppr TupleInfo{..} = text " ppr tupleSize <+> - text "stack" <+> ppr tupleNativeStackSize <+> - text "regs" <+> - ppr (map (text @SDoc . show) $ regSetToList tupleRegs) <> - char '>' - -voidTupleInfo :: TupleInfo -voidTupleInfo = TupleInfo 0 emptyRegSet 0 + +data NativeCallType = NativePrimCall + | NativeTupleReturn + deriving (Eq) + +data NativeCallInfo = NativeCallInfo + { nativeCallType :: !NativeCallType + , nativeCallSize :: !WordOff -- total size of arguments in words + , nativeCallRegs :: !GlobalRegSet + , nativeCallStackSpillSize :: !WordOff {- words spilled on the stack by + GHCs native calling convention -} + } + +instance Outputable NativeCallInfo where + ppr NativeCallInfo{..} = text " ppr nativeCallSize <+> + text "stack" <+> ppr nativeCallStackSpillSize <+> + text "regs" <+> + ppr (map (text @SDoc . show) $ regSetToList nativeCallRegs) <> + char '>' + + +voidTupleReturnInfo :: NativeCallInfo +voidTupleReturnInfo = NativeCallInfo NativeTupleReturn 0 emptyRegSet 0 + +voidPrimCallInfo :: NativeCallInfo +voidPrimCallInfo = NativeCallInfo NativePrimCall 0 emptyRegSet 0 type ItblEnv = NameEnv (Name, ItblPtr) -- We need the Name in the range so we know which ===================================== compiler/GHC/Cmm/CallConv.hs ===================================== @@ -3,7 +3,7 @@ module GHC.Cmm.CallConv ( assignArgumentsPos, assignStack, realArgRegsCover, - tupleRegsCover + allArgRegsCover ) where import GHC.Prelude @@ -220,12 +220,104 @@ realArgRegsCover platform realLongRegs platform -- we don't save XMM registers if they are not used for parameter passing --- Like realArgRegsCover but always includes the node. This covers the real --- and virtual registers used for unboxed tuples. --- --- Note: if anything changes in how registers for unboxed tuples overlap, --- make sure to also update GHC.StgToByteCode.layoutTuple. -tupleRegsCover :: Platform -> [GlobalReg] -tupleRegsCover platform = +{- + + Note [GHCi and native call registers] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + The GHCi bytecode interpreter does not have access to the STG registers + that the native calling convention uses for passing arguments. It uses + helper stack frames to move values between the stack and registers. + + If only a single register needs to be moved, GHCi uses a specific stack + frame. For example stg_ctoi_R1p saves a heap pointer value from STG register + R1 and stg_ctoi_D1 saves a double precision floating point value from D1. + In the other direction, helpers stg_ret_p and stg_ret_d move a value from + the stack to the R1 and D1 registers, respectively. + + When GHCi needs to move more than one register it cannot use a specific + helper frame. It would simply be impossible to create a helper for all + possible combinations of register values. Instead, there are generic helper + stack frames that use a call_info word that describes the active registers + and the number of stack words used by the arguments of a call. + + These helper stack frames are currently: + + - stg_ret_t: return a tuple to the continuation at the top of + the stack + - stg_ctoi_t: convert a tuple return value to be used in + bytecode + - stg_primcall: call a function + + + The call_info word contains a bitmap of the active registers + for the call and and a stack offset. The layout is as follows: + + - bit 0-23: Bitmap of active registers for the call, the + order corresponds to the list returned by + allArgRegsCover. For example if bit 0 (the least + significant bit) is set, the first register in the + allArgRegsCover list is active. Bit 1 for the + second register in the list and so on. + + - bit 24-31: Unsigned byte, indicating the stack usage of the + call in words (not counting the space ) + + The upper 32 bits on 64 bit platforms are currently unused. + + If a register is smaller than a word on the stack (for example a + single precision float on a 64 bit system), then the stack slot + is padded to a whole word. + + Example: + + If a call has three arguments passed registers and + additional two words of arguments on the stack, then + three bits in the bitmap in bits 0-23 would be set. And + Bit 24-31 would be 00000010 (two in binary). + + The values on the stack before a call to POP_ARG_REGS would + be as follows: + + ... + stack_arg_1 + stack_arg_2 + register_arg_3 + register_arg_2 + register_arg_1 <- Sp + + A call to POP_ARG_REGS(call_info) would move register_arg_1 + to the register corresponding to the lowest set bit in the + call_info word. register_arg_2 would be moved to the register + corresponding to the second lowest set bit, and so on. + + After POP_ARG_REGS(call_info), the stack pointer Sp points + to the first stack slot below the stack arguments. The stack + arguments are still on the stack above Sp, so the stack looks + as follows: + + ... <- Sp + stack_arg_1 + stack_arg_2 + + At this point all the arguments are in place and we are ready + to jump to the native function. + + On x86_64, the double precision (Dn) and single precision + floating (Fn) point registers overlap, e.g. D1 uses the same + physical register as F1. On this platform, the list returned + by allArgRegsCover contains only entries for the double + precision registers. If an argument is passed in register + Fn, the bit corresponding to Dn should be set. + + Note: if anything changes in how registers for native calls overlap, + make sure to also update GHC.StgToByteCode.layoutNativeCall + -} + +-- Like realArgRegsCover but always includes the node. This covers all real +-- and virtual registers actually used for passing arguments. + +allArgRegsCover :: Platform -> [GlobalReg] +allArgRegsCover platform = nub (VanillaReg 1 VGcPtr : realArgRegsCover platform) ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -1233,8 +1233,8 @@ stmtMacros = listToUFM [ ( fsLit "SAVE_REGS", \[] -> emitSaveRegs ), ( fsLit "RESTORE_REGS", \[] -> emitRestoreRegs ), - ( fsLit "PUSH_TUPLE_REGS", \[live_regs] -> emitPushTupleRegs live_regs ), - ( fsLit "POP_TUPLE_REGS", \[live_regs] -> emitPopTupleRegs live_regs ), + ( fsLit "PUSH_ARG_REGS", \[live_regs] -> emitPushArgRegs live_regs ), + ( fsLit "POP_ARG_REGS", \[live_regs] -> emitPopArgRegs live_regs ), ( fsLit "LDV_ENTER", \[e] -> ldvEnter e ), ( fsLit "LDV_RECORD_CREATE", \[e] -> ldvRecordCreate e ), ===================================== compiler/GHC/Cmm/Reg.hs ===================================== @@ -223,7 +223,7 @@ instance Eq GlobalReg where _r1 == _r2 = False -- NOTE: this Ord instance affects the tuple layout in GHCi, see --- Note [GHCi tuple layout] +-- Note [GHCi and native call registers] instance Ord GlobalReg where compare (VanillaReg i _) (VanillaReg j _) = compare i j -- Ignore type when seeking clashes ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -58,7 +58,7 @@ import GHC.Data.FastString import GHC.Utils.Panic import GHC.Utils.Panic.Plain import GHC.Utils.Exception (evaluate) -import GHC.StgToCmm.Closure ( NonVoid(..), fromNonVoid, nonVoidIds ) +import GHC.StgToCmm.Closure ( NonVoid(..), fromNonVoid, nonVoidIds, argPrimRep ) import GHC.StgToCmm.Layout import GHC.Runtime.Heap.Layout hiding (WordOff, ByteOff, wordsToBytes) import GHC.Data.Bitmap @@ -464,10 +464,10 @@ returnUnliftedReps d s szb reps = do [rep] -> return (unitOL $ RETURN_UNLIFTED (toArgRep platform rep)) -- otherwise use RETURN_TUPLE with a tuple descriptor nv_reps -> do - let (tuple_info, args_offsets) = layoutTuple profile 0 (primRepCmmType platform) nv_reps + let (call_info, args_offsets) = layoutNativeCall profile NativeTupleReturn 0 (primRepCmmType platform) nv_reps args_ptrs = map (\(rep, off) -> (isFollowableArg (toArgRep platform rep), off)) args_offsets - tuple_bco <- emitBc (tupleBCO platform tuple_info args_ptrs) - return $ PUSH_UBX (mkTupleInfoLit platform tuple_info) 1 `consOL` + tuple_bco <- emitBc (tupleBCO platform call_info args_ptrs) + return $ PUSH_UBX (mkNativeCallInfoLit platform call_info) 1 `consOL` PUSH_BCO tuple_bco `consOL` unitOL RETURN_TUPLE return ( mkSlideB platform szb (d - s) -- clear to sequel @@ -484,7 +484,11 @@ returnUnboxedTuple d s p es = do profile <- getProfile let platform = profilePlatform profile arg_ty e = primRepCmmType platform (atomPrimRep e) - (tuple_info, tuple_components) = layoutTuple profile d arg_ty es + (call_info, tuple_components) = layoutNativeCall profile + NativeTupleReturn + d + arg_ty + es go _ pushes [] = return (reverse pushes) go !dd pushes ((a, off):cs) = do (push, szb) <- pushAtom dd p a massert (off == dd + szb) @@ -492,7 +496,7 @@ returnUnboxedTuple d s p es = do pushes <- go d [] tuple_components ret <- returnUnliftedReps d s - (wordsToBytes platform $ tupleSize tuple_info) + (wordsToBytes platform $ nativeCallSize call_info) (map atomPrimRep es) return (mconcat pushes `appOL` ret) @@ -648,14 +652,14 @@ schemeT d s p app -- Case 1 schemeT d s p (StgOpApp (StgFCallOp (CCall ccall_spec) _ty) args result_ty) = if isSupportedCConv ccall_spec - then generateCCall d s p ccall_spec result_ty (reverse args) + then generateCCall d s p ccall_spec result_ty args else unsupportedCConvException schemeT d s p (StgOpApp (StgPrimOp op) args _ty) = doTailCall d s p (primOpId op) (reverse args) -schemeT _d _s _p (StgOpApp StgPrimCallOp{} _args _ty) - = unsupportedCConvException +schemeT d s p (StgOpApp (StgPrimCallOp (PrimCall label unit)) args result_ty) + = generatePrimCall d s p label (Just unit) result_ty args -- Case 2: Unboxed tuple schemeT d s p (StgConApp con _cn args _tys) @@ -840,18 +844,18 @@ doCase d s p scrut bndr alts | ubx_frame = wordSize platform | otherwise = 0 - (bndr_size, tuple_info, args_offsets) + (bndr_size, call_info, args_offsets) | ubx_tuple_frame = let bndr_ty = primRepCmmType platform bndr_reps = filter (not.isVoidRep) (bcIdPrimReps bndr) - (tuple_info, args_offsets) = - layoutTuple profile 0 bndr_ty bndr_reps - in ( wordsToBytes platform (tupleSize tuple_info) - , tuple_info + (call_info, args_offsets) = + layoutNativeCall profile NativeTupleReturn 0 bndr_ty bndr_reps + in ( wordsToBytes platform (nativeCallSize call_info) + , call_info , args_offsets ) | otherwise = ( wordsToBytes platform (idSizeW platform bndr) - , voidTupleInfo + , voidTupleReturnInfo , [] ) @@ -885,17 +889,18 @@ doCase d s p scrut bndr alts | isUnboxedTupleType bndr_ty || isUnboxedSumType bndr_ty = let bndr_ty = primRepCmmType platform . bcIdPrimRep tuple_start = d_bndr - (tuple_info, args_offsets) = - layoutTuple profile - 0 - bndr_ty - bndrs + (call_info, args_offsets) = + layoutNativeCall profile + NativeTupleReturn + 0 + bndr_ty + bndrs stack_bot = d_alts p' = Map.insertList [ (arg, tuple_start - - wordsToBytes platform (tupleSize tuple_info) + + wordsToBytes platform (nativeCallSize call_info) + offset) | (arg, offset) <- args_offsets , not (isVoidRep $ bcIdPrimRep arg)] @@ -981,8 +986,8 @@ doCase d s p scrut bndr alts -- unboxed tuples get two more words, the second is a pointer (tuple_bco) (extra_pointers, extra_slots) - | ubx_tuple_frame && profiling = ([1], 3) -- tuple_info, tuple_BCO, CCCS - | ubx_tuple_frame = ([1], 2) -- tuple_info, tuple_BCO + | ubx_tuple_frame && profiling = ([1], 3) -- call_info, tuple_BCO, CCCS + | ubx_tuple_frame = ([1], 2) -- call_info, tuple_BCO | otherwise = ([], 0) bitmap_size = trunc16W $ fromIntegral extra_slots + @@ -1028,8 +1033,8 @@ doCase d s p scrut bndr alts let args_ptrs = map (\(rep, off) -> (isFollowableArg (toArgRep platform rep), off)) args_offsets - tuple_bco <- emitBc (tupleBCO platform tuple_info args_ptrs) - return (PUSH_ALTS_TUPLE alt_bco' tuple_info tuple_bco + tuple_bco <- emitBc (tupleBCO platform call_info args_ptrs) + return (PUSH_ALTS_TUPLE alt_bco' call_info tuple_bco `consOL` scrut_code) else let push_alts | not ubx_frame @@ -1050,14 +1055,15 @@ doCase d s p scrut bndr alts -- The native calling convention uses registers for tuples, but in the -- bytecode interpreter, all values live on the stack. -layoutTuple :: Profile - -> ByteOff - -> (a -> CmmType) - -> [a] - -> ( TupleInfo -- See Note [GHCi TupleInfo] - , [(a, ByteOff)] -- argument, offset on stack - ) -layoutTuple profile start_off arg_ty reps = +layoutNativeCall :: Profile + -> NativeCallType + -> ByteOff + -> (a -> CmmType) + -> [a] + -> ( NativeCallInfo -- See Note [GHCi TupleInfo] + , [(a, ByteOff)] -- argument, offset on stack + ) +layoutNativeCall profile call_type start_off arg_ty reps = let platform = profilePlatform profile (orig_stk_bytes, pos) = assignArgumentsPos profile 0 @@ -1070,7 +1076,7 @@ layoutTuple profile start_off arg_ty reps = -- sort the register parameters by register and add them to the stack regs_order :: Map.Map GlobalReg Int - regs_order = Map.fromList $ zip (tupleRegsCover platform) [0..] + regs_order = Map.fromList $ zip (allArgRegsCover platform) [0..] reg_order :: GlobalReg -> (Int, GlobalReg) reg_order reg | Just n <- Map.lookup reg regs_order = (n, reg) @@ -1099,10 +1105,11 @@ layoutTuple profile start_off arg_ty reps = get_byte_off _ = panic "GHC.StgToByteCode.layoutTuple get_byte_off" - in ( TupleInfo - { tupleSize = bytesToWords platform (ByteOff new_stk_bytes) - , tupleRegs = regs_set - , tupleNativeStackSize = bytesToWords platform + in ( NativeCallInfo + { nativeCallType = call_type + , nativeCallSize = bytesToWords platform (ByteOff new_stk_bytes) + , nativeCallRegs = regs_set + , nativeCallStackSpillSize = bytesToWords platform (ByteOff orig_stk_bytes) } , sortBy (comparing snd) $ @@ -1127,7 +1134,7 @@ usePlainReturn t ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We have the bytecode instructions RETURN_TUPLE and PUSH_ALTS_TUPLE to return and receive arbitrary unboxed tuples, respectively. These - instructions use the helper data tuple_BCO and tuple_info. + instructions use the helper data tuple_BCO and call_info. The helper data is used to convert tuples between GHCs native calling convention (object code), which uses stack and registers, and the bytecode @@ -1139,7 +1146,7 @@ usePlainReturn t ================= Bytecode that returns a tuple first pushes all the tuple fields followed - by the appropriate tuple_info and tuple_BCO onto the stack. It then + by the appropriate call_info and tuple_BCO onto the stack. It then executes the RETURN_TUPLE instruction, which causes the interpreter to push stg_ret_t_info to the top of the stack. The stack (growing down) then looks as follows: @@ -1150,14 +1157,14 @@ usePlainReturn t tuple_field_2 ... tuple_field_n - tuple_info + call_info tuple_BCO stg_ret_t_info <- Sp If next_frame is bytecode, the interpreter will start executing it. If it's object code, the interpreter jumps back to the scheduler, which in turn jumps to stg_ret_t. stg_ret_t converts the tuple to the native - calling convention using the description in tuple_info, and then jumps + calling convention using the description in call_info, and then jumps to next_frame. @@ -1169,13 +1176,13 @@ usePlainReturn t tuple. The PUSH_ALTS_TUPLE instuction contains three pieces of data: * cont_BCO: the continuation that receives the tuple - * tuple_info: see below + * call_info: see below * tuple_BCO: see below The interpreter pushes these onto the stack when the PUSH_ALTS_TUPLE instruction is executed, followed by stg_ctoi_tN_info, with N depending on the number of stack words used by the tuple in the GHC native calling - convention. N is derived from tuple_info. + convention. N is derived from call_info. For example if we expect a tuple with three words on the stack, the stack looks as follows after PUSH_ALTS_TUPLE: @@ -1186,7 +1193,7 @@ usePlainReturn t cont_free_var_2 ... cont_free_var_n - tuple_info + call_info tuple_BCO cont_BCO stg_ctoi_t3_info <- Sp @@ -1206,20 +1213,20 @@ usePlainReturn t that is already on the stack. - The tuple_info word + The call_info word =================== - The tuple_info word describes the stack and STG register (e.g. R1..R6, - D1..D6) usage for the tuple. tuple_info contains enough information to + The call_info word describes the stack and STG register (e.g. R1..R6, + D1..D6) usage for the tuple. call_info contains enough information to convert the tuple between the stack-only bytecode and stack+registers GHC native calling conventions. - See Note [GHCi tuple layout] for more details of how the data is packed - in a single word. + See Note [GHCi and native call registers] for more details of how the + data is packed in a single word. -} -tupleBCO :: Platform -> TupleInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name +tupleBCO :: Platform -> NativeCallInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name tupleBCO platform info pointers = mkProtoBCO platform invented_name body_code (Left []) 0{-no arity-} bitmap_size bitmap False{-is alts-} @@ -1233,15 +1240,103 @@ tupleBCO platform info pointers = -} invented_name = mkSystemVarName (mkPseudoUniqueE 0) (fsLit "tuple") - -- the first word in the frame is the tuple_info word, + -- the first word in the frame is the call_info word, -- which is not a pointer - bitmap_size = trunc16W $ 1 + tupleSize info + bitmap_size = trunc16W $ 1 + nativeCallSize info bitmap = intsToReverseBitmap platform (fromIntegral bitmap_size) $ map ((+1) . fromIntegral . bytesToWords platform . snd) (filter fst pointers) body_code = mkSlideW 0 1 -- pop frame header `snocOL` RETURN_TUPLE -- and add it again +primCallBCO :: Platform -> NativeCallInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name +primCallBCO platform args_info pointers = + mkProtoBCO platform invented_name body_code (Left []) + 0{-no arity-} bitmap_size bitmap False{-is alts-} + + where + {- + The primcall BCO is never referred to by name, so we can get away + with using a fake name here. We will need to change this if we want + to save some memory by sharing the BCO between places that have + the same tuple shape + -} + invented_name = mkSystemVarName (mkPseudoUniqueE 0) (fsLit "primcall") + + -- the first three words in the frame are the BCO describing the + -- pointers in the frame, the call_info word and the pointer + -- to the Cmm function being called. None of these is a pointer that + -- should be followed by the garbage collector + bitmap_size = trunc16W $ 2 + nativeCallSize args_info + bitmap = intsToReverseBitmap platform (fromIntegral bitmap_size) $ + map ((+2) . fromIntegral . bytesToWords platform . snd) + (filter fst pointers) + -- if the primcall BCO is ever run it's a bug, since the BCO should only + -- be pushed immediately before running the PRIMCALL bytecode instruction, + -- which immediately leaves the interpreter to jump to the stg_primcall_info + -- Cmm function + body_code = unitOL CASEFAIL + +-- ----------------------------------------------------------------------------- +-- Deal with a primitive call to native code. + +generatePrimCall + :: StackDepth + -> Sequel + -> BCEnv + -> CLabelString -- where to call + -> Maybe Unit + -> Type + -> [StgArg] -- args (atoms) + -> BcM BCInstrList +generatePrimCall d s p target _mb_unit _result_ty args + = do + profile <- getProfile + let + platform = profilePlatform profile + + non_void VoidRep = False + non_void _ = True + + nv_args :: [StgArg] + nv_args = filter (non_void . argPrimRep) args + + (args_info, args_offsets) = + layoutNativeCall profile + NativePrimCall + d + (primRepCmmType platform . argPrimRep) + nv_args + + args_ptrs :: [(Bool, ByteOff)] + args_ptrs = + map (\(r, off) -> + (isFollowableArg (toArgRep platform . argPrimRep $ r), off)) + args_offsets + + push_target = PUSH_UBX (LitLabel target Nothing IsFunction) 1 + push_info = PUSH_UBX (mkNativeCallInfoLit platform args_info) 1 + {- + compute size to move payload (without stg_primcall_info header) + + size of arguments plus three words for: + - function pointer to the target + - call_info word + - BCO to describe the stack frame + -} + szb = wordsToBytes platform (nativeCallSize args_info + 3) + go _ pushes [] = return (reverse pushes) + go !dd pushes ((a, off):cs) = do (push, szb) <- pushAtom dd p a + massert (off == dd + szb) + go (dd + szb) (push:pushes) cs + push_args <- go d [] args_offsets + args_bco <- emitBc (primCallBCO platform args_info args_ptrs) + return $ mconcat push_args `appOL` + (push_target `consOL` + push_info `consOL` + PUSH_BCO args_bco `consOL` + (mkSlideB platform szb (d - s) `appOL` unitOL PRIMCALL)) + -- ----------------------------------------------------------------------------- -- Deal with a CCall. @@ -1259,11 +1354,17 @@ generateCCall -> Type -> [StgArg] -- args (atoms) -> BcM BCInstrList -generateCCall d0 s p (CCallSpec target cconv safety) result_ty args_r_to_l +generateCCall d0 s p (CCallSpec target PrimCallConv _) result_ty args + | (StaticTarget _ label mb_unit _) <- target + = generatePrimCall d0 s p label mb_unit result_ty args + | otherwise + = panic "GHC.StgToByteCode.generateCCall: primcall convention only supports static targets" +generateCCall d0 s p (CCallSpec target cconv safety) result_ty args = do profile <- getProfile let + args_r_to_l = reverse args platform = profilePlatform profile -- useful constants addr_size_b :: ByteOff @@ -2007,7 +2108,7 @@ isSupportedCConv :: CCallSpec -> Bool isSupportedCConv (CCallSpec _ cconv _) = case cconv of CCallConv -> True -- we explicitly pattern match on every StdCallConv -> True -- convention to ensure that a warning - PrimCallConv -> False -- is triggered when a new one is added + PrimCallConv -> True -- is triggered when a new one is added JavaScriptCallConv -> False CApiConv -> True ===================================== compiler/GHC/StgToCmm/Foreign.hs ===================================== @@ -15,8 +15,8 @@ module GHC.StgToCmm.Foreign ( emitLoadThreadState, emitSaveRegs, emitRestoreRegs, - emitPushTupleRegs, - emitPopTupleRegs, + emitPushArgRegs, + emitPopArgRegs, loadThreadState, emitOpenNursery, emitCloseNursery, @@ -349,7 +349,7 @@ emitRestoreRegs = do -- bytecode interpreter. -- -- The "live registers" bitmap corresponds to the list of registers given by --- 'tupleRegsCover', with the least significant bit indicating liveness of +-- 'allArgRegsCover', with the least significant bit indicating liveness of -- the first register in the list. -- -- Each register is saved to a stack slot of one or more machine words, even @@ -362,12 +362,12 @@ emitRestoreRegs = do -- if((mask & 2) != 0) { Sp_adj(-1); Sp(0) = R2; } -- if((mask & 1) != 0) { Sp_adj(-1); Sp(0) = R1; } -- --- See Note [GHCi tuple layout] +-- See Note [GHCi and native call registers] -emitPushTupleRegs :: CmmExpr -> FCode () -emitPushTupleRegs regs_live = do +emitPushArgRegs :: CmmExpr -> FCode () +emitPushArgRegs regs_live = do platform <- getPlatform - let regs = zip (tupleRegsCover platform) [0..] + let regs = zip (allArgRegsCover platform) [0..] save_arg (reg, n) = let mask = CmmLit (CmmInt (1 `shiftL` n) (wordWidth platform)) live = cmmAndWord platform regs_live mask @@ -381,11 +381,11 @@ emitPushTupleRegs regs_live = do in mkCmmIfThen cond $ catAGraphs [adj_sp, save_reg] emit . catAGraphs =<< mapM save_arg (reverse regs) --- | Pop a subset of STG registers from the stack (see 'emitPushTupleRegs') -emitPopTupleRegs :: CmmExpr -> FCode () -emitPopTupleRegs regs_live = do +-- | Pop a subset of STG registers from the stack (see 'emitPushArgRegs') +emitPopArgRegs :: CmmExpr -> FCode () +emitPopArgRegs regs_live = do platform <- getPlatform - let regs = zip (tupleRegsCover platform) [0..] + let regs = zip (allArgRegsCover platform) [0..] save_arg (reg, n) = let mask = CmmLit (CmmInt (1 `shiftL` n) (wordWidth platform)) live = cmmAndWord platform regs_live mask ===================================== rts/Disassembler.c ===================================== @@ -83,6 +83,9 @@ disInstr ( StgBCO *bco, int pc ) debugBelch("CCALL marshaller at 0x%" FMT_HexWord "\n", literals[instrs[pc]] ); pc += 1; break; + case bci_PRIMCALL: + debugBelch("PRIMCALL\n"); + break; case bci_STKCHECK: { StgWord stk_words_reqd = BCO_GET_LARGE_ARG + 1; debugBelch("STKCHECK %" FMT_Word "\n", (W_)stk_words_reqd ); ===================================== rts/Interpreter.c ===================================== @@ -2038,6 +2038,12 @@ run_BCO: goto nextInsn; } + case bci_PRIMCALL: { + Sp_subW(1); + SpW(0) = (W_)&stg_primcall_info; + RETURN_TO_SCHEDULER_NO_PAUSE(ThreadRunGHC, ThreadYielding); + } + case bci_CCALL: { void *tok; int stk_offset = BCO_NEXT; ===================================== rts/RtsSymbols.c ===================================== @@ -602,6 +602,7 @@ extern char **environ; SymI_HasDataProto(stg_ret_l_info) \ SymI_HasDataProto(stg_ret_t_info) \ SymI_HasDataProto(stg_ctoi_t) \ + SymI_HasDataProto(stg_primcall_info) \ SymI_HasDataProto(stg_gc_prim_p) \ SymI_HasDataProto(stg_gc_prim_pp) \ SymI_HasDataProto(stg_gc_prim_n) \ ===================================== rts/StgMiscClosures.cmm ===================================== @@ -366,20 +366,10 @@ MK_STG_CTOI_T(61) MK_STG_CTOI_T(62) /* - Note [GHCi tuple layout] - ~~~~~~~~~~~~~~~~~~~~~~~~ - the tuple_info word describes the register and stack usage of the tuple: + Convert a tuple return value to be used in bytecode. - [ ssss ssss rrrr rrrr rrrr rrrr rrrr rrrr ] - - - r: bitmap of live registers, corresponding to the list of registers - returned by GHC.Cmm.CallConv.tupleRegsCover (the least significant - bit corresponds to the first element in the list) - - s: number of words on stack (in addition to registers) - - The order of the live registers in the bitmap is the same as the list - given by GHC.Cmm.CallConv.tupleRegsCover, with the least significant - bit corresponding to the first register in the list. + See Note [GHCi and native call registers] for information on how + values are moved between the stack and registers. */ stg_ctoi_t @@ -402,7 +392,7 @@ stg_ctoi_t Sp = Sp - WDS(tuple_stack); - PUSH_TUPLE_REGS(tuple_info); + PUSH_ARG_REGS(tuple_info); /* jump to the BCO that will finish the return of the tuple */ Sp_adj(-3); @@ -423,13 +413,57 @@ INFO_TABLE_RET( stg_ret_t, RET_BCO ) /* number of words spilled on stack */ tuple_stack = (tuple_info >> 24) & 0xff; - POP_TUPLE_REGS(tuple_info); + POP_ARG_REGS(tuple_info); /* Sp points to the topmost argument now */ jump %ENTRY_CODE(Sp(tuple_stack)) [*]; // NB. all registers live! } + /* + + The stg_primcall frame is used by the bytecode interpreter to call + a Cmm function. The frame contains a call_info word that contains + a bitmap describing the register arguments. + + When the target function is called, Sp points to the topmost stack + argument. + + ... + next_stack_frame + arg_1 + arg_2 + ... + arg_n + target_funptr (pointer to the function we're calling) + call_info (describes the registers containing the arguments) + primcall_BCO (contains bitmap describing pointers in args) + stg_primcall_info <- Sp + + See Note [GHCi and native call registers] for information on the call_info + word and how registers are moved between the stack and registers. + + */ + +INFO_TABLE_RET ( stg_primcall, RET_BCO ) +{ + W_ args_info, prim_fun; + + /* Sp(1) would be the BCO containing the stack description bitmap */ + args_info = Sp(2); + prim_fun = Sp(3); + + Sp_adj(4); + + /* Sp points to the top of the register arguments now, + load them into actual registers */ + POP_ARG_REGS(args_info); + + /* Sp points to the topmost stack argument now */ + + jump prim_fun [*]; // NB. all registers live! +} + /* * Dummy info table pushed on the top of the stack when the interpreter * should apply the BCO on the stack to its arguments, also on the ===================================== rts/include/rts/Bytecodes.h ===================================== @@ -112,6 +112,8 @@ #define bci_TESTLT_W8 85 #define bci_TESTEQ_W8 86 +#define bci_PRIMCALL 87 + /* If you need to go past 255 then you will run into the flags */ /* If you need to go below 0x0100 then you will run into the instructions */ ===================================== rts/include/stg/MiscClosures.h ===================================== @@ -160,6 +160,7 @@ RTS_RET(stg_ctoi_t60); RTS_RET(stg_ctoi_t61); RTS_RET(stg_ctoi_t62); +RTS_RET(stg_primcall); RTS_RET(stg_apply_interp); RTS_RET(stg_dead_thread); ===================================== testsuite/tests/ghci/prog014/prog014.T ===================================== @@ -1,6 +1,5 @@ test('prog014', [extra_files(['Primop.hs', 'dummy.c']), - expect_fail, # bytecode compiler doesn't support foreign import prim extra_run_opts('dummy.o'), pre_cmd('$MAKE -s --no-print-directory prog014')], ghci_script, ['prog014.script']) ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs ===================================== @@ -0,0 +1,224 @@ +{-# LANGUAGE ForeignFunctionInterface, GHCForeignImportPrim, UnliftedFFITypes, MagicHash, UnboxedTuples #-} + +module Main where + +import GHC.Int +import GHC.Word +import GHC.Prim +import GHC.Exts +import GHC.Types +import Unsafe.Coerce +import GHC.IO + +data Box (a :: UnliftedType) = MkBox a + +i2a :: Int -> Any +i2a = unsafeCoerce + +a2i :: Any -> Int +a2i = unsafeCoerce + +main :: IO () +main = do + + let i8s :: [Int8] + i8s = [0, -1, 1, minBound, maxBound] + + i16s :: [Int16] + i16s = [0, -1, 1, minBound, maxBound] + + i32s :: [Int32] + i32s = [0, -1, 1, minBound, maxBound] + + i64s :: [Int64] + i64s = [0, -1, 1, minBound, maxBound] + + ws :: [Word] + ws = [0, 1, 2, maxBound] + + fs :: [Float] + fs = [-0, 0, -1, 1, -2, 2, 1/0, 1e37, -1e-37] + + ds :: [Double] + ds = [-0, 0, -1, 1, -2, 2, 1/0, 1e307, -1e-307] + + ls :: [Word64] + ls = [0, 1, 2, 4294967296, maxBound] + + mi2a :: Maybe Integer -> Any + mi2a = unsafeCoerce + + a2mi :: Any -> Maybe Integer + a2mi = unsafeCoerce + + a0, a1, a2, a3 :: Any + a0 = mi2a Nothing + a1 = mi2a (Just 1) + a2 = mi2a (Just 18446744073709551617) + a3 = mi2a (Just (-18446744073709551617)) + + as :: [Any] + as = [a0, a1, a2, a3] + + + putStrLn "zero arguments" + IO (\st -> case cmm_zero st of (# st' #) -> (# st', () #)) + print =<< IO (\st -> case cmm_zero_w st of (# st', w #) -> (# st', W# w #)) + print =<< IO (\st -> case cmm_zero_d st of (# st', w #) -> (# st', D# w #)) + print =<< IO (\st -> case cmm_zero_f st of (# st', w #) -> (# st', F# w #)) + + -- XXX zero argument functions + + putStrLn "one argument functions" + print [ I8# (cmm_one1_i8 x) | (I8# x) <- i8s ] + print [ I16# (cmm_one1_i16 x) | (I16# x) <- i16s ] + print [ I32# (cmm_one1_i32 x) | (I32# x) <- i32s ] + print [ I64# (cmm_one1_i64 x) | (I64# x) <- i64s ] + print [ case cmm_one1_p x of (# y #) -> a2mi y | x <- as ] + print [ W# (cmm_one1_w x) | (W# x) <- ws ] + print [ F# (cmm_one1_f x) | (F# x) <- fs ] + print [ D# (cmm_one1_d x) | (D# x) <- ds ] + print [ W64# (cmm_one1_l x) | (W64# x) <- ls ] + + print [ case cmm_one2_i8 x of (# y1, y2 #) -> (I8# y1, I8# y2) | (I8# x) <- i8s ] + print [ case cmm_one2_i16 x of (# y1, y2 #) -> (I16# y1, I16# y2) | (I16# x) <- i16s ] + print [ case cmm_one2_i32 x of (# y1, y2 #) -> (I32# y1, I32# y2) | (I32# x) <- i32s ] + print [ case cmm_one2_i64 x of (# y1, y2 #) -> (I64# y1, I64# y2) | (I64# x) <- i64s ] + print [ case cmm_one2_p x of (# y1, y2 #) -> (a2mi y1, a2mi y2) | x <- as ] + print [ case cmm_one2_w x of (# y1, y2 #) -> (W# y1, W# y2) | (W# x) <- ws ] + print [ case cmm_one2_f x of (# y1, y2 #) -> (F# y1, F# y2) | (F# x) <- fs ] + print [ case cmm_one2_d x of (# y1, y2 #) -> (D# y1, D# y2) | (D# x) <- ds ] + print [ case cmm_one2_l x of (# y1, y2 #) -> (W64# y1, W64# y2) | (W64# x) <- ls ] + + putStrLn "two argument functions" + print [ I8# (cmm_two1_i8 x1 x2) | (I8# x1) <- i8s, (I8# x2) <- i8s ] + print [ I16# (cmm_two1_i16 x1 x2) | (I16# x1) <- i16s, (I16# x2) <- i16s ] + print [ I32# (cmm_two1_i32 x1 x2) | (I32# x1) <- i32s, (I32# x2) <- i32s ] + print [ I64# (cmm_two1_i64 x1 x2) | (I64# x1) <- i64s, (I64# x2) <- i64s ] + print [ case cmm_two1_p x1 x2 of (# y #) -> a2mi y | x1 <- as, x2 <- as ] + print [ W# (cmm_two1_w x1 x2) | (W# x1) <- ws, (W# x2) <- ws ] + print [ F# (cmm_two1_f x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_two1_d x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ W64# (cmm_two1_l x1 x2) | (W64# x1) <- ls, (W64# x2) <- ls ] + + print [ I8# (cmm_two2_i8 x1 x2) | (I8# x1) <- i8s, (I8# x2) <- i8s ] + print [ I16# (cmm_two2_i16 x1 x2) | (I16# x1) <- i16s, (I16# x2) <- i16s ] + print [ I32# (cmm_two2_i32 x1 x2) | (I32# x1) <- i32s, (I32# x2) <- i32s ] + print [ I64# (cmm_two2_i64 x1 x2) | (I64# x1) <- i64s, (I64# x2) <- i64s ] + print [ case cmm_two2_p x1 x2 of (# y #) -> a2mi y | x1 <- as, x2 <- as ] + print [ W# (cmm_two2_w x1 x2) | (W# x1) <- ws, (W# x2) <- ws ] + print [ F# (cmm_two2_f x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_two2_d x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ W64# (cmm_two2_l x1 x2) | (W64# x1) <- ls, (W64# x2) <- ls ] + + putStrLn "additional floating point tests" + print [ F# (cmm_floating_1 x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_floating_2 x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ F# (cmm_floating_3 x1 x2) | (F# x1) <- fs, (D# x2) <- ds ] + print [ D# (cmm_floating_4 x1 x2) | (F# x1) <- fs, (D# x2) <- ds ] + print [ case cmm_floating_5 x1 x2 3.0e1# 4.0e2## 5.0e3# 6.0e4## 7.0e5# 8.0e6## of (# y1, y2 #) -> (F# y1, D# y2) + | (F# x1) <- fs, (D# x2) <- ds ] + print [ case cmm_floating_6 x1 x2 3.0e1## 4.0e2# 5.0e3## 6.0e4# 7.0e5## 8.0e6# of (# y1, y2 #) -> (D# y1, F# y2) + | (D# x1) <- ds, (F# x2) <- fs ] + print [ case cmm_floating_7 w1 x1 x2 + 4## 5.0e1# 6.0e2## + 7## 8.0e3# 9.0e4## + 10## 11.0e5# 12.0e6## + 13## 14.0e7# 15.0e8## + 16## 17.0e9# 18.0e10## + 19## 20.0e11# 21.0e12## of (# y1, y2, y3 #) -> (W# y1, F# y2, D# y3) + | (W# w1) <- ws, (F# x1) <- fs, (D# x2) <- ds ] + + putStrLn "various sized tuple returns" + print [ case cmm_tuple_1 x1 x2 3## of (# y1, y2, y3 #) -> (W# y1, W# y2, W# y3) | (W# x1) <- ws, (W# x2) <- ws] + print [ case cmm_tuple_2 x1 x2 3## 4## a0 a1 7.0## 8.0## a2 a3 11.0# 12.0# + of (# y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12 #) -> + (F# y1, F# y2, a2mi y3, a2mi y4, D# y5, D# y6, a2mi y7, a2mi y8, W# y9, W# y10, a2mi y11, a2mi y12) + | x1 <- as, x2 <- as ] + print [ case cmm_tuple_3 x1 x2 a0 3.0## a1 5.0# + of (# y1, y2, y3, y4, y5, y6 #) -> (F# y1, a2mi y2, D# y3, a2mi y4, W# y5, a2mi y6) + | x1 <- as, (W# x2) <- ws ] + print [ case cmm_tuple_4 x1 x2 of (# y1, y2 #) -> (a2mi y1, a2mi y2) | x1 <- as, x2 <- as ] + + putStrLn "arrays" + MkBox marr0 <- IO (\s -> case newArray# 10# a0 s of (# s', a #) -> (# s', MkBox a #)) + MkBox marr1 <- IO (\s -> case newArray# 12# a1 s of (# s', a #) -> (# s', MkBox a #)) + MkBox arr0 <- IO (\s -> case unsafeFreezeArray# marr0 s of (# s', a #) -> (# s', MkBox a #)) + MkBox arr1 <- IO (\s -> case unsafeFreezeArray# marr1 s of (# s', a #) -> (# s', MkBox a #)) + print (I# (cmm_array_1 arr0), I# (cmm_array_1 arr1)) + case cmm_array_2 arr0 arr1 of (# arr2, arr3 #) -> print (I# (cmm_array_1 arr2), I# (cmm_array_1 arr3)) + + +-- XXX why don't we accept State# RealWorld -> State# RealWorld ? +foreign import prim cmm_zero :: State# RealWorld -> (# State# RealWorld #) +foreign import prim cmm_zero_w :: State# RealWorld -> (# State# RealWorld, Word# #) +foreign import prim cmm_zero_d :: State# RealWorld -> (# State# RealWorld, Double# #) +foreign import prim cmm_zero_f :: State# RealWorld -> (# State# RealWorld, Float# #) + +-- one argument functions +foreign import prim cmm_one1_i8 :: Int8# -> Int8# +foreign import prim cmm_one1_i16 :: Int16# -> Int16# +foreign import prim cmm_one1_i32 :: Int32# -> Int32# +foreign import prim cmm_one1_i64 :: Int64# -> Int64# +foreign import prim cmm_one1_p :: Any -> (# Any #) +foreign import prim cmm_one1_w :: Word# -> Word# +foreign import prim cmm_one1_f :: Float# -> Float# +foreign import prim cmm_one1_d :: Double# -> Double# +foreign import prim cmm_one1_l :: Word64# -> Word64# + +foreign import prim cmm_one2_i8 :: Int8# -> (# Int8#, Int8# #) +foreign import prim cmm_one2_i16 :: Int16# -> (# Int16#, Int16# #) +foreign import prim cmm_one2_i32 :: Int32# -> (# Int32#, Int32# #) +foreign import prim cmm_one2_i64 :: Int64# -> (# Int64#, Int64# #) +foreign import prim cmm_one2_p :: Any -> (# Any, Any #) +foreign import prim cmm_one2_w :: Word# -> (# Word#, Word# #) +foreign import prim cmm_one2_f :: Float# -> (# Float#, Float# #) +foreign import prim cmm_one2_d :: Double# -> (# Double#, Double# #) +foreign import prim cmm_one2_l :: Word64# -> (# Word64#, Word64# #) + +-- two argument functions +foreign import prim cmm_two1_i8 :: Int8# -> Int8# -> Int8# +foreign import prim cmm_two1_i16 :: Int16# -> Int16# -> Int16# +foreign import prim cmm_two1_i32 :: Int32# -> Int32# -> Int32# +foreign import prim cmm_two1_i64 :: Int64# -> Int64# -> Int64# +foreign import prim cmm_two1_p :: Any -> Any -> (# Any #) +foreign import prim cmm_two1_w :: Word# -> Word# -> Word# +foreign import prim cmm_two1_f :: Float# -> Float# -> Float# +foreign import prim cmm_two1_d :: Double# -> Double# -> Double# +foreign import prim cmm_two1_l :: Word64# -> Word64# -> Word64# + +foreign import prim cmm_two2_i8 :: Int8# -> Int8# -> Int8# +foreign import prim cmm_two2_i16 :: Int16# -> Int16# -> Int16# +foreign import prim cmm_two2_i32 :: Int32# -> Int32# -> Int32# +foreign import prim cmm_two2_i64 :: Int64# -> Int64# -> Int64# +foreign import prim cmm_two2_p :: Any -> Any -> (# Any #) +foreign import prim cmm_two2_w :: Word# -> Word# -> Word# +foreign import prim cmm_two2_f :: Float# -> Float# -> Float# +foreign import prim cmm_two2_d :: Double# -> Double# -> Double# +foreign import prim cmm_two2_l :: Word64# -> Word64# -> Word64# + +{- additional tests for floating point, since D_ and F_ registers + overlap on some platforms -} + +foreign import prim cmm_floating_1 :: Float# -> Float# -> Float# +foreign import prim cmm_floating_2 :: Double# -> Double# -> Double# +foreign import prim cmm_floating_3 :: Float# -> Double# -> Float# +foreign import prim cmm_floating_4 :: Float# -> Double# -> Double# +foreign import prim cmm_floating_5 :: Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> (# Float#, Double# #) +foreign import prim cmm_floating_6 :: Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> (# Double#, Float# #) +foreign import prim cmm_floating_7 :: Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> (# Word#, Float#, Double# #) +-- various sized tuple returns + +foreign import prim cmm_tuple_1 :: Word# -> Word# -> Word# -> (# Word# , Word#, Word# #) +foreign import prim cmm_tuple_2 :: Any -> Any -> Word# -> Word# -> Any -> Any -> Double# -> Double# -> Any -> Any -> Float# -> Float# -> + (# Float#, Float#, Any, Any, Double#, Double#, Any, Any, Word#, Word#, Any, Any #) +foreign import prim cmm_tuple_3 :: Any -> Word# -> Any -> Double# -> Any -> Float# -> + (# Float#, Any, Double#, Any, Word#, Any #) +foreign import prim cmm_tuple_4 :: Any -> Any -> (# Any, Any #) + +-- boxed primitive types + +-- get the length of an array +foreign import prim cmm_array_1 :: Array# Any -> Int# +-- return some arrays +foreign import prim cmm_array_2 :: Array# Any -> Array# Any -> (# Array# Any, Array# Any #) ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout ===================================== @@ -0,0 +1,58 @@ +zero arguments +123 +1.0 +1.0 +one argument functions +[0,-1,1,-128,127] +[0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,18446744073709551615] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615] +[(0,0),(-1,-1),(1,1),(-128,-128),(127,127)] +[(0,0),(-1,-1),(1,1),(-32768,-32768),(32767,32767)] +[(0,0),(-1,-1),(1,1),(-2147483648,-2147483648),(2147483647,2147483647)] +[(0,0),(-1,-1),(1,1),(-9223372036854775808,-9223372036854775808),(9223372036854775807,9223372036854775807)] +[(Nothing,Nothing),(Just 1,Just 1),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just (-18446744073709551617))] +[(0,0),(1,1),(2,2),(18446744073709551615,18446744073709551615)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e37,1.0e37),(-1.0e-37,-1.0e-37)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e307,1.0e307),(-1.0e-307,-1.0e-307)] +[(0,0),(1,1),(2,2),(4294967296,4294967296),(18446744073709551615,18446744073709551615)] +two argument functions +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-128,-128,-128,-128,-128,127,127,127,127,127] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-32768,-32768,-32768,-32768,-32768,32767,32767,32767,32767,32767] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,2147483647,2147483647,2147483647,2147483647,2147483647] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807] +[Nothing,Nothing,Nothing,Nothing,Just 1,Just 1,Just 1,Just 1,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617)] +[0,0,0,0,1,1,1,1,2,2,2,2,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307] +[0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,4294967296,4294967296,4294967296,4294967296,4294967296,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127] +[0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,18446744073709551615,0,1,2,18446744073709551615,0,1,2,18446744073709551615,0,1,2,18446744073709551615] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615] +additional floating point tests +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e37,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e37,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e37,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e37,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,Infinity,2.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-2.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e307,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e307,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e307,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e307,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,Infinity,2.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-2.0e-307] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e307),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e307),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e307),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e307),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e307),(Infinity,8060400.0),(1.0e37,8060400.0),(1.0e37,8060400.0),(1.0e37,8060399.0),(1.0e37,8060401.0),(1.0e37,8060398.0),(1.0e37,8060402.0),(1.0e37,Infinity),(1.0e37,1.0e307),(1.0e37,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0)] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e37),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e37),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e37),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e37),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e37),(Infinity,8060400.0),(1.0e307,8060400.0),(1.0e307,8060400.0),(1.0e307,8060399.0),(1.0e307,8060401.0),(1.0e307,8060398.0),(1.0e307,8060402.0),(1.0e307,Infinity),(1.0e307,1.0e37),(1.0e307,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0)] +[(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.1181512090599e13),(69,Infinity,2.1181512090601e13),(69,Infinity,2.1181512090598e13),(69,Infinity,2.1181512090602e13),(69,Infinity,Infinity),(69,Infinity,1.0e307),(69,Infinity,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.1181512090599e13),(69,1.0e37,2.1181512090601e13),(69,1.0e37,2.1181512090598e13),(69,1.0e37,2.1181512090602e13),(69,1.0e37,Infinity),(69,1.0e37,1.0e307),(69,1.0e37,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.1181512090599e13),(70,Infinity,2.1181512090601e13),(70,Infinity,2.1181512090598e13),(70,Infinity,2.1181512090602e13),(70,Infinity,Infinity),(70,Infinity,1.0e307),(70,Infinity,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.1181512090599e13),(70,1.0e37,2.1181512090601e13),(70,1.0e37,2.1181512090598e13),(70,1.0e37,2.1181512090602e13),(70,1.0e37,Infinity),(70,1.0e37,1.0e307),(70,1.0e37,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.1181512090599e13),(71,Infinity,2.1181512090601e13),(71,Infinity,2.1181512090598e13),(71,Infinity,2.1181512090602e13),(71,Infinity,Infinity),(71,Infinity,1.0e307),(71,Infinity,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.1181512090599e13),(71,1.0e37,2.1181512090601e13),(71,1.0e37,2.1181512090598e13),(71,1.0e37,2.1181512090602e13),(71,1.0e37,Infinity),(71,1.0e37,1.0e307),(71,1.0e37,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.1181512090599e13),(68,Infinity,2.1181512090601e13),(68,Infinity,2.1181512090598e13),(68,Infinity,2.1181512090602e13),(68,Infinity,Infinity),(68,Infinity,1.0e307),(68,Infinity,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.1181512090599e13),(68,1.0e37,2.1181512090601e13),(68,1.0e37,2.1181512090598e13),(68,1.0e37,2.1181512090602e13),(68,1.0e37,Infinity),(68,1.0e37,1.0e307),(68,1.0e37,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13)] +various sized tuple returns +[(3,0,0),(3,1,0),(3,2,0),(3,18446744073709551615,0),(3,0,1),(3,1,1),(3,2,1),(3,18446744073709551615,1),(3,0,2),(3,1,2),(3,2,2),(3,18446744073709551615,2),(3,0,18446744073709551615),(3,1,18446744073709551615),(3,2,18446744073709551615),(3,18446744073709551615,18446744073709551615)] +[(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just (-18446744073709551617))] +[(5.0,Just 1,3.0,Nothing,0,Nothing),(5.0,Just 1,3.0,Nothing,1,Nothing),(5.0,Just 1,3.0,Nothing,2,Nothing),(5.0,Just 1,3.0,Nothing,18446744073709551615,Nothing),(5.0,Just 1,3.0,Nothing,0,Just 1),(5.0,Just 1,3.0,Nothing,1,Just 1),(5.0,Just 1,3.0,Nothing,2,Just 1),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just 1),(5.0,Just 1,3.0,Nothing,0,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,1,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,2,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,0,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,1,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,2,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just (-18446744073709551617))] +[(Nothing,Nothing),(Just 1,Nothing),(Just 18446744073709551617,Nothing),(Just (-18446744073709551617),Nothing),(Nothing,Just 1),(Just 1,Just 1),(Just 18446744073709551617,Just 1),(Just (-18446744073709551617),Just 1),(Nothing,Just 18446744073709551617),(Just 1,Just 18446744073709551617),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just 18446744073709551617),(Nothing,Just (-18446744073709551617)),(Just 1,Just (-18446744073709551617)),(Just 18446744073709551617,Just (-18446744073709551617)),(Just (-18446744073709551617),Just (-18446744073709551617))] +arrays +(11,13) +(13,11) ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout-ws-32 ===================================== @@ -0,0 +1,58 @@ +zero arguments +123 +1.0 +1.0 +one argument functions +[0,-1,1,-128,127] +[0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,4294967295] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615] +[(0,0),(-1,-1),(1,1),(-128,-128),(127,127)] +[(0,0),(-1,-1),(1,1),(-32768,-32768),(32767,32767)] +[(0,0),(-1,-1),(1,1),(-2147483648,-2147483648),(2147483647,2147483647)] +[(0,0),(-1,-1),(1,1),(-9223372036854775808,-9223372036854775808),(9223372036854775807,9223372036854775807)] +[(Nothing,Nothing),(Just 1,Just 1),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just (-18446744073709551617))] +[(0,0),(1,1),(2,2),(4294967295,4294967295)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e37,1.0e37),(-1.0e-37,-1.0e-37)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e307,1.0e307),(-1.0e-307,-1.0e-307)] +[(0,0),(1,1),(2,2),(4294967296,4294967296),(18446744073709551615,18446744073709551615)] +two argument functions +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-128,-128,-128,-128,-128,127,127,127,127,127] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-32768,-32768,-32768,-32768,-32768,32767,32767,32767,32767,32767] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,2147483647,2147483647,2147483647,2147483647,2147483647] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807] +[Nothing,Nothing,Nothing,Nothing,Just 1,Just 1,Just 1,Just 1,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617)] +[0,0,0,0,1,1,1,1,2,2,2,2,4294967295,4294967295,4294967295,4294967295] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307] +[0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,4294967296,4294967296,4294967296,4294967296,4294967296,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127] +[0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,4294967295,0,1,2,4294967295,0,1,2,4294967295,0,1,2,4294967295] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615] +additional floating point tests +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e37,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e37,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e37,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e37,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,Infinity,2.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-2.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e307,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e307,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e307,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e307,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,Infinity,2.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-2.0e-307] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e307),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e307),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e307),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e307),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e307),(Infinity,8060400.0),(1.0e37,8060400.0),(1.0e37,8060400.0),(1.0e37,8060399.0),(1.0e37,8060401.0),(1.0e37,8060398.0),(1.0e37,8060402.0),(1.0e37,Infinity),(1.0e37,1.0e307),(1.0e37,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0)] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e37),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e37),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e37),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e37),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e37),(Infinity,8060400.0),(1.0e307,8060400.0),(1.0e307,8060400.0),(1.0e307,8060399.0),(1.0e307,8060401.0),(1.0e307,8060398.0),(1.0e307,8060402.0),(1.0e307,Infinity),(1.0e307,1.0e37),(1.0e307,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0)] +[(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.1181512090599e13),(69,Infinity,2.1181512090601e13),(69,Infinity,2.1181512090598e13),(69,Infinity,2.1181512090602e13),(69,Infinity,Infinity),(69,Infinity,1.0e307),(69,Infinity,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.1181512090599e13),(69,1.0e37,2.1181512090601e13),(69,1.0e37,2.1181512090598e13),(69,1.0e37,2.1181512090602e13),(69,1.0e37,Infinity),(69,1.0e37,1.0e307),(69,1.0e37,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.1181512090599e13),(70,Infinity,2.1181512090601e13),(70,Infinity,2.1181512090598e13),(70,Infinity,2.1181512090602e13),(70,Infinity,Infinity),(70,Infinity,1.0e307),(70,Infinity,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.1181512090599e13),(70,1.0e37,2.1181512090601e13),(70,1.0e37,2.1181512090598e13),(70,1.0e37,2.1181512090602e13),(70,1.0e37,Infinity),(70,1.0e37,1.0e307),(70,1.0e37,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.1181512090599e13),(71,Infinity,2.1181512090601e13),(71,Infinity,2.1181512090598e13),(71,Infinity,2.1181512090602e13),(71,Infinity,Infinity),(71,Infinity,1.0e307),(71,Infinity,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.1181512090599e13),(71,1.0e37,2.1181512090601e13),(71,1.0e37,2.1181512090598e13),(71,1.0e37,2.1181512090602e13),(71,1.0e37,Infinity),(71,1.0e37,1.0e307),(71,1.0e37,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.1181512090599e13),(68,Infinity,2.1181512090601e13),(68,Infinity,2.1181512090598e13),(68,Infinity,2.1181512090602e13),(68,Infinity,Infinity),(68,Infinity,1.0e307),(68,Infinity,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.1181512090599e13),(68,1.0e37,2.1181512090601e13),(68,1.0e37,2.1181512090598e13),(68,1.0e37,2.1181512090602e13),(68,1.0e37,Infinity),(68,1.0e37,1.0e307),(68,1.0e37,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13)] +various sized tuple returns +[(3,0,0),(3,1,0),(3,2,0),(3,4294967295,0),(3,0,1),(3,1,1),(3,2,1),(3,4294967295,1),(3,0,2),(3,1,2),(3,2,2),(3,4294967295,2),(3,0,4294967295),(3,1,4294967295),(3,2,4294967295),(3,4294967295,4294967295)] +[(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just (-18446744073709551617))] +[(5.0,Just 1,3.0,Nothing,0,Nothing),(5.0,Just 1,3.0,Nothing,1,Nothing),(5.0,Just 1,3.0,Nothing,2,Nothing),(5.0,Just 1,3.0,Nothing,4294967295,Nothing),(5.0,Just 1,3.0,Nothing,0,Just 1),(5.0,Just 1,3.0,Nothing,1,Just 1),(5.0,Just 1,3.0,Nothing,2,Just 1),(5.0,Just 1,3.0,Nothing,4294967295,Just 1),(5.0,Just 1,3.0,Nothing,0,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,1,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,2,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,4294967295,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,0,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,1,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,2,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,4294967295,Just (-18446744073709551617))] +[(Nothing,Nothing),(Just 1,Nothing),(Just 18446744073709551617,Nothing),(Just (-18446744073709551617),Nothing),(Nothing,Just 1),(Just 1,Just 1),(Just 18446744073709551617,Just 1),(Just (-18446744073709551617),Just 1),(Nothing,Just 18446744073709551617),(Just 1,Just 18446744073709551617),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just 18446744073709551617),(Nothing,Just (-18446744073709551617)),(Just 1,Just (-18446744073709551617)),(Just 18446744073709551617,Just (-18446744073709551617)),(Just (-18446744073709551617),Just (-18446744073709551617))] +arrays +(11,13) +(13,11) ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm ===================================== @@ -0,0 +1,145 @@ +#include "Cmm.h" + +/* zero arguments */ +cmm_zero() { /* ccall puts("cmm_zero"); buffering gets in the way */ return (); } +cmm_zero_w() { return (123::W_); } +cmm_zero_d() { return (1.0::D_); } +cmm_zero_f() { return (1.0::F_); } +cmm_zero_l() { return (123::L_); } + +/* one argument functions */ +cmm_one1_i8(I8 x) { return (x); } +cmm_one1_i16(I16 x) { return (x); } +cmm_one1_i32(I32 x) { return (x); } +cmm_one1_i64(I64 x) { return (x); } +cmm_one1_p(P_ x) { return (x); } +cmm_one1_w(W_ x) { return (x); } +cmm_one1_f(F_ x) { return (x); } +cmm_one1_d(D_ x) { return (x); } +cmm_one1_l(L_ x) { return (x); } + +cmm_one2_i8(I8 x) { return (x,x); } +cmm_one2_i16(I16 x) { return (x,x); } +cmm_one2_i32(I32 x) { return (x,x); } +cmm_one2_i64(I64 x) { return (x,x); } +cmm_one2_p(P_ x) { return (x,x); } +cmm_one2_w(W_ x) { return (x,x); } +cmm_one2_f(F_ x) { return (x,x); } +cmm_one2_d(D_ x) { return (x,x); } +cmm_one2_l(L_ x) { return (x,x); } + + +/* two argument functions */ +cmm_two1_i8(I8 x, I8 y) { return (x); } +cmm_two1_i16(I16 x, I16 y) { return (x); } +cmm_two1_i32(I32 x, I32 y) { return (x); } +cmm_two1_i64(I64 x, I64 y) { return (x); } +cmm_two1_p(P_ x, P_ y) { return (x); } +cmm_two1_w(W_ x, W_ y) { return (x); } +cmm_two1_f(F_ x, F_ y) { return (x); } +cmm_two1_d(D_ x, D_ y) { return (x); } +cmm_two1_l(L_ x, L_ y) { return (x); } + +cmm_two2_i8(I8 x, I8 y) { return (y); } +cmm_two2_i16(I16 x, I16 y) { return (y); } +cmm_two2_i32(I32 x, I32 y) { return (y); } +cmm_two2_i64(I64 x, I64 y) { return (y); } +cmm_two2_p(P_ x, P_ y) { return (y); } +cmm_two2_w(W_ x, W_ y) { return (y); } +cmm_two2_f(F_ x, F_ y) { return (y); } +cmm_two2_d(D_ x, D_ y) { return (y); } +cmm_two2_l(L_ x, L_ y) { return (y); } + +/* additional tests for floating point, since D_ and F_ registers + overlap on some platforms */ +cmm_floating_1(F_ x, F_ y) { F_ z; z = %fadd(x, y); return (z); } +cmm_floating_2(D_ x, D_ y) { D_ z; z = %fadd(x, y); return (z); } +cmm_floating_3(F_ x, D_ y) { return (x); } +cmm_floating_4(F_ x, D_ y) { return (y); } + + +cmm_floating_5(F_ x1, D_ x2, F_ x3, D_ x4, F_ x5, D_ x6, F_ x7, D_ x8) { + F_ y1; + D_ y2; + + y1 = %fadd(x1,x3); + y1 = %fadd(y1,x5); + y1 = %fadd(y1,x7); + + y2 = %fadd(x2,x4); + y2 = %fadd(y2,x6); + y2 = %fadd(y2,x8); + + return (y1, y2); +} + + +cmm_floating_6(D_ x1, F_ x2, D_ x3, F_ x4, D_ x5, F_ x6, D_ x7, F_ x8) { + D_ y1; + F_ y2; + + y1 = %fadd(x1,x3); + y1 = %fadd(y1,x5); + y1 = %fadd(y1,x7); + + y2 = %fadd(x2,x4); + y2 = %fadd(y2,x6); + y2 = %fadd(y2,x8); + + return (y1, y2); +} + + +cmm_floating_7( W_ x1, F_ x2, D_ x3 + , W_ x4, F_ x5, D_ x6 + , W_ x7, F_ x8, D_ x9 + , W_ x10, F_ x11, D_ x12 + , W_ x13, F_ x14, D_ x15 + , W_ x16, F_ x17, D_ x18 + , W_ x19, F_ x20, D_ x21 + ) { + W_ y1; + F_ y2; + D_ y3; + y1 = x1+x4+x7+x10+x13+x16+x19; + + y2 = %fadd(x2,x5); + y2 = %fadd(y2,x8); + y2 = %fadd(y2,x11); + y2 = %fadd(y2,x14); + y2 = %fadd(y2,x17); + y2 = %fadd(y2,x20); + + y3 = %fadd(x3,x6); + y3 = %fadd(y3,x9); + y3 = %fadd(y3,x12); + y3 = %fadd(y3,x15); + y3 = %fadd(y3,x18); + y3 = %fadd(y3,x21); + + return ( y1, y2, y3 ); +} + + +/* various sized tuple returns */ + +cmm_tuple_1(W_ x, W_ y, W_ z) { return (z, y, x); } +cmm_tuple_2(P_ p1, P_ p2, W_ w1, W_ w2, P_ p3, P_ p4, D_ d1, D_ d2, P_ p5, P_ p6, F_ f1, F_ f2) { + return (f2, f1, p6, p5, d2, d1, p4, p3, w2, w1, p2, p1); +} +cmm_tuple_3(P_ p1, W_ w1, P_ p2, D_ d1, P_ p3, F_ f1) { + return (f1, p3, d1, p2, w1, p1); +} +cmm_tuple_4(P_ p1, P_ p2) { return (p2, p1); } + +/* working with arrays */ +cmm_array_1(P_ x) { + W_ size; + size = StgMutArrPtrs_size(x); + return (size); +} + +/* return two arrays */ +cmm_array_2(P_ x, P_ y) { + return (y, x); +} ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile ===================================== @@ -0,0 +1,4 @@ +.PHONY: GHCiPrimCall +GHCiPrimCall: + '$(TEST_HC)' $(TEST_HC_OPTS) -fPIC -v0 -c GHCiPrimCall_cmm.cmm + -'$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -e main GHCiPrimCall.hs GHCiPrimCall_cmm.o || echo $$? >&2 ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/all.T ===================================== @@ -0,0 +1,2 @@ +test('GHCiPrimCall', [req_interp], makefile_test, ['GHCiPrimCall']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/00577d1ade77980df5eb304b0811c171261c63c0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/00577d1ade77980df5eb304b0811c171261c63c0 You're receiving 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 Jan 9 16:54:42 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 09 Jan 2023 11:54:42 -0500 Subject: [Git][ghc/ghc][wip/no_fixup_chains_2] 2 commits: Store bootstrap_llvm_target and use it to set LlvmTarget in bindists Message-ID: <63bc46d2c6e39_3b1bf93fcc990962e0@gitlab.mail> Matthew Pickering pushed to branch wip/no_fixup_chains_2 at Glasgow Haskell Compiler / GHC Commits: 78a9bec6 by Matthew Pickering at 2023-01-09T16:53:52+00:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 926cd4ee by Matthew Pickering at 2023-01-09T16:54:07+00:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. This completes the fix for #22429 - - - - - 3 changed files: - configure.ac - distrib/configure.ac.in - m4/ghc_llvm_target.m4 Changes: ===================================== configure.ac ===================================== @@ -667,6 +667,8 @@ GHC_LLVM_TARGET_SET_VAR # we intend to pass trough --targets to llvm as is. LLVMTarget_CPP=` echo "$LlvmTarget"` AC_SUBST(LLVMTarget_CPP) +# The target is substituted into the distrib/configure.ac file +AC_SUBST(LlvmTarget) dnl ** See whether cc supports --target= and set dnl CONF_CC_OPTS_STAGE[012] accordingly. ===================================== distrib/configure.ac.in ===================================== @@ -18,6 +18,8 @@ dnl-------------------------------------------------------------------- dnl Various things from the source distribution configure bootstrap_target=@TargetPlatform@ +bootstrap_llvm_target=@LlvmTarget@ + TargetHasRTSLinker=@TargetHasRTSLinker@ AC_SUBST(TargetHasRTSLinker) @@ -169,6 +171,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG # Stage 3 won't be supported by cross-compilation FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) +FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) +FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + AC_SUBST(CONF_CC_OPTS_STAGE0) AC_SUBST(CONF_CC_OPTS_STAGE1) AC_SUBST(CONF_CC_OPTS_STAGE2) ===================================== m4/ghc_llvm_target.m4 ===================================== @@ -50,5 +50,10 @@ AC_DEFUN([GHC_LLVM_TARGET], [ # require it. AC_DEFUN([GHC_LLVM_TARGET_SET_VAR], [ AC_REQUIRE([FPTOOLS_SET_PLATFORMS_VARS]) - GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + if test "$bootstrap_llvm_target" != "" + then + LlvmTarget=$bootstrap_llvm_target + else + GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + fi ]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4e70977ac02f6b7f0a3013bed76aceb813e5d03b...926cd4ee097106cf9c6d1ae1fc32375e7fc45ff2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4e70977ac02f6b7f0a3013bed76aceb813e5d03b...926cd4ee097106cf9c6d1ae1fc32375e7fc45ff2 You're receiving 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 Jan 9 16:56:27 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 09 Jan 2023 11:56:27 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/opaque-boxity-fix Message-ID: <63bc473b24cac_3b1bf959e7096782@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/opaque-boxity-fix at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/opaque-boxity-fix You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Jan 9 17:06:23 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 09 Jan 2023 12:06:23 -0500 Subject: [Git][ghc/ghc][wip/andreask/opaque-boxity-fix] Fix a bug where finaliseArgBoxities wasn't looking through casts. Message-ID: <63bc498f1474d_3b1bf955be01025d2@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/opaque-boxity-fix at Glasgow Haskell Compiler / GHC Commits: 22d22410 by Andreas Klebinger at 2023-01-09T18:05:14+01:00 Fix a bug where finaliseArgBoxities wasn't looking through casts. If the return type of a function was a newtype then we would fail to adjust the demands resulting in a panic in W/W when looking at opaque bindings. Fixes #22502 - - - - - 5 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Utils/Misc.hs - + testsuite/tests/simplCore/should_compile/OpaqueNoWW2.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -41,6 +41,7 @@ module GHC.Core ( bindersOf, bindersOfBinds, rhssOfBind, rhssOfAlts, foldBindersOfBindStrict, foldBindersOfBindsStrict, collectBinders, collectTyBinders, collectTyAndValBinders, + collectBindersThroughCasts, collectNBinders, collectNValBinders_maybe, collectArgs, stripNArgs, collectArgsTicks, flattenBinds, collectFunSimple, @@ -1954,6 +1955,7 @@ flattenBinds [] = [] collectBinders :: Expr b -> ([b], Expr b) collectTyBinders :: CoreExpr -> ([TyVar], CoreExpr) collectValBinders :: CoreExpr -> ([Id], CoreExpr) +collectBindersThroughCasts :: Expr Var -> ([Var], Expr Var) collectTyAndValBinders :: CoreExpr -> ([TyVar], [Id], CoreExpr) -- | Strip off exactly N leading lambdas (type or value). @@ -1979,6 +1981,14 @@ collectValBinders expr go ids (Lam b e) | isId b = go (b:ids) e go ids body = (reverse ids, body) +-- | Look through casts when collecting binders +collectBindersThroughCasts expr + = go [] expr + where + go ids (Cast e _) = go ids e + go ids (Lam b e) = go (b:ids) e + go ids body = (reverse ids, body) + collectTyAndValBinders expr = (tvs, ids, body) where ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -48,7 +48,6 @@ import GHC.Types.Unique.Set import GHC.Types.Unique.MemoFun import GHC.Types.RepType - {- ************************************************************************ * * @@ -1922,7 +1921,7 @@ finaliseArgBoxities env fn arity rhs div -- uses the info on the binders directly. where opts = ae_opts env - (bndrs, _body) = collectBinders rhs + (bndrs, _body) = collectBindersThroughCasts rhs unarise_arity = sum [ unariseArity (idType b) | b <- bndrs, isId b ] max_wkr_args = dmd_max_worker_args opts `max` unarise_arity -- This is the budget initialisation step of @@ -1947,17 +1946,19 @@ finaliseArgBoxities env fn arity rhs div -- catch newtype dictionaries too. -- NB: even for bottoming functions, don't unbox dictionaries - | is_bot_fn = unboxDeeplyDmd dmd - -- See Note [Boxity for bottoming functions], case (B) - | is_opaque = trimBoxity dmd -- See Note [OPAQUE pragma] -- See Note [The OPAQUE pragma and avoiding the reboxing of arguments] + | is_bot_fn = unboxDeeplyDmd dmd + -- See Note [Boxity for bottoming functions], case (B) + + | otherwise = dmd where dmd = idDemandInfo bndr - is_opaque = isOpaquePragma (idInlinePragma fn) + + is_opaque = isOpaquePragma (idInlinePragma fn) -- is_bot_fn: see Note [Boxity for bottoming functions] is_bot_fn = div == botDiv @@ -2017,6 +2018,7 @@ finaliseArgBoxities env fn arity rhs div add_demands :: [Demand] -> CoreExpr -> CoreExpr -- Attach the demands to the outer lambdas of this expression add_demands [] e = e + add_demands (dmds) (Cast e co) = Cast (add_demands dmds e) co add_demands (dmd:dmds) (Lam v e) | isTyVar v = Lam v (add_demands (dmd:dmds) e) | otherwise = Lam (v `setIdDemandInfo` dmd) (add_demands dmds e) ===================================== compiler/GHC/Utils/Misc.hs ===================================== @@ -637,8 +637,9 @@ all2 _ [] [] = True all2 p (x:xs) (y:ys) = p x y && all2 p xs ys all2 _ _ _ = False --- Count the number of times a predicate is true - +-- | Count the number of times a predicate is true +-- +-- A manually fused alternative to @length . filter p@ count :: (a -> Bool) -> [a] -> Int count p = go 0 where go !n [] = n ===================================== testsuite/tests/simplCore/should_compile/OpaqueNoWW2.hs ===================================== @@ -0,0 +1,13 @@ +module OpaqueNoWW2 where + +{-# LANGUAGE MagicHash #-} +module M where + +import GHC.Exts +import GHC.IO + +data T a = MkT !Bool !a + +fun :: T a -> IO a +{-# OPAQUE fun #-} +fun (MkT _ x) = IO $ \s -> noinline seq# x s ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -398,6 +398,7 @@ test('OpaqueNoSpecConstr', [ req_interp, grep_errmsg(r'$sloop') ], compile, ['-O test('OpaqueNoSpecialise', [ grep_errmsg(r'$sf') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) test('OpaqueNoStrictArgWW', [ grep_errmsg(r'$wf') ], compile, ['-O -fworker-wrapper-cbv -ddump-simpl -dsuppress-uniques']) test('OpaqueNoWW', [ grep_errmsg(r'$wf') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) +test('OpaqueNoWW2', [ grep_errmsg(r'$wf') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) test('T21144', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/22d224104ecf3d5990c44f175798e4e3795adf0e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/22d224104ecf3d5990c44f175798e4e3795adf0e You're receiving 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 Jan 9 19:13:43 2023 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Mon, 09 Jan 2023 14:13:43 -0500 Subject: [Git][ghc/ghc][wip/req_smp] testsuite: req_smp --> req_target_smp, req_ghc_smp Message-ID: <63bc6767dd0e5_3b1bf95632412032c@gitlab.mail> doyougnu pushed to branch wip/req_smp at Glasgow Haskell Compiler / GHC Commits: 9bd98a93 by Sylvain Henry at 2023-01-09T14:01:20-05:00 testsuite: req_smp --> req_target_smp, req_ghc_smp See #22630 and !9552 This commit: - splits req_smp into req_target_smp and req_ghc_smp - changes the testsuite driver to calculate req_ghc_smp - changes a handful of tests to use req_target_smp instead of req_smp - changes a handful of tests to use req_host_smp when needed The problem: - the problem this solves is the ambiguity surrounding req_smp - on master req_smp was used to express the constraint that the program being compiled supports smp _and_ that the host RTS (i.e., the RTS used to compile the program) supported smp. Normally that is fine, but in cross compilation this is not always the case as was discovered in #22630. The solution: - Differentiate the two constraints: - use req_target_smp to say the RTS the compiled program is linked with (and the platform) supports smp - use req_host_smp to say the RTS the host is linked with supports smp WIP: fix req_smp (target vs ghc) add flag to separate bootstrapper split req_smp -> req_target_smp and req_ghc_smp update tests smp flags cleanup and add some docstrings only set ghc_with_smp to bootstrapper on S1 or CC Only set ghc_with_smp to bootstrapperWithSMP of when testing stage 1 and cross compiling test the RTS in config/ghc not hadrian re-add ghc_with_smp fix and align req names fix T11760 to use req_host_smp test the rts directly, avoid python 3.5 limitation test the compiler in a try block align out of tree and in tree withSMP flags mark failing tests as host req smp testsuite: req_host_smp --> req_ghc_smp - - - - - 15 changed files: - hadrian/src/Settings/Builders/RunTest.hs - libraries/base/tests/all.T - testsuite/config/ghc - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/tests/codeGen/should_run/all.T - testsuite/tests/concurrent/T13615/all.T - testsuite/tests/concurrent/should_run/all.T - testsuite/tests/driver/T14075/all.T - testsuite/tests/driver/T20030/test1/all.T - testsuite/tests/driver/j-space/all.T - testsuite/tests/driver/t22391/all.T - testsuite/tests/ffi/should_run/all.T - testsuite/tests/rts/all.T - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -68,8 +68,8 @@ data TestCompilerArgs = TestCompilerArgs{ , withInterpreter :: Bool , unregisterised :: Bool , tables_next_to_code :: Bool - , withSMP :: Bool - , debugAssertions :: Bool + , targetWithSMP :: Bool -- does the target support SMP + , debugAssertions :: Bool -- ^ Whether the compiler has debug assertions enabled, -- corresponding to the -DDEBUG option. , profiled :: Bool @@ -100,7 +100,7 @@ inTreeCompilerArgs stg = do withInterpreter <- ghcWithInterpreter unregisterised <- flag GhcUnregisterised tables_next_to_code <- flag TablesNextToCode - withSMP <- targetSupportsSMP + targetWithSMP <- targetSupportsSMP debugAssertions <- ($ succStage stg) . ghcDebugAssertions <$> flavour profiled <- ghcProfiled <$> flavour <*> pure stg @@ -145,8 +145,8 @@ outOfTreeCompilerArgs = do withNativeCodeGen <- getBooleanSetting TestGhcWithNativeCodeGen withInterpreter <- getBooleanSetting TestGhcWithInterpreter unregisterised <- getBooleanSetting TestGhcUnregisterised - tables_next_to_code <- getBooleanSetting TestGhcTablesNextToCode - withSMP <- getBooleanSetting TestGhcWithSMP + tables_next_to_code <- getBooleanSetting TestGhcUnregisterised + targetWithSMP <- targetSupportsSMP debugAssertions <- getBooleanSetting TestGhcDebugged os <- getTestSetting TestHostOS @@ -202,7 +202,7 @@ runTestBuilderArgs = builder Testsuite ? do bignumBackend <- getBignumBackend bignumCheck <- getBignumCheck - keepFiles <- expr (testKeepFiles <$> userSetting defaultTestArgs) + keepFiles <- expr (testKeepFiles <$> userSetting defaultTestArgs) accept <- expr (testAccept <$> userSetting defaultTestArgs) (acceptPlatform, acceptOS) <- expr . liftIO $ @@ -262,8 +262,7 @@ runTestBuilderArgs = builder Testsuite ? do , arg "-e", arg $ asBool "ghc_with_dynamic_rts=" (hasDynamicRts) , arg "-e", arg $ asBool "ghc_with_threaded_rts=" (hasThreadedRts) , arg "-e", arg $ asBool "config.have_fast_bignum=" (bignumBackend /= "native" && not bignumCheck) - , arg "-e", arg $ asBool "ghc_with_smp=" withSMP - + , arg "-e", arg $ asBool "target_with_smp=" targetWithSMP , arg "-e", arg $ "config.ghc_dynamic=" ++ show hasDynamic , arg "-e", arg $ "config.leading_underscore=" ++ show leadingUnderscore ===================================== libraries/base/tests/all.T ===================================== @@ -240,7 +240,7 @@ test('T11555', normal, compile_and_run, ['']) test('T12494', normal, compile_and_run, ['']) test('T12852', [when(opsys('mingw32'), skip), js_broken(22374)], compile_and_run, ['']) test('lazySTexamples', normal, compile_and_run, ['']) -test('T11760', req_smp, compile_and_run, ['-threaded -with-rtsopts=-N2']) +test('T11760', [req_ghc_smp, req_target_smp], compile_and_run, ['-threaded -with-rtsopts=-N2']) test('T12874', normal, compile_and_run, ['']) test('T13191', [ collect_stats('bytes allocated', 5) ===================================== testsuite/config/ghc ===================================== @@ -43,10 +43,12 @@ if ghc_with_native_codegen: if config.have_interp: config.run_ways.append('ghci') +# we read the 'Support SMP' setting from the ghcconfig file. This dictates +# whether the target supports smp if ghc_with_threaded_rts: config.run_ways.append('threaded1') - if ghc_with_smp: - config.have_smp = True + if target_with_smp: + config.target_has_smp = True config.run_ways.append('threaded2') if config.speed == 0: config.run_ways.append('nonmoving_thr') @@ -210,31 +212,52 @@ def get_compiler_info(): # See Note [Replacing backward slashes in config.libdir]. config.libdir = config.libdir.replace('\\', '/') - def test_compile(flags) -> bool: + def test_compile(flags): """ - Check whether GHC can compile in the given way. - This is used as a proxy to determine, e.g., whether - profiled libraries were built. + Check whether GHC can compile in the given way. This is used as a + proxy to determine, e.g., whether profiled libraries were built, or + whether the host RTS supports smp. """ import tempfile import textwrap + + res = False + with tempfile.TemporaryDirectory() as d: src = Path(d) / 'test.hs' src.write_text(textwrap.dedent(''' module Main where main = putStrLn "Hello World!" ''')) - p = subprocess.run( + try: + p = subprocess.run( '{} -v0 {} -o test '.format(config.compiler, src) + ' '.join(flags), shell=True, cwd=d, - stderr=None if config.verbose >= 3 else subprocess.DEVNULL) - res = p.returncode - return res == 0 + stderr=None if config.verbose >= 3 else subprocess.DEVNULL + ) + + except Exception as err: + print("Exception thrown in testsuite/config/ghc.get_compiler_info: %s", err) + + else: + res = p.returncode == 0 + + return res + + def compiler_supports_way(flags): + return test_compile(flags) + + # Test the Host RTS to determine if it supports SMP. For cross compilers the + # Host /= Target, so we cannot determine from the ghcconfig file if the host + # itself supports smp. To support smp the host must be linked with an RTS + # built with 'defined(THREADED_RTS) && !defined(NO_SMP)'. Thus we directly + # query the RTS the host is linked with. + config.host_has_smp = test_compile(["+RTS", "-N"]) - config.have_vanilla = test_compile([]) - config.have_dynamic = test_compile(['-dynamic']) - config.have_profiling = test_compile(['-prof']) + config.have_vanilla = compiler_supports_way([]) + config.have_dynamic = compiler_supports_way(['-dynamic']) + config.have_profiling = compiler_supports_way(['-prof']) if config.have_profiling: config.compile_ways.append('profasm') ===================================== testsuite/driver/testglobals.py ===================================== @@ -147,8 +147,11 @@ class TestConfig: # Is the compiler dynamically linked? self.ghc_dynamic = False - # Do we have SMP support? - self.have_smp = False + # Does the host RTS have SMP support? + self.host_has_smp = True + + # Does the target have SMP support? + self.target_has_smp = True # Is gdb available? self.have_gdb = False ===================================== testsuite/driver/testlib.py ===================================== @@ -296,8 +296,22 @@ def req_th( name, opts ): if ghc_dynamic(): return _omit_ways(name, opts, ['profasm', 'profthreaded']) -def req_smp( name, opts ): - if not config.have_smp: +def req_ghc_smp( name, opts ): + """ + Mark a test as requiring the host to be linked with an RTS that supports + smp. Use this when the test needs to be compiled with smp support, but may + not necessarily be run. + """ + if not config.host_has_smp: + opts.skip = True + +def req_target_smp( name, opts ): + """ + Mark a test as requiring smp when run on the target. If the target does + not support smp, then mark the test as an expected fail. Use this when the + test needs to run with smp support. + """ + if not config.target_has_smp: opts.expect = 'fail' def ignore_stdout(name, opts): ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -156,7 +156,7 @@ test('T10246', normal, compile_and_run, ['']) test('T9533', normal, compile_and_run, ['']) test('T9533b', normal, compile_and_run, ['']) test('T9533c', normal, compile_and_run, ['']) -test('T10414', [only_ways(['threaded2']), extra_ways(['threaded2']), req_smp], +test('T10414', [only_ways(['threaded2']), extra_ways(['threaded2']), req_target_smp, req_ghc_smp], compile_and_run, ['-feager-blackholing']) test('T10521', normal, compile_and_run, ['']) test('T10521b', normal, compile_and_run, ['']) ===================================== testsuite/tests/concurrent/T13615/all.T ===================================== @@ -1,7 +1,7 @@ test('T13615', [when(fast(), skip), when(unregisterised(), skip), - req_smp, # needs -N support + req_target_smp, # needs -N support only_ways(threaded_ways), extra_files(['Parallel.hs', 'Memo.hs']), # Decrease stack chunk size and lots of capabilities to increase failure ===================================== testsuite/tests/concurrent/should_run/all.T ===================================== @@ -240,7 +240,9 @@ test('setnumcapabilities001', [ only_ways(['threaded1','threaded2', 'nonmoving_thr', 'profthreaded']), extra_run_opts('8 12 2000'), when(have_thread_sanitizer(), expect_broken(18808)), - req_smp ], + req_target_smp, + req_ghc_smp + ], compile_and_run, ['']) test('T21651', @@ -248,7 +250,9 @@ test('T21651', when(opsys('mingw32'),skip), # uses POSIX pipes when(opsys('darwin'),extra_run_opts('8 12 2000 100')), unless(opsys('darwin'),extra_run_opts('8 12 2000 200')), # darwin runners complain of too many open files - req_smp ], + req_target_smp, + req_ghc_smp + ], compile_and_run, ['']) test('hs_try_putmvar001', ===================================== testsuite/tests/driver/T14075/all.T ===================================== @@ -1,6 +1,6 @@ test('T14075', [ extra_files(['F.hs', 'F.hs-boot', 'O.hs', 'V.hs', 'V.hs-boot']) - , req_smp # uses ghc --make -j2 + , req_ghc_smp # uses ghc --make -j2 , js_broken(22261) ], makefile_test, []) ===================================== testsuite/tests/driver/T20030/test1/all.T ===================================== @@ -9,6 +9,7 @@ test('T20030_test1j', [ extra_files([ 'A.hs-boot' , 'A.hs' , 'B.hs' , 'C.hs-boot' , 'C.hs' , 'D.hs' , 'E.hs-boot' , 'E.hs' , 'F.hs' , 'G.hs' , 'H.hs' , 'I.hs', 'J.hs-boot', 'J.hs', 'K.hs' ]) - , req_smp + , req_target_smp + , req_ghc_smp ], multimod_compile, ['I.hs K.hs', '-v1 -j']) ===================================== testsuite/tests/driver/j-space/all.T ===================================== @@ -1 +1 @@ -test('jspace', [extra_files(['genJspace']), req_smp], makefile_test, ['jspace']) +test('jspace', [extra_files(['genJspace']), req_target_smp, req_ghc_smp], makefile_test, ['jspace']) ===================================== testsuite/tests/driver/t22391/all.T ===================================== @@ -1,5 +1,5 @@ test('t22391', [extra_files(['src'])], multimod_compile, ['Lib', '-v1 -Wall -fhide-source-paths -isrc -fdefer-diagnostics']) -test('t22391j', [req_smp, extra_files(['src'])], +test('t22391j', [req_target_smp, req_ghc_smp, extra_files(['src'])], multimod_compile, ['Lib', '-v1 -Wall -fhide-source-paths -isrc -fdefer-diagnostics -j2']) ===================================== testsuite/tests/ffi/should_run/all.T ===================================== @@ -235,7 +235,7 @@ test('T17471', [omit_ways(['ghci']), req_c], compile_and_run, ['T17471_c.c -optc-D -optcFOO']) test('IncallAffinity', - [req_smp, only_ways(['threaded1', 'threaded2']), + [req_target_smp, req_ghc_smp, only_ways(['threaded1', 'threaded2']), # Unregisterised build doesn't support when(unregisterised(), skip), req_c], ===================================== testsuite/tests/rts/all.T ===================================== @@ -287,7 +287,7 @@ test('stablename001', expect_fail_for(['hpc']), compile_and_run, ['']) test('T7815', [ multi_cpu_race, extra_run_opts('50000 +RTS -N2 -RTS'), - req_smp, + req_target_smp, req_ghc_smp, only_ways(['threaded1', 'threaded2']) ], compile_and_run, [''] ) # ignore_stderr because it contains a unique: @@ -306,10 +306,10 @@ test('T7919', [ when(fast(), skip) test('T8035', normal, compile_and_run, ['']) -test('T8209', [ req_smp, only_ways(threaded_ways), ignore_stdout ], +test('T8209', [ req_target_smp, req_ghc_smp, only_ways(threaded_ways), ignore_stdout ], compile_and_run, ['']) -test('T8242', [ req_smp, only_ways(threaded_ways), ignore_stdout ], +test('T8242', [ req_target_smp, req_ghc_smp, only_ways(threaded_ways), ignore_stdout ], compile_and_run, ['']) test('T8124', [ only_ways(threaded_ways), omit_ways(['ghci']), @@ -330,7 +330,8 @@ test('T9078', only_ways(['threaded1']), compile_and_run, ['']) test('T10017', [ when(opsys('mingw32'), skip) , when(unregisterised(), skip) - , req_smp + , req_target_smp + , req_ghc_smp , only_ways(threaded_ways), extra_run_opts('+RTS -N2 -RTS') ], compile_and_run, ['']) test('T11108', normal, compile_and_run, ['']) @@ -403,7 +404,7 @@ test('T11788', [ when(ghc_dynamic(), skip) , req_interp ], makefile_test, ['T11788']) -test('T10296a', [req_smp], makefile_test, ['T10296a']) +test('T10296a', [req_ghc_smp], makefile_test, ['T10296a']) test('T10296b', [only_ways(['threaded2'])], compile_and_run, ['']) @@ -457,7 +458,8 @@ test('alloccounter1', js_broken(22261), compile_and_run, test('nursery-chunks1', [ extra_run_opts('4 100 +RTS -n32k -A1m -RTS') - , req_smp + , req_ghc_smp + , req_target_smp , only_ways(['threaded1','threaded2']) ], compile_and_run, ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -412,7 +412,7 @@ test('T11990a', normal, compile_fail, ['']) test('T11990b', normal, compile_fail, ['']) test('T12035', [], multimod_compile_fail, ['T12035', '-v0']) test('T12035j', [ extra_files(['T12035.hs', 'T12035a.hs', 'T12035.hs-boot']) - , req_smp + , req_ghc_smp , js_broken(22261) ], multimod_compile_fail, ['T12035', '-j2 -v0']) test('T12045b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9bd98a93707e8807c409cde05c4717e27295356a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9bd98a93707e8807c409cde05c4717e27295356a You're receiving 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 Jan 9 19:25:21 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 09 Jan 2023 14:25:21 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/misc-cleanup4 Message-ID: <63bc6a21d8ae5_3b1bf95262012949e@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/misc-cleanup4 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/misc-cleanup4 You're receiving 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 Jan 9 19:39:26 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 09 Jan 2023 14:39:26 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Remove RTS hack for configuring Message-ID: <63bc6d6e384c1_3b1bf9563241354a5@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 111caae0 by John Ericson at 2023-01-09T14:39:19-05:00 Remove RTS hack for configuring See the brand new Note [Undefined symbols in the RTS] for additional details. - - - - - b474a7c7 by Sebastian Graf at 2023-01-09T14:39:19-05:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - 4 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Rules/Register.hs - rts/rts.cabal.in Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -333,7 +333,8 @@ dmdAnalBindLetUp :: TopLevelFlag -> WithDmdType (DmdResult CoreBind a) dmdAnalBindLetUp top_lvl env id rhs anal_body = WithDmdType final_ty (R (NonRec id' rhs') (body')) where - WithDmdType body_ty body' = anal_body env + WithDmdType body_ty body' = anal_body (addInScopeAnalEnv env id) + -- See Note [Bringing a new variable into scope] WithDmdType body_ty' id_dmd = findBndrDmd env body_ty id -- See Note [Finalising boxity for demand signatures] @@ -473,7 +474,8 @@ dmdAnal' env dmd (App fun arg) dmdAnal' env dmd (Lam var body) | isTyVar var = let - WithDmdType body_ty body' = dmdAnal env dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) dmd body + -- See Note [Bringing a new variable into scope] in WithDmdType body_ty (Lam var body') @@ -481,7 +483,8 @@ dmdAnal' env dmd (Lam var body) = let (n, body_dmd) = peelCallDmd dmd -- body_dmd: a demand to analyze the body - WithDmdType body_ty body' = dmdAnal env body_dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) body_dmd body + -- See Note [Bringing a new variable into scope] WithDmdType lam_ty var' = annotateLamIdBndr env body_ty var new_dmd_type = multDmdType n lam_ty in @@ -493,7 +496,9 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt_con bndrs rhs]) -- can consider its field demands when analysing the scrutinee. | want_precise_field_dmds alt_con = let - WithDmdType rhs_ty rhs' = dmdAnal env dmd rhs + rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + WithDmdType rhs_ty rhs' = dmdAnal rhs_env dmd rhs WithDmdType alt_ty1 fld_dmds = findBndrsDmds env rhs_ty bndrs WithDmdType alt_ty2 case_bndr_dmd = findBndrDmd env alt_ty1 case_bndr !case_bndr' = setIdDemandInfo case_bndr case_bndr_dmd @@ -629,7 +634,9 @@ dmdAnalSumAlts env dmd case_bndr (alt:alts) dmdAnalSumAlt :: AnalEnv -> SubDemand -> Id -> CoreAlt -> WithDmdType CoreAlt dmdAnalSumAlt env dmd case_bndr (Alt con bndrs rhs) - | WithDmdType rhs_ty rhs' <- dmdAnal env dmd rhs + | let rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + , WithDmdType rhs_ty rhs' <- dmdAnal rhs_env dmd rhs , WithDmdType alt_ty dmds <- findBndrsDmds env rhs_ty bndrs , let (_ :* case_bndr_sd) = findIdDemand alt_ty case_bndr -- See Note [Demand on case-alternative binders] @@ -2399,7 +2406,7 @@ enterDFun bind env emptySigEnv :: SigEnv emptySigEnv = emptyVarEnv --- | Extend an environment with the strictness IDs attached to the id +-- | Extend an environment with the strictness sigs attached to the Ids extendAnalEnvs :: TopLevelFlag -> AnalEnv -> [Id] -> AnalEnv extendAnalEnvs top_lvl env vars = env { ae_sigs = extendSigEnvs top_lvl (ae_sigs env) vars } @@ -2418,6 +2425,12 @@ extendSigEnv top_lvl sigs var sig = extendVarEnv sigs var (sig, top_lvl) lookupSigEnv :: AnalEnv -> Id -> Maybe (DmdSig, TopLevelFlag) lookupSigEnv env id = lookupVarEnv (ae_sigs env) id +addInScopeAnalEnv :: AnalEnv -> Var -> AnalEnv +addInScopeAnalEnv env id = env { ae_sigs = delVarEnv (ae_sigs env) id } + +addInScopeAnalEnvs :: AnalEnv -> [Var] -> AnalEnv +addInScopeAnalEnvs env ids = env { ae_sigs = delVarEnvList (ae_sigs env) ids } + nonVirgin :: AnalEnv -> AnalEnv nonVirgin env = env { ae_virgin = False } @@ -2456,7 +2469,18 @@ findBndrDmd env dmd_ty id fam_envs = ae_fam_envs env -{- Note [Making dictionary parameters strict] +{- Note [Bringing a new variable into scope] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + f x = blah + g = ...(\f. ...f...)... + +In the body of the '\f', any occurrence of `f` refers to the lambda-bound `f`, +not the top-level `f` (which will be in `ae_sigs`). So it's very important +to delete `f` from `ae_sigs` when we pass a lambda/case/let-up binding of `f`. +Otherwise chaos results (#22718). + +Note [Making dictionary parameters strict] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -148,6 +148,8 @@ configurePackage context at Context {..} = do -- Figure out what hooks we need. hooks <- case C.buildType (C.flattenPackageDescription gpd) of C.Configure -> pure C.autoconfUserHooks + C.Simple -> pure C.simpleUserHooks + C.Make -> fail "build-type: Make is not supported" -- The 'time' package has a 'C.Custom' Setup.hs, but it's actually -- 'C.Configure' plus a @./Setup test@ hook. However, Cabal is also -- 'C.Custom', but doesn't have a configure script. @@ -155,12 +157,6 @@ configurePackage context at Context {..} = do configureExists <- doesFileExist $ replaceFileName (pkgCabalFile package) "configure" pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks - -- Not quite right, but good enough for us: - _ | package == rts -> - -- Don't try to do post configuration validation for 'rts'. This - -- will simply not work, due to the @ld-options@ and @Stg.h at . - pure $ C.simpleUserHooks { C.postConf = \_ _ _ _ -> return () } - | otherwise -> pure C.simpleUserHooks -- Compute the list of flags, and the Cabal configuration arguments flavourArgs <- args <$> flavour ===================================== hadrian/src/Rules/Register.hs ===================================== @@ -45,6 +45,14 @@ configurePackageRules = do isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend when isGmp $ need [buildP -/- "include/ghc-gmp.h"] + when (pkg == rts) $ do + -- Rts.h is a header listed in the cabal file, and configuring + -- therefore wants to ensure that the header "works" post-configure. + -- But it (transitively) includes these, so we must ensure they exist + -- for that check to work. + need [ buildP -/- "include/ghcautoconf.h" + , buildP -/- "include/ghcplatform.h" + ] Cabal.configurePackage ctx root -/- "**/autogen/cabal_macros.h" %> \out -> do ===================================== rts/rts.cabal.in ===================================== @@ -275,6 +275,8 @@ library stg/SMP.h stg/Ticky.h stg/Types.h + + -- See Note [Undefined symbols in the RTS] if flag(64bit) if flag(leading-underscore) ld-options: @@ -474,6 +476,8 @@ library ld-options: "-Wl,-search_paths_first" -- See Note [fd_set_overflow] "-Wl,-U,___darwin_check_fd_set_overflow" + -- See Note [Undefined symbols in the RTS] + "-Wl,-undefined,dynamic_lookup" if !arch(x86_64) && !arch(aarch64) ld-options: -read_only_relocs warning @@ -714,3 +718,35 @@ library -- , https://github.com/sitsofe/fio/commit/b6a1e63a1ff607692a3caf3c2db2c3d575ba2320 -- The issue was originally reported in #19950 + + +-- Note [Undefined symbols in the RTS] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- The RTS is built with a number of `-u` flags. This is to handle cyclic +-- dependencies between the RTS and other libraries which we normally think of as +-- downstream from the RTS. "Regular" dependencies from usages in those libraries +-- to definitions in the RTS are handled normally. "Reverse" dependencies from +-- usages in the RTS to definitions in those libraries get the `-u` flag in the +-- RTS. +-- +-- The symbols are specified literally, but follow C ABI conventions (as all 3 of +-- C, C--, and Haskell do currently). Thus, we have to be careful to include a +-- leading underscore or not based on those conventions for the given platform in +-- question. +-- +-- A tricky part is that different linkers have different policies regarding +-- undefined symbols (not defined in the current binary, or found in a shared +-- library that could be loaded at run time). GNU Binutils' linker is fine with +-- undefined symbols by default, but Apple's "cctools" linker is not. To appease +-- that linker we either need to do a blanket `-undefined dynamic_lookup` or +-- whitelist each such symbol with an additional `-U` (see the man page for more +-- details). +-- +-- GHC already does `-undefined dynamic_lookup`, so we just do that for now, but +-- we might try to get more precise with `-U` in the future. +-- +-- Note that the RTS also `-u`s some atomics symbols that *are* defined --- and +-- defined within the RTS! It is not immediately clear why this is needed. This +-- dates back to c06e3f46d24ef69f3a3d794f5f604cb8c2a40cbc which mentions a build +-- failure that it was suggested that this fix, but the precise reasoning is not +-- explained. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/965a273510adfac4f041a31182c2fec82e614e47...b474a7c7229ad846e492920aeecf1970180daa63 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/965a273510adfac4f041a31182c2fec82e614e47...b474a7c7229ad846e492920aeecf1970180daa63 You're receiving 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 Jan 9 19:41:19 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Mon, 09 Jan 2023 14:41:19 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/remove-everywhere-permissive-mach-o-linking Message-ID: <63bc6ddf6fa9f_3b1bf9526481449ca@gitlab.mail> John Ericson pushed new branch wip/remove-everywhere-permissive-mach-o-linking at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/remove-everywhere-permissive-mach-o-linking You're receiving 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 Jan 9 19:42:07 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 09 Jan 2023 14:42:07 -0500 Subject: [Git][ghc/ghc][wip/T22264] 217 commits: Hadrian: fix ghcDebugAssertions off-by-one error Message-ID: <63bc6e0f72bd_3b1bf95262014514d@gitlab.mail> Ben Gamari pushed to branch wip/T22264 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 - - - - - 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 - - - - - 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]. - - - - - 2eb0fb87 by Matthew Pickering at 2022-12-15T03:54:39-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 - - - - - 552b7908 by Ben Gamari at 2022-12-15T03:55:15-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. - - - - - 933d61a4 by Simon Peyton Jones at 2022-12-15T03:55:51-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. - - - - - 03ed0b95 by Ryan Scott at 2022-12-15T03:56:26-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. - - - - - ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/ThreadPaused: Ordering fixes - - - - - 914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00 eventlog: Silence spurious data race - - - - - fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts: Use fences instead of explicit barriers - - - - - 2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - 70999283 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 98689f77 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - 86f20258 by Ben Gamari at 2022-12-16T16:12:45-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. - - - - - f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate access to capabilities array - - - - - 7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate sched_state - - - - - 1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Style fix - - - - - 82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00 compiler: Use release store in eager blackholing - - - - - eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Fix ordering of makeStableName - - - - - ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Note race with wakeBlockingQueue - - - - - 5acf33dd by Bodigrim at 2022-12-16T16:13:22-05:00 Bump submodule directory to 1.3.8.0 and hpc to HEAD - - - - - 0dd95421 by Bodigrim at 2022-12-16T16:13:22-05:00 Accept allocations increase on Windows This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips between lists and ByteArray. See #22625 for discussion. Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T10547 T12150 T12227 T12234 T12425 T13035 T13253 T13253-spj T13701 T13719 T15703 T16875 T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T21839r T5837 T6048 T9198 T9961 TcPlugin_RewritePerf hard_hole_fits - - - - - ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00 testsuite: Mark T9405 as fragile instead of broken on Windows It's starting to pass again, and the unexpected pass blocks CI. - - - - - 1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: remove obsolete commented code in wasm NCG It was just a temporary hack to workaround a bug in the relooper, that bug has been fixed long before the wasm backend is merged. - - - - - e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm Also removes some unreachable code here. - - - - - 1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: change fallback function signature to Cmm function signature in wasm NCG In the wasm NCG, when handling a `CLabel` of undefined function without knowing its function signature, we used to fallback to `() -> ()` which is accepted by `wasm-ld`. This patch changes it to the signature of Cmm functions, which equally works, but would be required when we emit tail call instructions. - - - - - 8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add optional tail-call support in wasm NCG When the `-mtail-call` clang flag is passed at configure time, wasm tail-call extension is enabled, and the wasm NCG will emit `return_call`/`return_call_indirect` instructions to take advantage of it and avoid the `StgRun` trampoline overhead. Closes #22461. - - - - - d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00 base: add missing autoconf checks for waitpid/umask These are not present in wasi-libc. Required for fixing #22589 - - - - - da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00 compiler: make .wasm the default executable extension on wasm32 Following convention as in other wasm toolchains. Fixes #22594. - - - - - ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00 ci: support hello.wasm in ci.sh cross testing logic - - - - - 6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00 Correct `exitWith` Haddocks The `IOError`-specific `catch` in the Prelude is long gone. - - - - - b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-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. - - - - - 761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00 rts/libdw: Silence uninitialized usage warnings As noted in #22538, previously some GCC versions warned that various locals in Libdw.c may be used uninitialized. Although this wasn't strictly true (since they were initialized in an inline assembler block) we fix this by providing explicit empty initializers. Fixes #22538 - - - - - 5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00 testsuite: Mark T16392 as fragile on windows See #22649 - - - - - 703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00 Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`. - - - - - 9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05: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 - - - - - 7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Drop uses of AC_PROG_CC_C99 As noted in #22566, this macro is deprecated as of autoconf-2.70 `AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself. Closes #22566. - - - - - 36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Use AS_HELP_STRING instead of AC_HELP_STRING The latter has been deprecated. See #22566. - - - - - befe6ff8 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: fix various usages of head and tail - - - - - 666d0ba7 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: avoid head and tail in parseCallEscape and around - - - - - 5d96fd50 by Bodigrim at 2022-12-20T21:16:37-05:00 Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty - - - - - 3ce2ab94 by Bodigrim at 2022-12-21T06:17:56-05:00 Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian - - - - - 954de93a by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule haskeline to HEAD (to allow transformers-0.6) - - - - - cefbeec3 by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule transformers to 0.6.0.4 - - - - - b4730b62 by Bodigrim at 2022-12-21T06:17:56-05:00 Fix tests T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations Metric Increase: T13253 - - - - - 0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05: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. - - - - - df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00 rts: explicitly store return value of ccall checkClosure to prevent type error (#22617) - - - - - e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix shadowing lacuna in OccurAnal Issue #22623 demonstrated another lacuna in the implementation of wrinkle (BS3) in Note [The binder-swap substitution] in the occurrence analyser. I was failing to add TyVar lambda binders using addInScope/addOneInScope and that led to a totally bogus binder-swap transformation. Very easy to fix. - - - - - 3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix an assertion check in addToEqualCtList The old assertion saw that a constraint ct could rewrite itself (of course it can) and complained (stupid). Fixes #22645 - - - - - ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00 configure: Bump version to 9.6 - - - - - fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00 base: Bump version to 4.18 Requires various submodule bumps. - - - - - 93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00 ghc-boot: Fix bootstrapping - - - - - fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00 Bump GHC version to 9.7 - - - - - 914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05: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. - - - - - 32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00 hadrian bindist: Install manpages to share/man/man1/ghc.1 When the installation makefile was copied over the manpages were no longer installed in the correct place. Now we install it into share/man/man1/ghc.1 as the make build system did. Fixes #22371 - - - - - b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00 rts: Drop paths from configure from cabal file A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them. - - - - - b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00 Bump libffi-tarballs submodule We will now use libffi-3.4.4. - - - - - 3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00 EPA: Make EOF position part of AnnsModule Closes #20951 Closes #19697 - - - - - 99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00 JS: fix support for -outputdir (#22641) The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug. - - - - - 02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00 Refactor mkRuntimeError This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions. - - - - - 35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00 base: Fix event manager shutdown race on non-Linux platforms During shutdown it's possible that we will attempt to use a closed fd to wakeup another capability's event manager. On the Linux eventfd path we were careful to handle this. However on the non-Linux path we failed to do so. Fix this. - - - - - 317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00 Fix unifier bug: failing to decompose over-saturated type family This simple patch fixes #22647 - - - - - 14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00 rts/m32: Fix sanity checking Previously we would attempt to clear pages which were marked as read-only. Fix this. - - - - - 16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00 ci: Move wasm pipelines into nightly rather than master See #22664 for the changes which need to be made to bring one of these back to the validate pipeline. - - - - - 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-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). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Bodigrim at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - 541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - 28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00 Add support for sized literals in the bytecode interpreter. The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945 - - - - - ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00 rts: MUT_VAR is not a StgMutArrPtrs There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs. - - - - - 6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s - - - - - 73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. - - - - - 8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 938c6c1e by Ben Gamari at 2023-01-09T13:55:04-05:00 nonmoving: Fix style - - - - - 5c37c7c2 by Ben Gamari at 2023-01-09T13:55:04-05:00 nonmoving: Deduplicate assertion - - - - - 75343981 by Ben Gamari at 2023-01-09T13:55:04-05:00 rts: Fix type issues in Sparks.h Adds explicit casts to satisfy a C++ compiler. - - - - - d460fe22 by Ben Gamari at 2023-01-09T13:55:04-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. - - - - - 8906d0e4 by Ben Gamari at 2023-01-09T13:55:04-05:00 rts/Sanity: Mark pinned_object_blocks - - - - - 07a70cd0 by Ben Gamari at 2023-01-09T13:55:05-05:00 rts/Sanity: Look at nonmoving saved_filled lists - - - - - a24d71f9 by Ben Gamari at 2023-01-09T13:55:05-05:00 Evac: Squash data race in eval_selector_chain - - - - - 795eedcd by Ben Gamari at 2023-01-09T13:55:05-05:00 nonmoving: Clarify implementation This makes the intent of this implementation a bit clearer. - - - - - f66b33b8 by Ben Gamari at 2023-01-09T13:55:05-05:00 nonmoving: Clarify comment - - - - - 1dd1f123 by Ben Gamari at 2023-01-09T13:55:05-05:00 nonmoving: Add missing no-op in busy-wait loop - - - - - 7487daaa by Ben Gamari at 2023-01-09T13:55:05-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. - - - - - 65f7382d by Ben Gamari at 2023-01-09T13:55:05-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. - - - - - bdbfcc24 by Ben Gamari at 2023-01-09T13:55:05-05:00 nonmoving: Sanity check nonmoving large objects and compacts - - - - - af7af8e7 by Ben Gamari at 2023-01-09T13:55:05-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. - - - - - 01ef80bf by Ben Gamari at 2023-01-09T13:55:05-05:00 nonmoving: Don't show occupancy if we didn't collect live words - - - - - 9994cbe7 by Ben Gamari at 2023-01-09T13:55:05-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. - - - - - ff8392de by Ben Gamari at 2023-01-09T13:55:05-05:00 nonmoving: Assert state of swept segments - - - - - 710a96d1 by Ben Gamari at 2023-01-09T13:55:05-05:00 nonmoving: Handle new closures in nonmovingIsNowAlive - - - - - d5b286d4 by Ben Gamari at 2023-01-09T13:55:05-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. - - - - - 93380853 by Ben Gamari at 2023-01-09T13:55:05-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. - - - - - 0f595bba by Ben Gamari at 2023-01-09T13:55:05-05:00 nonmoving: Post-sweep sanity checking - - - - - cbba7578 by Ben Gamari at 2023-01-09T13:55:05-05:00 nonmoving: Avoid n_caps race - - - - - fb10613e by Ben Gamari at 2023-01-09T13:55:05-05:00 nonmoving: Don't push if nonmoving collector isn't enabled - - - - - 1444d20e by Ben Gamari at 2023-01-09T14:10:34-05:00 nonmoving: Be more paranoid in segment tracking Previously we left various segment link pointers dangling. None of this wrong per se, but it did make it harder than necessary to debug. - - - - - 59e0cc8b by Ben Gamari at 2023-01-09T14:22:35-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. - - - - - 89e8e058 by Ben Gamari at 2023-01-09T14:22:36-05:00 nonmoving: Allow pinned gen0 objects to be WEAK keys - - - - - 0c810999 by Ben Gamari at 2023-01-09T14:38:52-05:00 rts: Fix typo "tracingAddCapabilities" was mis-named - - - - - 977a3902 by Ben Gamari at 2023-01-09T14:39:20-05:00 rts: Reenable assertion - - - - - 6b2d5e30 by Ben Gamari at 2023-01-09T14:39:20-05:00 rts: C++ typing issues Make the RTS compilable with a C++ compiler by inserting necessary casts. - - - - - e6b7497e by Ben Gamari at 2023-01-09T14:39:20-05:00 rts: Drop SM spinlock - - - - - f4772005 by Ben Gamari at 2023-01-09T14:41:45-05:00 rts: Fix non-atomic mutation of enabled_capabilities - - - - - 8597d2bc by Ben Gamari at 2023-01-09T14:41:45-05:00 nonmoving: Move current segment array into Capability - - - - - d64f8f41 by Ben Gamari at 2023-01-09T14:41:45-05:00 setNumCapabilities - - - - - a792dd40 by Ben Gamari at 2023-01-09T14:41:45-05:00 nonmoving: Disable shortcutting - - - - - b5f1cb81 by Ben Gamari at 2023-01-09T14:41:45-05:00 CheckGC - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - compiler/CodeGen.Platform.h - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info/Build.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.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/46a5084349b7fcb6ad602308c07e32aa07cc2787...b5f1cb818d707c456249159d25042570ddef3663 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/46a5084349b7fcb6ad602308c07e32aa07cc2787...b5f1cb818d707c456249159d25042570ddef3663 You're receiving 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 Jan 9 19:45:32 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Mon, 09 Jan 2023 14:45:32 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/int-index/type-abs-flag Message-ID: <63bc6edc8a8b5_3b1bf95632414936f@gitlab.mail> Vladislav Zavialov pushed new branch wip/int-index/type-abs-flag at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/int-index/type-abs-flag You're receiving 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 Jan 9 19:53:39 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Mon, 09 Jan 2023 14:53:39 -0500 Subject: [Git][ghc/ghc][wip/int-index/decl-invis-binders] 8 commits: Make FloatIn robust to shadowing Message-ID: <63bc70c326c61_3b1bf93fcc9901527a5@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/decl-invis-binders at Glasgow Haskell Compiler / GHC Commits: 6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s - - - - - 73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. - - - - - 8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 6d1a6fce by Vladislav Zavialov at 2023-01-09T18:20:59+03:00 workaround: bump template-haskell - - - - - 7faabed4 by Vladislav Zavialov at 2023-01-09T22:52:21+03:00 WIP: Invisible binders in type declarations Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 30 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/TyCon.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/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Error/Codes.hs - compiler/Language/Haskell/Syntax/Type.hs - configure.ac - 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 The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4c55e8248566f8e06a20ec0033aab0f12fd51421...7faabed42b59a1bbdd864d9dc936618b0b7ff3fb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4c55e8248566f8e06a20ec0033aab0f12fd51421...7faabed42b59a1bbdd864d9dc936618b0b7ff3fb You're receiving 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 Jan 9 19:59:53 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 09 Jan 2023 14:59:53 -0500 Subject: [Git][ghc/ghc][wip/T22264] Deleted 3 commits: setNumCapabilities Message-ID: <63bc723938589_3b1bf95260c155226@gitlab.mail> Ben Gamari pushed to branch wip/T22264 at Glasgow Haskell Compiler / GHC WARNING: The push did not contain any new commits, but force pushed to delete the commits and changes below. Deleted commits: d64f8f41 by Ben Gamari at 2023-01-09T14:41:45-05:00 setNumCapabilities - - - - - a792dd40 by Ben Gamari at 2023-01-09T14:41:45-05:00 nonmoving: Disable shortcutting - - - - - b5f1cb81 by Ben Gamari at 2023-01-09T14:41:45-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 ===================================== @@ -2228,9 +2228,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) @@ -2250,11 +2253,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; } @@ -2357,6 +2364,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 ===================================== @@ -615,6 +615,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 ===================================== @@ -1255,6 +1255,7 @@ concurrent_marking: #if defined(THREADED_RTS) && defined(NONCONCURRENT_SWEEP) #if defined(DEBUG) + check_gc(); checkNonmovingHeap(&nonmovingHeap); checkSanity(true, true); #endif ===================================== rts/sm/NonMovingMark.c ===================================== @@ -1608,7 +1608,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/8597d2bc2ed61910af3d8177715e16efbe2eb2ef...b5f1cb818d707c456249159d25042570ddef3663 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8597d2bc2ed61910af3d8177715e16efbe2eb2ef...b5f1cb818d707c456249159d25042570ddef3663 You're receiving 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 Jan 9 19:59:57 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 09 Jan 2023 14:59:57 -0500 Subject: [Git][ghc/ghc][wip/T22404] Partition into OneOccs and ManyOccs Message-ID: <63bc723d762fb_3b1bf93c57d8c1554ba@gitlab.mail> Sebastian Graf pushed to branch wip/T22404 at Glasgow Haskell Compiler / GHC Commits: 0ada2fca by Sebastian Graf at 2023-01-09T20:59:44+01:00 Partition into OneOccs and ManyOccs - - - - - 1 changed file: - compiler/GHC/Core/Opt/OccurAnal.hs Changes: ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -755,15 +755,16 @@ occAnalBind !env lvl ire (NonRec bndr rhs) thing_inside combine = let -- Analyse the rhs first, generating rhs_uds rhs_env = setRhsCtxt OccVanilla env WithUsageDetails rhs_uds rhs' = occAnalRhs rhs_env NonRecursive mb_join rhs + !(!one_uds, !many_uds) = partitionOneOccUDs rhs_uds -- Now analyse the body, adding the -- join-point into the environment with addJoinPoint (tagged_bndr, body_wuds) = occAnalNonRecBody env lvl bndr $ \env -> - thing_inside (addJoinPoint env bndr rhs_uds) + thing_inside (addJoinPoint env bndr one_uds) -- Build the WithUsageDetails for the join-point binding - bind_wuds = WithUsageDetails emptyDetails [NonRec tagged_bndr rhs'] + bind_wuds = WithUsageDetails many_uds [NonRec tagged_bndr rhs'] in finishNonRec combine tagged_bndr bind_wuds body_wuds @@ -3167,6 +3168,15 @@ lookupDetails ud id usedIn :: Id -> UsageDetails -> Bool v `usedIn` ud = isExportedId v || v `elemVarEnv` ud_env ud +partitionOneOccUDs :: UsageDetails -> (UsageDetails, UsageDetails) +partitionOneOccUDs uds + = (emptyDetails{ud_env = interesting_env}, emptyDetails{ud_env = boring_env}) + where + UD{ud_env=env} = flattenUsageDetails uds + (interesting_env,boring_env) = partitionVarEnv interesting env + interesting OneOcc{} = True + interesting _ = False + udFreeVars :: VarSet -> UsageDetails -> VarSet -- Find the subset of bndrs that are mentioned in uds udFreeVars bndrs ud = restrictFreeVars bndrs (ud_env ud) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0ada2fca7ae72f643558dbfdc7adf07d63882272 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0ada2fca7ae72f643558dbfdc7adf07d63882272 You're receiving 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 Jan 9 20:23:10 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 09 Jan 2023 15:23:10 -0500 Subject: [Git][ghc/ghc][wip/T22264] 21 commits: nonmoving: Fix handling of weak pointers Message-ID: <63bc77ae2c7d6_3b1bf9526201598ad@gitlab.mail> Ben Gamari pushed to branch wip/T22264 at Glasgow Haskell Compiler / GHC Commits: 1ecbf4ef by Ben Gamari at 2023-01-09T15:22:49-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. - - - - - c1271cfa by Ben Gamari at 2023-01-09T15:22:49-05:00 nonmoving: Sanity check nonmoving large objects and compacts - - - - - e061aa5a by Ben Gamari at 2023-01-09T15:22:49-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. - - - - - 25fdeee7 by Ben Gamari at 2023-01-09T15:22:49-05:00 nonmoving: Don't show occupancy if we didn't collect live words - - - - - 8b82a2b0 by Ben Gamari at 2023-01-09T15:22:49-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. - - - - - f1c9a041 by Ben Gamari at 2023-01-09T15:22:49-05:00 nonmoving: Assert state of swept segments - - - - - 915181d3 by Ben Gamari at 2023-01-09T15:22:49-05:00 nonmoving: Handle new closures in nonmovingIsNowAlive - - - - - b75229ae by Ben Gamari at 2023-01-09T15:22:49-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. - - - - - b45c529f by Ben Gamari at 2023-01-09T15:22:49-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. - - - - - 1cd74885 by Ben Gamari at 2023-01-09T15:22:49-05:00 nonmoving: Post-sweep sanity checking - - - - - 2ab54d88 by Ben Gamari at 2023-01-09T15:22:49-05:00 nonmoving: Avoid n_caps race - - - - - b2763a51 by Ben Gamari at 2023-01-09T15:22:49-05:00 nonmoving: Don't push if nonmoving collector isn't enabled - - - - - a11bdf9e by Ben Gamari at 2023-01-09T15:22:49-05:00 nonmoving: Be more paranoid in segment tracking Previously we left various segment link pointers dangling. None of this wrong per se, but it did make it harder than necessary to debug. - - - - - 799e2a50 by Ben Gamari at 2023-01-09T15:22:50-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. - - - - - be328c31 by Ben Gamari at 2023-01-09T15:22:50-05:00 nonmoving: Allow pinned gen0 objects to be WEAK keys - - - - - 7d7979eb by Ben Gamari at 2023-01-09T15:22:50-05:00 rts: Fix typo "tracingAddCapabilities" was mis-named - - - - - 570c3478 by Ben Gamari at 2023-01-09T15:22:50-05:00 rts: Reenable assertion - - - - - 73f40a60 by Ben Gamari at 2023-01-09T15:22:50-05:00 rts: C++ typing issues Make the RTS compilable with a C++ compiler by inserting necessary casts. - - - - - 814a8545 by Ben Gamari at 2023-01-09T15:22:50-05:00 rts: Drop SM spinlock - - - - - 5cd834fc by Ben Gamari at 2023-01-09T15:22:50-05:00 rts: Fix non-atomic mutation of enabled_capabilities - - - - - 89fba7d8 by Ben Gamari at 2023-01-09T15:22:50-05:00 nonmoving: Move current segment array into Capability - - - - - 30 changed files: - rts/Capability.c - rts/Capability.h - rts/CheckUnload.c - rts/RtsStartup.c - rts/Schedule.c - rts/Schedule.h - rts/Sparks.h - rts/Stats.c - rts/Trace.c - rts/Trace.h - rts/include/rts/storage/MBlock.h - rts/sm/BlockAlloc.c - 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/MarkWeak.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/NonMovingShortcut.c - rts/sm/NonMovingSweep.c - rts/sm/Sanity.c - rts/sm/Sanity.h The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8597d2bc2ed61910af3d8177715e16efbe2eb2ef...89fba7d861d11d91fdec1d6ee7da67d49780bd98 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8597d2bc2ed61910af3d8177715e16efbe2eb2ef...89fba7d861d11d91fdec1d6ee7da67d49780bd98 You're receiving 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 Jan 9 20:38:23 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 09 Jan 2023 15:38:23 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22264-extras Message-ID: <63bc7b3f94ae9_3b1bf955be016043e@gitlab.mail> Ben Gamari pushed new branch wip/T22264-extras at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22264-extras You're receiving 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 Jan 9 21:10:25 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 09 Jan 2023 16:10:25 -0500 Subject: [Git][ghc/ghc][wip/T22725] 3 commits: Disable split sections on aarch64-deb10 build Message-ID: <63bc82c168014_3b1bf95263417637@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22725 at Glasgow Haskell Compiler / GHC Commits: 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 275cab6c by Simon Peyton Jones at 2023-01-09T21:10:48+00:00 Fix void-arg-adding mechanism for worker/wrapper As #22725 shows, in worker/wrapper we must add the void argument /last/, not first. See GHC.Core.Opt.WorkWrap.Utils Note [Worker/wrapper needs to add void arg last]. That led me to to study GHC.Core.Opt.SpecConstr Note [SpecConstr needs to add void args first] which suggests the opposite! And indeed I think it's the other way round for SpecConstr -- or more precisely the void arg must precede the "extra_bndrs". That led me to some refactoring of GHC.Core.Opt.SpecConstr.calcSpecInfo. - - - - - 15 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - + testsuite/tests/printer/HsDocTy.hs - testsuite/tests/printer/Makefile - testsuite/tests/printer/all.T - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/simplCore/should_compile/T18328.stderr - + testsuite/tests/simplCore/should_compile/T22725.hs - testsuite/tests/simplCore/should_compile/all.T - utils/check-exact/ExactPrint.hs - utils/check-exact/Main.hs Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -813,7 +813,7 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , standardBuilds Amd64 Darwin , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin - , standardBuilds AArch64 (Linux Debian10) + , standardBuildsWithConfig AArch64 (Linux Debian10) (splitSectionsBroken vanilla) , disableValidate (standardBuildsWithConfig AArch64 (Linux Debian10) llvm) , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla) , standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static) ===================================== .gitlab/jobs.yaml ===================================== @@ -1926,7 +1926,7 @@ "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release": { + "release-aarch64-linux-deb10-release+llvm": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1936,7 +1936,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release.tar.xz", + "ghc-aarch64-linux-deb10-release+llvm.tar.xz", "junit.xml" ], "reports": { @@ -1978,15 +1978,15 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", + "BUILD_FLAVOUR": "release+llvm", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release", + "TEST_ENV": "aarch64-linux-deb10-release+llvm", "XZ_OPT": "-9" } }, - "release-aarch64-linux-deb10-release+llvm": { + "release-aarch64-linux-deb10-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1996,7 +1996,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-aarch64-linux-deb10-release+llvm.tar.xz", + "ghc-aarch64-linux-deb10-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2038,11 +2038,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+llvm", - "BUILD_FLAVOUR": "release+llvm", + "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "aarch64-linux-deb10-release+llvm", + "TEST_ENV": "aarch64-linux-deb10-release+no_split_sections", "XZ_OPT": "-9" } }, ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -53,6 +53,7 @@ import GHC.Unit.Module.ModGuts import GHC.Types.Literal ( litIsLifted ) import GHC.Types.Id import GHC.Types.Id.Info ( IdDetails(..) ) +import GHC.Types.Id.Make ( voidArgId, voidPrimId ) import GHC.Types.Var.Env import GHC.Types.Var.Set import GHC.Types.Name @@ -1924,23 +1925,9 @@ spec_one env fn arg_bndrs body (call_pat, rule_number) -- And build the results ; (qvars', pats') <- generaliseDictPats qvars pats - ; let spec_body_ty = exprType spec_body - (spec_lam_args1, spec_sig, spec_arity1, spec_join_arity1) - = calcSpecInfo fn call_pat extra_bndrs - -- Annotate the variables with the strictness information from - -- the function (see Note [Strictness information in worker binders]) - add_void_arg = needsVoidWorkerArg fn arg_bndrs spec_lam_args1 - (spec_lam_args, spec_call_args, spec_arity, spec_join_arity) - | add_void_arg - -- See Note [SpecConstr needs to add void args first] - , (spec_lam_args, spec_call_args, _) <- addVoidWorkerArg spec_lam_args1 [] - -- needsVoidWorkerArg: usual w/w hack to avoid generating - -- a spec_rhs of unlifted type and no args. - , !spec_arity <- spec_arity1 + 1 - , !spec_join_arity <- fmap (+ 1) spec_join_arity1 - = (spec_lam_args, spec_call_args, spec_arity, spec_join_arity) - | otherwise - = (spec_lam_args1, spec_lam_args1, spec_arity1, spec_join_arity1) + ; let spec_body_ty = exprType spec_body + (spec_lam_args, spec_call_args, spec_sig, spec_arity, spec_join_arity) + = calcSpecInfo fn arg_bndrs call_pat extra_bndrs spec_id = asWorkerLikeId $ mkLocalId spec_name ManyTy @@ -1953,11 +1940,7 @@ spec_one env fn arg_bndrs body (call_pat, rule_number) -- Conditionally use result of new worker-wrapper transform spec_rhs = mkLams spec_lam_args (mkSeqs cbv_args spec_body_ty spec_body) - rule_rhs = mkVarApps (Var spec_id) $ - -- This will give us all the arguments we quantify over - -- in the rule plus the void argument if present - -- since `length(qvars) + void + length(extra_bndrs) = length spec_call_args` - dropTail (length extra_bndrs) spec_call_args + rule_rhs = mkVarApps (Var spec_id) spec_call_args inline_act = idInlineActivation fn this_mod = sc_module $ sc_opts env rule = mkRule this_mod True {- Auto -} True {- Local -} @@ -2023,30 +2006,41 @@ mkSeqs seqees res_ty rhs = {- Note [SpecConstr needs to add void args first] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider a function + f :: Bool -> forall t. blah f start @t = e We want to specialize for a partially applied call `f True`. See also Note [SpecConstr call patterns], second Wrinkle. Naively we would expect to get + $sf :: forall t. blah $sf @t = $se RULE: f True = $sf -The specialized function only takes a single type argument -so we add a void argument to prevent it from turning into -a thunk. See Note [Protecting the last value argument] for details -why. Normally we would add the void argument after the -type argument giving us: +The specialized function only takes a single type argument so we add a +void argument to prevent it from turning into a thunk. See Note +[Protecting the last value argument] for details why. Normally we +would add the void argument after the type argument giving us: + $sf :: forall t. Void# -> bla $sf @t void = $se RULE: f True = $sf void# (wrong) -But if you look closely this wouldn't typecheck! -If we substitute `f True` with `$sf void#` we expect the type argument to be applied first -but we apply void# first. -The easiest fix seems to be just to add the void argument to the front of the arguments. -Now we get: + +But if you look closely this wouldn't typecheck! If we substitute `f +True` with `$sf void#` we expect the type argument to be applied first +but we apply void# first. The easiest fix seems to be just to add the +void argument to the front of the arguments. Now we get: + $sf :: Void# -> forall t. bla $sf void @t = $se RULE: f True = $sf void# + And now we can substitute `f True` with `$sf void#` with everything working out nicely! +More preisely, we need the void arg to precede the `extra_bndrs` in +calcSpecInfo, but it's fine it put it before /all/ the arguments. + +Note that putting the extra arg first is exactly from what is needed +in worker/wrapper; see Note [Worker/wrapper needs to add void arg last] +in GHC.Core.Opt.WorkWrap.Utils. + Note [generaliseDictPats] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider these two rules (#21831, item 2): @@ -2076,35 +2070,49 @@ And /now/ "SPEC:foo" is clearly more specific: we can instantiate the new -} calcSpecInfo :: Id -- The original function + -> [InVar] -- Lambda binders of original RHS -> CallPat -- Call pattern -> [Var] -- Extra bndrs - -> ( [Var] -- Demand-decorated binders + -> ( [Var] -- Demand-decorated lambda binders + -- for RHS of specialised function + , [Var] -- Args for call site , DmdSig -- Strictness of specialised thing , Arity, Maybe JoinArity ) -- Arities of specialised thing -- Calculate bits of IdInfo for the specialised function -- See Note [Transfer strictness] -- See Note [Strictness information in worker binders] -calcSpecInfo fn (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs - | isJoinId fn -- Join points have strictness and arity for LHS only - = ( bndrs_w_dmds - , mkClosedDmdSig qvar_dmds div - , count isId qvars - , Just (length qvars) ) +calcSpecInfo fn arg_bndrs (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs + | needsVoidWorkerArg fn arg_bndrs spec_lam_bndrs_w_dmds + = -- Usual w/w hack to avoid generating + -- a spec_rhs of unlifted type and no args. + -- See Note [SpecConstr needs to add void args first] + ( voidArgId : spec_lam_bndrs_w_dmds + , voidPrimId : qvars_w_dmds + , mkClosedDmdSig (topDmd : all_dmds) div + , arity + 1 + , if isJoinId fn then Just (length qvars + 1) else Nothing ) + | otherwise - = ( bndrs_w_dmds - , mkClosedDmdSig (qvar_dmds ++ extra_dmds) div - , count isId qvars + count isId extra_bndrs - , Nothing ) + = ( spec_lam_bndrs_w_dmds + , qvars_w_dmds + , mkClosedDmdSig all_dmds div + , arity + , if isJoinId fn then Just (length qvars) else Nothing ) where DmdSig (DmdType _ fn_dmds div) = idDmdSig fn + arity = count isId qvars + count isId extra_bndrs + all_dmds = qvar_dmds ++ extra_dmds val_pats = filterOut isTypeArg pats -- value args at call sites, used to determine how many demands to drop -- from the original functions demand and for setting up dmd_env. qvar_dmds = [ lookupVarEnv dmd_env qv `orElse` topDmd | qv <- qvars, isId qv ] extra_dmds = dropList val_pats fn_dmds - bndrs_w_dmds = set_dmds qvars qvar_dmds - ++ set_dmds extra_bndrs extra_dmds + -- Annotate the variables with the strictness information from + -- the function (see Note [Strictness information in worker binders]) + qvars_w_dmds = set_dmds qvars qvar_dmds + extras_w_dmds = set_dmds extra_bndrs extra_dmds + spec_lam_bndrs_w_dmds = qvars_w_dmds ++ extras_w_dmds set_dmds :: [Var] -> [Demand] -> [Var] set_dmds [] _ = [] @@ -2127,7 +2135,6 @@ calcSpecInfo fn (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs = go env ds args go_one env _ _ = env - {- Note [spec_usg includes rhs_usg] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -9,7 +9,7 @@ A library for the ``worker\/wrapper'' back-end to the strictness analyser module GHC.Core.Opt.WorkWrap.Utils ( WwOpts(..), mkWwBodies, mkWWstr, mkWWstr_one - , needsVoidWorkerArg, addVoidWorkerArg + , needsVoidWorkerArg , DataConPatContext(..) , UnboxingDecision(..), canUnboxArg , findTypeShape, IsRecDataConResult(..), isRecDataCon @@ -377,25 +377,34 @@ We use the state-token type which generates no code. -- Note [Preserving float barriers]. needsVoidWorkerArg :: Id -> [Var] -> [Var] -> Bool needsVoidWorkerArg fn_id wrap_args work_args - = not (isJoinId fn_id) && no_value_arg -- See Note [Protecting the last value argument] - || needs_float_barrier -- See Note [Preserving float barriers] + = thunk_problem -- See Note [Protecting the last value argument] + || needs_float_barrier -- See Note [Preserving float barriers] where - no_value_arg = all (not . isId) work_args + -- thunk_problem: see Note [Protecting the last value argument] + -- For join points we are only worried about (4), not (1-4). + -- And (4) can't happen if (null work_args) + -- (We could be more clever, by looking at the result type, but + -- this approach is simple and conservative.) + thunk_problem | isJoinId fn_id = no_value_arg && not (null work_args) + | otherwise = no_value_arg + no_value_arg = not (any isId work_args) + + -- needs_float_barrier: see Note [Preserving float barriers] + needs_float_barrier = wrap_had_barrier && not work_has_barrier is_float_barrier v = isId v && hasNoOneShotInfo (idOneShotInfo v) wrap_had_barrier = any is_float_barrier wrap_args work_has_barrier = any is_float_barrier work_args - needs_float_barrier = wrap_had_barrier && not work_has_barrier --- | Inserts a `Void#` arg before the first argument. --- --- Why as the first argument? See Note [SpecConstr needs to add void args first] --- in SpecConstr. +-- | Inserts a `Void#` arg as the last argument. +-- Why last? See Note [Worker/wrapper needs to add void arg last] addVoidWorkerArg :: [Var] -> [StrictnessMark] - -> ([Var], -- Lambda bound args - [Var], -- Args at call site - [StrictnessMark]) -- str semantics for the worker args. + -> ( [Var] -- Lambda bound args + , [Var] -- Args at call site + , [StrictnessMark]) -- str semantics for the worker args addVoidWorkerArg work_args str_marks - = (voidArgId : work_args, voidPrimId:work_args, NotMarkedStrict:str_marks) + = ( work_args ++ [voidArgId] + , work_args ++ [voidPrimId] + , str_marks ++ [NotMarkedStrict] ) {- Note [Protecting the last value argument] @@ -403,8 +412,8 @@ Note [Protecting the last value argument] If the user writes (\_ -> E), they might be intentionally disallowing the sharing of E. Since absence analysis and worker-wrapper are keen to remove such unused arguments, we add in a void argument to prevent -the function from becoming a thunk. Three reasons why turning a function -into a thunk might be bad: +the function from becoming a thunk. Here are several reasons why turning +a function into a thunk might be bad: 1) It can create a space leak. e.g. f x = let y () = [1..x] @@ -423,7 +432,19 @@ into a thunk might be bad: g = \x. 30# Removing the \x would leave an unlifted binding. -NB: none of these apply to a join point. +4) It can create a worker of ill-kinded type (#22275). Consider + f :: forall r (a :: TYPE r). () -> a + f x = f x + Here `x` is absent, but if we simply drop it we'd end up with + $wf :: forall r (a :: TYPE r). a + But alas $wf's type is ill-kinded: the kind of (/\r (a::TYPE r).a) + is (TYPE r), which mentions the bound variable `r`. See also + Note [Worker/wrapper needs to add void arg last] + +See also Note [Preserving float barriers] + +NB: Of these, only (1-3) don't apply to a join point, which can be +unlifted even if the RHS is not ok-for-speculation. Note [Preserving float barriers] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -457,7 +478,7 @@ which some are absent or one-shot and the resulting worker arguments: * \a{Abs}.\b{os}.\c{os}... ==> \b{os}.\c{os}.\(_::Void#)... Wrapper arg `a` was the only float barrier and had been dropped. Hence Void# - * \a{Abs,os}.\b{os}.\c... ==> \b{os}.\c... +p * \a{Abs,os}.\b{os}.\c... ==> \b{os}.\c... Worker arg `c` is a float barrier. * \a.\b{Abs}.\c{os}... ==> \a.\c{os}... Worker arg `a` is a float barrier. @@ -469,6 +490,28 @@ which some are absent or one-shot and the resulting worker arguments: Executable examples in T21150. +Note [Worker/wrapper needs to add void arg last] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider point (4) of Note [Protecting the last value argument] + + f :: forall r (a :: TYPE r). () -> a + f x = f x + +As pointed out in (4) we need to add a void argument. But if we add +it /first/ we'd get + + $wf :: Void# -> forall r (a :: TYPE r). a + $wf = ... + +But alas $wf's type is /still/ still-kinded, just as before in (4). +Solution is simple: put the void argument /last/: + + $wf :: forall r (a :: TYPE r). Void# -> a + $wf = ... + +Notice that this is exactly backwards from GHC.Core.Opt.SpecConstr +Note [SpecConstr needs to add void args first]. + Note [Join points and beta-redexes] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Originally, the worker would invoke the original function by calling it with ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1337,7 +1337,7 @@ ty_con_app_fun_maybe many_ty_co tc args | otherwise = Nothing -mkFunctionType :: Mult -> Type -> Type -> Type +mkFunctionType :: HasDebugCallStack => Mult -> Type -> Type -> Type -- ^ This one works out the FunTyFlag from the argument type -- See GHC.Types.Var Note [FunTyFlag] mkFunctionType mult arg_ty res_ty ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -158,7 +158,7 @@ coreAltsType :: [CoreAlt] -> Type coreAltsType (alt:_) = coreAltType alt coreAltsType [] = panic "coreAltsType" -mkLamType :: Var -> Type -> Type +mkLamType :: HasDebugCallStack => Var -> Type -> Type -- ^ Makes a @(->)@ type or an implicit forall type, depending -- on whether it is given a type variable or a term variable. -- This is used, for example, when producing the type of a lambda. ===================================== testsuite/tests/printer/HsDocTy.hs ===================================== @@ -0,0 +1,6 @@ +{-# OPTIONS_GHC -haddock #-} +module HsDocTy where + +class C1 a where + f1 :: a -> Int + -- ^ comment on Int ===================================== testsuite/tests/printer/Makefile ===================================== @@ -769,3 +769,9 @@ Test21355: Test21805: $(CHECK_PPR) $(LIBDIR) Test21805.hs $(CHECK_EXACT) $(LIBDIR) Test21805.hs + +.PHONY: HsDocTy +HsDocTy: + # See comment on pprWithDocString, this won't round trip + # $(CHECK_PPR) $(LIBDIR) HsDocTy.hs + $(CHECK_EXACT) $(LIBDIR) HsDocTy.hs ===================================== testsuite/tests/printer/all.T ===================================== @@ -185,4 +185,5 @@ test('Test21805', [ignore_stderr, req_ppr_deps], makefile_test, ['Test21805']) test('T22488', normal, ghci_script, ['T22488.script']) test('T22488_docHead', normal, compile_and_run, ['-package ghc']) test('T20531', extra_files(['T20531_defs.hs']), ghci_script, ['T20531.script']) -test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) \ No newline at end of file +test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) +test('HsDocTy', [ignore_stderr, req_ppr_deps], makefile_test, ['HsDocTy']) \ No newline at end of file ===================================== testsuite/tests/simplCore/should_compile/T13143.stderr ===================================== @@ -1,14 +1,14 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 71, types: 41, coercions: 0, joins: 0/0} + = {terms: 71, types: 40, coercions: 0, joins: 0/0} Rec { -- RHS size: {terms: 4, types: 3, coercions: 0, joins: 0/0} T13143.$wf [InlPrag=NOINLINE, Occ=LoopBreaker] - :: (# #) -> forall {a}. a + :: forall {a}. (# #) -> a [GblId, Arity=1, Str=b, Cpr=b, Unf=OtherCon []] -T13143.$wf = \ _ [Occ=Dead] (@a) -> T13143.$wf GHC.Prim.(##) @a +T13143.$wf = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##) end Rec } -- RHS size: {terms: 4, types: 3, coercions: 0, joins: 0/0} @@ -17,55 +17,60 @@ f [InlPrag=NOINLINE[final]] :: forall a. Int -> a Arity=1, Str=b, Cpr=b, - 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=True) - Tmpl= \ (@a) _ [Occ=Dead] -> T13143.$wf GHC.Prim.(##) @a}] -f = \ (@a) _ [Occ=Dead] -> T13143.$wf GHC.Prim.(##) @a + Tmpl= \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##)}] +f = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##) -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T13143.$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}] T13143.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T13143.$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}] T13143.$trModule3 = GHC.Types.TrNameS T13143.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T13143.$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}] T13143.$trModule2 = "T13143"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T13143.$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}] 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}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T13143.$trModule = GHC.Types.Module T13143.$trModule3 T13143.$trModule1 --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -lvl :: forall {a}. a +-- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} +lvl :: Int [GblId, Str=b, Cpr=b] -lvl = T13143.$wf GHC.Prim.(##) +lvl = T13143.$wf @Int GHC.Prim.(##) Rec { --- RHS size: {terms: 28, types: 8, coercions: 0, joins: 0/0} +-- RHS size: {terms: 28, types: 7, coercions: 0, joins: 0/0} T13143.$wg [InlPrag=[2], Occ=LoopBreaker] :: Bool -> Bool -> GHC.Prim.Int# -> GHC.Prim.Int# [GblId[StrictWorker([!, !])], @@ -94,8 +99,8 @@ g [InlPrag=[2]] :: Bool -> Bool -> Int -> Int Arity=3, Str=<1L><1L><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=3,unsat_ok=True,boring_ok=False) Tmpl= \ (ds [Occ=Once1] :: Bool) (ds1 [Occ=Once1] :: Bool) ===================================== testsuite/tests/simplCore/should_compile/T18328.stderr ===================================== @@ -1,84 +1,90 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 65, types: 53, coercions: 0, joins: 1/1} + = {terms: 69, types: 55, coercions: 0, joins: 1/1} --- RHS size: {terms: 38, types: 23, coercions: 0, joins: 1/1} +-- RHS size: {terms: 42, types: 25, coercions: 0, joins: 1/1} T18328.$wf [InlPrag=[2]] :: forall {a}. GHC.Prim.Int# -> [a] -> [a] -> [a] -[GblId, +[GblId[StrictWorker([~, !])], Arity=3, Str=, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [176 0 0] 306 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [176 0 0] 306 0}] T18328.$wf - = \ (@a) (ww :: GHC.Prim.Int#) (w :: [a]) (w1 :: [a]) -> + = \ (@a) (ww :: GHC.Prim.Int#) (ys :: [a]) (eta :: [a]) -> join { - $wj [InlPrag=NOINLINE, Dmd=ML] :: forall {p}. [a] - [LclId[JoinId(1)]] - $wj (@p) + $wj [InlPrag=NOINLINE, Dmd=MC(1,L)] :: forall {p}. (# #) -> [a] + [LclId[JoinId(2)(Nothing)], Arity=1, Str=, Unf=OtherCon []] + $wj (@p) _ [Occ=Dead, OS=OneShot] = case ww of { - __DEFAULT -> ++ @a w (++ @a w (++ @a w w1)); - 3# -> ++ @a w (++ @a w (++ @a w (++ @a w w1))) + __DEFAULT -> ++ @a ys (++ @a ys (++ @a ys eta)); + 3# -> ++ @a ys (++ @a ys (++ @a ys (++ @a ys eta))) } } in case ww of { - __DEFAULT -> ++ @a w w1; - 1# -> jump $wj @Integer; - 2# -> jump $wj @Integer; - 3# -> jump $wj @Integer + __DEFAULT -> ++ @a ys eta; + 1# -> jump $wj @Integer GHC.Prim.(##); + 2# -> jump $wj @Integer GHC.Prim.(##); + 3# -> jump $wj @Integer GHC.Prim.(##) } -- RHS size: {terms: 11, types: 9, coercions: 0, joins: 0/0} f [InlPrag=[2]] :: forall a. Int -> [a] -> [a] -> [a] [GblId, Arity=3, - Str=<1P(SL)>, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Str=<1!P(SL)>, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) Tmpl= \ (@a) - (w [Occ=Once1!] :: Int) - (w1 [Occ=Once1] :: [a]) - (w2 [Occ=Once1] :: [a]) -> - case w of { GHC.Types.I# ww [Occ=Once1] -> - T18328.$wf @a ww w1 w2 + (x [Occ=Once1!] :: Int) + (ys [Occ=Once1] :: [a]) + (eta [Occ=Once1] :: [a]) -> + case x of { GHC.Types.I# ww [Occ=Once1] -> + T18328.$wf @a ww ys eta }}] -f = \ (@a) (w :: Int) (w1 :: [a]) (w2 :: [a]) -> - case w of { GHC.Types.I# ww -> T18328.$wf @a ww w1 w2 } +f = \ (@a) (x :: Int) (ys :: [a]) (eta :: [a]) -> + case x of { GHC.Types.I# ww -> T18328.$wf @a ww ys eta } -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule3 = GHC.Types.TrNameS T18328.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule2 = "T18328"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule1 = GHC.Types.TrNameS T18328.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T18328.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T18328.$trModule = GHC.Types.Module T18328.$trModule3 T18328.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T22725.hs ===================================== @@ -0,0 +1,6 @@ +module M where + +import GHC.Exts (TYPE) + +f :: forall r (a :: TYPE r). () -> a +f x = f x ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -462,3 +462,4 @@ test('T22272', normal, multimod_compile, ['T22272', '-O -fexpose-all-unfoldings test('T22459', normal, compile, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) test('T22662', normal, compile, ['']) +test('T22725', normal, compile, ['-O']) ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -3898,6 +3898,10 @@ instance ExactPrint (HsType GhcPs) where exact (HsSpliceTy a splice) = do splice' <- markAnnotated splice return (HsSpliceTy a splice') + exact (HsDocTy an ty doc) = do + ty' <- markAnnotated ty + doc' <- markAnnotated doc + return (HsDocTy an ty' doc') exact (HsBangTy an (HsSrcBang mt up str) ty) = do an0 <- case mt of ===================================== utils/check-exact/Main.hs ===================================== @@ -59,7 +59,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../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) - "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) + -- "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3a.hs" (Just changeWhereIn3a) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3b.hs" (Just changeWhereIn3b) -- "../../testsuite/tests/ghc-api/exactprint/AddLocalDecl1.hs" (Just addLocaLDecl1) @@ -203,6 +203,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../testsuite/tests/ghc-api/exactprint/Test20239.hs" Nothing -- "../../testsuite/tests/printer/PprArrowLambdaCase.hs" Nothing -- "../../testsuite/tests/printer/Test16279.hs" Nothing + "../../testsuite/tests/printer/HsDocTy.hs" Nothing -- cloneT does not need a test, function can be retired View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7797c1150f6cf620b731e29076bad41cbdf5f18c...275cab6c2de7c082a7c17f32b64a6edee41a0f4e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7797c1150f6cf620b731e29076bad41cbdf5f18c...275cab6c2de7c082a7c17f32b64a6edee41a0f4e You're receiving 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 Jan 9 22:11:22 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 09 Jan 2023 17:11:22 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/specialize-hdoc Message-ID: <63bc910a2dda7_3b1bf93fcc9902196ac@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/specialize-hdoc at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/specialize-hdoc You're receiving 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 Jan 9 23:17:49 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 09 Jan 2023 18:17:49 -0500 Subject: [Git][ghc/ghc][wip/T22725] Fix finaliseArgBoxities for OPAQUE function Message-ID: <63bca09d1e735_3b1bf95260c22879@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22725 at Glasgow Haskell Compiler / GHC Commits: 7da376f1 by Simon Peyton Jones at 2023-01-09T23:17:50+00:00 Fix finaliseArgBoxities for OPAQUE function This patch fixes #22502 - - - - - 3 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - + testsuite/tests/simplCore/should_compile/T22502.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -41,7 +41,6 @@ import GHC.Core.Opt.Arity ( typeArity ) import GHC.Utils.Misc import GHC.Utils.Panic import GHC.Utils.Panic.Plain -import GHC.Data.Maybe import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set @@ -1071,9 +1070,8 @@ dmdAnalRhsSig top_lvl rec_flag env let_dmd id rhs WithDmdType rhs_dmd_ty rhs' = dmdAnal env rhs_dmd rhs DmdType rhs_fv rhs_dmds rhs_div = rhs_dmd_ty - -- See Note [Boxity for bottoming functions] - (final_rhs_dmds, final_rhs) = finaliseArgBoxities env id threshold_arity rhs' rhs_div - `orElse` (rhs_dmds, rhs') + (final_rhs_dmds, final_rhs) = finaliseArgBoxities env id threshold_arity + rhs_dmds rhs_div rhs' sig = mkDmdSigForArity threshold_arity (DmdType sig_fv final_rhs_dmds rhs_div) @@ -1252,7 +1250,9 @@ The threshold we use is * Ordinary bindings: idArity f. Why idArity arguments? Because that's a conservative estimate of how many arguments we must feed a function before it does anything interesting with - them. Also it elegantly subsumes the trivial RHS and PAP case. + them. Also it elegantly subsumes the trivial RHS and PAP case. E.g. for + f = g + we want to use a threshold arity based on g, not 0! idArity is /at least/ the number of manifest lambdas, but might be higher for PAPs and trivial RHS (see Note [Demand analysis for trivial right-hand sides]). @@ -1902,21 +1902,33 @@ spendTopBudget m (MkB n bg) = MkB (n-m) bg positiveTopBudget :: Budgets -> Bool positiveTopBudget (MkB n _) = n >= 0 -finaliseArgBoxities :: AnalEnv -> Id -> Arity -> CoreExpr -> Divergence - -> Maybe ([Demand], CoreExpr) -finaliseArgBoxities env fn arity rhs div - | arity > count isId bndrs -- Can't find enough binders - = Nothing -- This happens if we have f = g - -- Then there are no binders; we don't worker/wrapper; and we - -- simply want to give f the same demand signature as g - - | otherwise -- NB: arity is the threshold_arity, which might be less than +finaliseArgBoxities :: AnalEnv -> Id -> Arity + -> [Demand] -> Divergence + -> CoreExpr -> ([Demand], CoreExpr) +finaliseArgBoxities env fn threshold_arity rhs_dmds div rhs + + -- Check for an OPAQUE function: see Note [OPAQUE pragma] + -- In that case, trim off all boxity info from argument demands + -- See Note [The OPAQUE pragma and avoiding the reboxing of arguments] + | isOpaquePragma (idInlinePragma fn) + , let trimmed_rhs_dmds = map trimBoxity rhs_dmds + = (trimmed_rhs_dmds, add_demands trimmed_rhs_dmds rhs) + + -- Check that we have enough visible binders to match the + -- threshold arity; if not, we won't do worker/wrapper + -- This happens if we have simply f=g + -- we simply want to give f the same demand signature as g + | threshold_arity > count isId bndrs + = (rhs_dmds, rhs) + + -- The normal case + | otherwise -- NB: threshold_arity might be less than -- manifest arity for join points = -- pprTrace "finaliseArgBoxities" ( -- vcat [text "function:" <+> ppr fn -- , text "dmds before:" <+> ppr (map idDemandInfo (filter isId bndrs)) -- , text "dmds after: " <+> ppr arg_dmds' ]) $ - Just (arg_dmds', add_demands arg_dmds' rhs) + (arg_dmds', add_demands arg_dmds' rhs) -- add_demands: we must attach the final boxities to the lambda-binders -- of the function, both because that's kosher, and because CPR analysis -- uses the info on the binders directly. @@ -1934,7 +1946,7 @@ finaliseArgBoxities env fn arity rhs div (remaining_budget, arg_dmds') = go_args (MkB max_wkr_args remaining_budget) arg_triples arg_triples :: [(Type, StrictnessMark, Demand)] - arg_triples = take arity $ + arg_triples = take threshold_arity $ [ (bndr_ty, NotMarkedStrict, get_dmd bndr bndr_ty) | bndr <- bndrs , isRuntimeVar bndr, let bndr_ty = idType bndr ] @@ -1950,14 +1962,9 @@ finaliseArgBoxities env fn arity rhs div | is_bot_fn = unboxDeeplyDmd dmd -- See Note [Boxity for bottoming functions], case (B) - | is_opaque = trimBoxity dmd - -- See Note [OPAQUE pragma] - -- See Note [The OPAQUE pragma and avoiding the reboxing of arguments] - | otherwise = dmd where - dmd = idDemandInfo bndr - is_opaque = isOpaquePragma (idInlinePragma fn) + dmd = idDemandInfo bndr -- is_bot_fn: see Note [Boxity for bottoming functions] is_bot_fn = div == botDiv @@ -2020,6 +2027,10 @@ finaliseArgBoxities env fn arity rhs div add_demands (dmd:dmds) (Lam v e) | isTyVar v = Lam v (add_demands (dmd:dmds) e) | otherwise = Lam (v `setIdDemandInfo` dmd) (add_demands dmds e) + add_demands dmds (Cast e co) = Cast (add_demands dmds e) co + -- This case happens for an OPAQUE function, which may look like + -- f = (\x y. blah) |> co + -- We give it strictness but no boxity add_demands dmds e = pprPanic "add_demands" (ppr dmds $$ ppr e) finaliseLetBoxity ===================================== testsuite/tests/simplCore/should_compile/T22502.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +module M where + +import GHC.Exts +import GHC.IO + +data T a = MkT !Bool !a + +fun :: T a -> IO a +{-# OPAQUE fun #-} +fun (MkT _ x) = IO $ \s -> noinline seq# x s +-- evaluate/seq# should not produce its own eval for x +-- since it is properly tagged (from a strict field) + +-- uses noinline to prevent caseRules from eliding the seq# in Core ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -463,3 +463,4 @@ test('T22459', normal, compile, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) test('T22662', normal, compile, ['']) test('T22725', normal, compile, ['-O']) +test('T22502', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7da376f1a1887fe3e31ee242efe3f73a5525f450 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7da376f1a1887fe3e31ee242efe3f73a5525f450 You're receiving 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 Jan 9 23:25:10 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Mon, 09 Jan 2023 18:25:10 -0500 Subject: [Git][ghc/ghc][wip/az/exactprint-epalocation-for-anchor] 186 commits: Fix bounds-checking buglet in Data.Array.Byte Message-ID: <63bca256c0aa0_3b1bf98fe52c42309ea@gitlab.mail> Alan Zimmerman pushed to branch wip/az/exactprint-epalocation-for-anchor 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 - - - - - 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]. - - - - - 2eb0fb87 by Matthew Pickering at 2022-12-15T03:54:39-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 - - - - - 552b7908 by Ben Gamari at 2022-12-15T03:55:15-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. - - - - - 933d61a4 by Simon Peyton Jones at 2022-12-15T03:55:51-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. - - - - - 03ed0b95 by Ryan Scott at 2022-12-15T03:56:26-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. - - - - - ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/ThreadPaused: Ordering fixes - - - - - 914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00 eventlog: Silence spurious data race - - - - - fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts: Use fences instead of explicit barriers - - - - - 2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - 70999283 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 98689f77 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - 86f20258 by Ben Gamari at 2022-12-16T16:12:45-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. - - - - - f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate access to capabilities array - - - - - 7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate sched_state - - - - - 1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Style fix - - - - - 82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00 compiler: Use release store in eager blackholing - - - - - eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Fix ordering of makeStableName - - - - - ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Note race with wakeBlockingQueue - - - - - 5acf33dd by Bodigrim at 2022-12-16T16:13:22-05:00 Bump submodule directory to 1.3.8.0 and hpc to HEAD - - - - - 0dd95421 by Bodigrim at 2022-12-16T16:13:22-05:00 Accept allocations increase on Windows This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips between lists and ByteArray. See #22625 for discussion. Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T10547 T12150 T12227 T12234 T12425 T13035 T13253 T13253-spj T13701 T13719 T15703 T16875 T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T21839r T5837 T6048 T9198 T9961 TcPlugin_RewritePerf hard_hole_fits - - - - - ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00 testsuite: Mark T9405 as fragile instead of broken on Windows It's starting to pass again, and the unexpected pass blocks CI. - - - - - 1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: remove obsolete commented code in wasm NCG It was just a temporary hack to workaround a bug in the relooper, that bug has been fixed long before the wasm backend is merged. - - - - - e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm Also removes some unreachable code here. - - - - - 1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: change fallback function signature to Cmm function signature in wasm NCG In the wasm NCG, when handling a `CLabel` of undefined function without knowing its function signature, we used to fallback to `() -> ()` which is accepted by `wasm-ld`. This patch changes it to the signature of Cmm functions, which equally works, but would be required when we emit tail call instructions. - - - - - 8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add optional tail-call support in wasm NCG When the `-mtail-call` clang flag is passed at configure time, wasm tail-call extension is enabled, and the wasm NCG will emit `return_call`/`return_call_indirect` instructions to take advantage of it and avoid the `StgRun` trampoline overhead. Closes #22461. - - - - - d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00 base: add missing autoconf checks for waitpid/umask These are not present in wasi-libc. Required for fixing #22589 - - - - - da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00 compiler: make .wasm the default executable extension on wasm32 Following convention as in other wasm toolchains. Fixes #22594. - - - - - ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00 ci: support hello.wasm in ci.sh cross testing logic - - - - - 6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00 Correct `exitWith` Haddocks The `IOError`-specific `catch` in the Prelude is long gone. - - - - - b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-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. - - - - - 761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00 rts/libdw: Silence uninitialized usage warnings As noted in #22538, previously some GCC versions warned that various locals in Libdw.c may be used uninitialized. Although this wasn't strictly true (since they were initialized in an inline assembler block) we fix this by providing explicit empty initializers. Fixes #22538 - - - - - 5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00 testsuite: Mark T16392 as fragile on windows See #22649 - - - - - 703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00 Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`. - - - - - 9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05: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 - - - - - 7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Drop uses of AC_PROG_CC_C99 As noted in #22566, this macro is deprecated as of autoconf-2.70 `AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself. Closes #22566. - - - - - 36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Use AS_HELP_STRING instead of AC_HELP_STRING The latter has been deprecated. See #22566. - - - - - befe6ff8 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: fix various usages of head and tail - - - - - 666d0ba7 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: avoid head and tail in parseCallEscape and around - - - - - 5d96fd50 by Bodigrim at 2022-12-20T21:16:37-05:00 Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty - - - - - 3ce2ab94 by Bodigrim at 2022-12-21T06:17:56-05:00 Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian - - - - - 954de93a by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule haskeline to HEAD (to allow transformers-0.6) - - - - - cefbeec3 by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule transformers to 0.6.0.4 - - - - - b4730b62 by Bodigrim at 2022-12-21T06:17:56-05:00 Fix tests T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations Metric Increase: T13253 - - - - - 0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05: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. - - - - - df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00 rts: explicitly store return value of ccall checkClosure to prevent type error (#22617) - - - - - e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix shadowing lacuna in OccurAnal Issue #22623 demonstrated another lacuna in the implementation of wrinkle (BS3) in Note [The binder-swap substitution] in the occurrence analyser. I was failing to add TyVar lambda binders using addInScope/addOneInScope and that led to a totally bogus binder-swap transformation. Very easy to fix. - - - - - 3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix an assertion check in addToEqualCtList The old assertion saw that a constraint ct could rewrite itself (of course it can) and complained (stupid). Fixes #22645 - - - - - ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00 configure: Bump version to 9.6 - - - - - fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00 base: Bump version to 4.18 Requires various submodule bumps. - - - - - 93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00 ghc-boot: Fix bootstrapping - - - - - fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00 Bump GHC version to 9.7 - - - - - 914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05: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. - - - - - 32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00 hadrian bindist: Install manpages to share/man/man1/ghc.1 When the installation makefile was copied over the manpages were no longer installed in the correct place. Now we install it into share/man/man1/ghc.1 as the make build system did. Fixes #22371 - - - - - b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00 rts: Drop paths from configure from cabal file A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them. - - - - - b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00 Bump libffi-tarballs submodule We will now use libffi-3.4.4. - - - - - 3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00 EPA: Make EOF position part of AnnsModule Closes #20951 Closes #19697 - - - - - 99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00 JS: fix support for -outputdir (#22641) The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug. - - - - - 02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00 Refactor mkRuntimeError This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions. - - - - - 35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00 base: Fix event manager shutdown race on non-Linux platforms During shutdown it's possible that we will attempt to use a closed fd to wakeup another capability's event manager. On the Linux eventfd path we were careful to handle this. However on the non-Linux path we failed to do so. Fix this. - - - - - 317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00 Fix unifier bug: failing to decompose over-saturated type family This simple patch fixes #22647 - - - - - 14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00 rts/m32: Fix sanity checking Previously we would attempt to clear pages which were marked as read-only. Fix this. - - - - - 16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00 ci: Move wasm pipelines into nightly rather than master See #22664 for the changes which need to be made to bring one of these back to the validate pipeline. - - - - - 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-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). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Bodigrim at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - 541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - 28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00 Add support for sized literals in the bytecode interpreter. The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945 - - - - - ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00 rts: MUT_VAR is not a StgMutArrPtrs There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs. - - - - - 6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s - - - - - 73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. - - - - - 8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 038b0113 by Alan Zimmerman at 2023-01-09T17:58:54+00:00 EPA: Replace Anchor with EpaLocation WIP. Compiles, but check-exact tests are failing. - - - - - 1b385a7d by Alan Zimmerman at 2023-01-09T17:58:54+00:00 EPA: remove anchor and anchor_op - - - - - 4d8dc5e8 by Alan Zimmerman at 2023-01-09T17:58:54+00:00 Remove Anchor = EpaLocation type synonym - - - - - d2540ee2 by Alan Zimmerman at 2023-01-09T17:59:57+00:00 EPA: When splitting out header comments, keep ones for first decl - - - - - 068b8e8a by Alan Zimmerman at 2023-01-09T18:00:01+00:00 WIP - - - - - 115fad7b by Alan Zimmerman at 2023-01-09T18:00:48+00:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. AZ Note: Add test based on parsing AddDecls1 - - - - - 8d00ca3b by Alan Zimmerman at 2023-01-09T18:01:58+00:00 Fix test results for EpaLocation not Anchor - - - - - b3808a7c by Alan Zimmerman at 2023-01-09T18:02:01+00:00 WIP Down to 23 failures - - - - - 3de6fe2e by Alan Zimmerman at 2023-01-09T23:24:55+00:00 WIP - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - compiler/CodeGen.Platform.h - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Info/Build.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.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/414268f575a2ce424b7ac994d32155444a2a6ac0...3de6fe2e619a262c526d336da99e3e97b189d1e1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/414268f575a2ce424b7ac994d32155444a2a6ac0...3de6fe2e619a262c526d336da99e3e97b189d1e1 You're receiving 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 Jan 9 23:26:56 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 09 Jan 2023 18:26:56 -0500 Subject: [Git][ghc/ghc][wip/T22725] Fix finaliseArgBoxities for OPAQUE function Message-ID: <63bca2c0a22e_3b1bf95263423117@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22725 at Glasgow Haskell Compiler / GHC Commits: 2c66b095 by Simon Peyton Jones at 2023-01-09T23:27:19+00:00 Fix finaliseArgBoxities for OPAQUE function This patch fixes #22502 - - - - - 3 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - + testsuite/tests/simplCore/should_compile/T22502.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -41,7 +41,6 @@ import GHC.Core.Opt.Arity ( typeArity ) import GHC.Utils.Misc import GHC.Utils.Panic import GHC.Utils.Panic.Plain -import GHC.Data.Maybe import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set @@ -1071,9 +1070,8 @@ dmdAnalRhsSig top_lvl rec_flag env let_dmd id rhs WithDmdType rhs_dmd_ty rhs' = dmdAnal env rhs_dmd rhs DmdType rhs_fv rhs_dmds rhs_div = rhs_dmd_ty - -- See Note [Boxity for bottoming functions] - (final_rhs_dmds, final_rhs) = finaliseArgBoxities env id threshold_arity rhs' rhs_div - `orElse` (rhs_dmds, rhs') + (final_rhs_dmds, final_rhs) = finaliseArgBoxities env id threshold_arity + rhs_dmds rhs_div rhs' sig = mkDmdSigForArity threshold_arity (DmdType sig_fv final_rhs_dmds rhs_div) @@ -1252,7 +1250,9 @@ The threshold we use is * Ordinary bindings: idArity f. Why idArity arguments? Because that's a conservative estimate of how many arguments we must feed a function before it does anything interesting with - them. Also it elegantly subsumes the trivial RHS and PAP case. + them. Also it elegantly subsumes the trivial RHS and PAP case. E.g. for + f = g + we want to use a threshold arity based on g, not 0! idArity is /at least/ the number of manifest lambdas, but might be higher for PAPs and trivial RHS (see Note [Demand analysis for trivial right-hand sides]). @@ -1902,21 +1902,33 @@ spendTopBudget m (MkB n bg) = MkB (n-m) bg positiveTopBudget :: Budgets -> Bool positiveTopBudget (MkB n _) = n >= 0 -finaliseArgBoxities :: AnalEnv -> Id -> Arity -> CoreExpr -> Divergence - -> Maybe ([Demand], CoreExpr) -finaliseArgBoxities env fn arity rhs div - | arity > count isId bndrs -- Can't find enough binders - = Nothing -- This happens if we have f = g - -- Then there are no binders; we don't worker/wrapper; and we - -- simply want to give f the same demand signature as g - - | otherwise -- NB: arity is the threshold_arity, which might be less than +finaliseArgBoxities :: AnalEnv -> Id -> Arity + -> [Demand] -> Divergence + -> CoreExpr -> ([Demand], CoreExpr) +finaliseArgBoxities env fn threshold_arity rhs_dmds div rhs + + -- Check for an OPAQUE function: see Note [OPAQUE pragma] + -- In that case, trim off all boxity info from argument demands + -- See Note [The OPAQUE pragma and avoiding the reboxing of arguments] + | isOpaquePragma (idInlinePragma fn) + , let trimmed_rhs_dmds = map trimBoxity rhs_dmds + = (trimmed_rhs_dmds, add_demands trimmed_rhs_dmds rhs) + + -- Check that we have enough visible binders to match the + -- threshold arity; if not, we won't do worker/wrapper + -- This happens if we have simply f=g + -- we simply want to give f the same demand signature as g + | threshold_arity > count isId bndrs + = (rhs_dmds, rhs) + + -- The normal case + | otherwise -- NB: threshold_arity might be less than -- manifest arity for join points = -- pprTrace "finaliseArgBoxities" ( -- vcat [text "function:" <+> ppr fn -- , text "dmds before:" <+> ppr (map idDemandInfo (filter isId bndrs)) -- , text "dmds after: " <+> ppr arg_dmds' ]) $ - Just (arg_dmds', add_demands arg_dmds' rhs) + (arg_dmds', add_demands arg_dmds' rhs) -- add_demands: we must attach the final boxities to the lambda-binders -- of the function, both because that's kosher, and because CPR analysis -- uses the info on the binders directly. @@ -1934,7 +1946,7 @@ finaliseArgBoxities env fn arity rhs div (remaining_budget, arg_dmds') = go_args (MkB max_wkr_args remaining_budget) arg_triples arg_triples :: [(Type, StrictnessMark, Demand)] - arg_triples = take arity $ + arg_triples = take threshold_arity $ [ (bndr_ty, NotMarkedStrict, get_dmd bndr bndr_ty) | bndr <- bndrs , isRuntimeVar bndr, let bndr_ty = idType bndr ] @@ -1950,14 +1962,9 @@ finaliseArgBoxities env fn arity rhs div | is_bot_fn = unboxDeeplyDmd dmd -- See Note [Boxity for bottoming functions], case (B) - | is_opaque = trimBoxity dmd - -- See Note [OPAQUE pragma] - -- See Note [The OPAQUE pragma and avoiding the reboxing of arguments] - | otherwise = dmd where - dmd = idDemandInfo bndr - is_opaque = isOpaquePragma (idInlinePragma fn) + dmd = idDemandInfo bndr -- is_bot_fn: see Note [Boxity for bottoming functions] is_bot_fn = div == botDiv @@ -2020,6 +2027,10 @@ finaliseArgBoxities env fn arity rhs div add_demands (dmd:dmds) (Lam v e) | isTyVar v = Lam v (add_demands (dmd:dmds) e) | otherwise = Lam (v `setIdDemandInfo` dmd) (add_demands dmds e) + add_demands dmds (Cast e co) = Cast (add_demands dmds e) co + -- This case happens for an OPAQUE function, which may look like + -- f = (\x y. blah) |> co + -- We give it strictness but no boxity (#22502) add_demands dmds e = pprPanic "add_demands" (ppr dmds $$ ppr e) finaliseLetBoxity ===================================== testsuite/tests/simplCore/should_compile/T22502.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +module M where + +import GHC.Exts +import GHC.IO + +data T a = MkT !Bool !a + +fun :: T a -> IO a +{-# OPAQUE fun #-} +fun (MkT _ x) = IO $ \s -> noinline seq# x s +-- evaluate/seq# should not produce its own eval for x +-- since it is properly tagged (from a strict field) + +-- uses noinline to prevent caseRules from eliding the seq# in Core ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -463,3 +463,4 @@ test('T22459', normal, compile, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) test('T22662', normal, compile, ['']) test('T22725', normal, compile, ['-O']) +test('T22502', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2c66b095151d28feded5e0d595842fc8bb82941c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2c66b095151d28feded5e0d595842fc8bb82941c You're receiving 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 Jan 9 23:32:49 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 09 Jan 2023 18:32:49 -0500 Subject: [Git][ghc/ghc][wip/misc-cleanup4] Misc cleanup Message-ID: <63bca421ddeb8_3b1bf952648237317@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/misc-cleanup4 at Glasgow Haskell Compiler / GHC Commits: 585d3ef6 by Krzysztof Gogolewski at 2023-01-10T00:13:02+01:00 Misc cleanup - Use typeTypeOrConstraint - more symmetric and asserts that that the type is Type or Constraint - Use text "foo" in JS, to make sure the rule fires - Fix escape sequences in Python; they raise a deprecation warning with -Wdefault - - - - - 13 changed files: - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Type.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/JS/Ppr.hs - compiler/GHC/Tc/Validity.hs - testsuite/driver/runtests.py - testsuite/tests/cabal/all.T - testsuite/tests/cmm/should_compile/all.T - testsuite/tests/codeGen/should_compile/all.T - testsuite/tests/simplStg/should_compile/all.T - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -199,8 +199,7 @@ joinToTargets_again (return ()) -} delta <- getDeltaR - fixUpInstrs_ <- mapM (handleComponent delta instr) sccs - let fixUpInstrs = concat fixUpInstrs_ + fixUpInstrs <- concatMapM (handleComponent delta instr) sccs -- make a new basic block containing the fixup code. -- A the end of the current block we will jump to the fixup one, ===================================== compiler/GHC/Core/Make.hs ===================================== @@ -6,7 +6,7 @@ module GHC.Core.Make ( mkCoreLet, mkCoreLets, mkCoreApp, mkCoreApps, mkCoreConApps, mkCoreLams, mkWildCase, mkIfThenElse, - mkWildValBinder, mkWildEvBinder, + mkWildValBinder, mkSingleAltCase, sortQuantVars, castBottomExpr, @@ -54,7 +54,7 @@ import GHC.Prelude import GHC.Platform import GHC.Types.Id -import GHC.Types.Var ( EvVar, setTyVarUnique, visArgConstraintLike ) +import GHC.Types.Var ( setTyVarUnique, visArgConstraintLike ) import GHC.Types.TyThing import GHC.Types.Id.Info import GHC.Types.Cpr @@ -173,9 +173,6 @@ mkCoreAppTyped d (fun, fun_ty) arg * * ********************************************************************* -} -mkWildEvBinder :: PredType -> EvVar -mkWildEvBinder pred = mkWildValBinder ManyTy pred - -- | Make a /wildcard binder/. This is typically used when you need a binder -- that you expect to use only at a *binding* site. Do not use it at -- occurrence sites because it has a single, fixed unique, and it's very @@ -1082,8 +1079,9 @@ mkImpossibleExpr :: Type -> String -> CoreExpr mkImpossibleExpr res_ty str = mkRuntimeErrorApp err_id res_ty str where -- See Note [Type vs Constraint for error ids] - err_id | isConstraintLikeKind (typeKind res_ty) = iMPOSSIBLE_CONSTRAINT_ERROR_ID - | otherwise = iMPOSSIBLE_ERROR_ID + err_id = case typeTypeOrConstraint res_ty of + TypeLike -> iMPOSSIBLE_ERROR_ID + ConstraintLike -> iMPOSSIBLE_CONSTRAINT_ERROR_ID {- Note [Type vs Constraint for error ids] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1207,8 +1205,9 @@ mkAbsentErrorApp :: Type -- The type to instantiate 'a' mkAbsentErrorApp res_ty err_msg = mkApps (Var err_id) [ Type res_ty, err_string ] where - err_id | isConstraintLikeKind (typeKind res_ty) = aBSENT_CONSTRAINT_ERROR_ID - | otherwise = aBSENT_ERROR_ID + err_id = case typeTypeOrConstraint res_ty of + TypeLike -> aBSENT_ERROR_ID + ConstraintLike -> aBSENT_CONSTRAINT_ERROR_ID err_string = Lit (mkLitString err_msg) absentErrorName, absentConstraintErrorName :: Name ===================================== compiler/GHC/Core/Opt/WorkWrap.hs ===================================== @@ -68,9 +68,7 @@ info for exported values). wwTopBinds :: WwOpts -> UniqSupply -> CoreProgram -> CoreProgram wwTopBinds ww_opts us top_binds - = initUs_ us $ do - top_binds' <- mapM (wwBind ww_opts) top_binds - return (concat top_binds') + = initUs_ us $ concatMapM (wwBind ww_opts) top_binds {- ************************************************************************ ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -770,7 +770,7 @@ isBoxedRuntimeRep rep = isJust (isBoxedRuntimeRep_maybe rep) -- expands to `Boxed lev` and returns `Nothing` otherwise. -- -- Types with this runtime rep are represented by pointers on the GC'd heap. -isBoxedRuntimeRep_maybe :: RuntimeRepType -> Maybe Type +isBoxedRuntimeRep_maybe :: RuntimeRepType -> Maybe LevityType isBoxedRuntimeRep_maybe rep | Just (rr_tc, args) <- splitRuntimeRep_maybe rep , rr_tc `hasKey` boxedRepDataConKey ===================================== compiler/GHC/HsToCore/Utils.hs ===================================== @@ -81,7 +81,6 @@ import GHC.Types.Tickish import GHC.Utils.Misc import GHC.Driver.Session import GHC.Driver.Ppr -import GHC.Data.FastString import qualified GHC.LanguageExtensions as LangExt import GHC.Tc.Types.Evidence @@ -995,19 +994,10 @@ mkOptTickBox = flip (foldr Tick) mkBinaryTickBox :: Int -> Int -> CoreExpr -> DsM CoreExpr mkBinaryTickBox ixT ixF e = do - uq <- newUnique this_mod <- getModule - let bndr1 = mkSysLocal (fsLit "t1") uq OneTy boolTy - -- It's always sufficient to pattern-match on a boolean with - -- multiplicity 'One'. - let + let trueBox = Tick (HpcTick this_mod ixT) (Var trueDataConId) falseBox = Tick (HpcTick this_mod ixF) (Var falseDataConId) - trueBox = Tick (HpcTick this_mod ixT) (Var trueDataConId) - -- - return $ Case e bndr1 boolTy - [ Alt (DataAlt falseDataCon) [] falseBox - , Alt (DataAlt trueDataCon) [] trueBox - ] + return $ mkIfThenElse e trueBox falseBox ===================================== compiler/GHC/JS/Ppr.hs ===================================== @@ -152,9 +152,9 @@ defRenderJsS r = \case ValExpr (JFunc is b) -> sep [jsToDocR r i <+> text "= function" <> parens (hsep . punctuate comma . map (jsToDocR r) $ is) <> char '{', nest 2 (jsToDocR r b), text "}"] _ -> jsToDocR r i <+> char '=' <+> jsToDocR r x UOpStat op x - | isPre op && isAlphaOp op -> ftext (uOpText op) <+> optParens r x - | isPre op -> ftext (uOpText op) <> optParens r x - | otherwise -> optParens r x <> ftext (uOpText op) + | isPre op && isAlphaOp op -> uOpText op <+> optParens r x + | isPre op -> uOpText op <> optParens r x + | otherwise -> optParens r x <> uOpText op BlockStat xs -> jsToDocR r (flattenBlocks xs) flattenBlocks :: [JStat] -> [JStat] @@ -174,11 +174,11 @@ defRenderJsE r = \case SelExpr x y -> jsToDocR r x <> char '.' <> jsToDocR r y IdxExpr x y -> jsToDocR r x <> brackets (jsToDocR r y) IfExpr x y z -> parens (jsToDocR r x <+> char '?' <+> jsToDocR r y <+> char ':' <+> jsToDocR r z) - InfixExpr op x y -> parens $ hsep [jsToDocR r x, ftext (opText op), jsToDocR r y] + InfixExpr op x y -> parens $ hsep [jsToDocR r x, opText op, jsToDocR r y] UOpExpr op x - | isPre op && isAlphaOp op -> ftext (uOpText op) <+> optParens r x - | isPre op -> ftext (uOpText op) <> optParens r x - | otherwise -> optParens r x <> ftext (uOpText op) + | isPre op && isAlphaOp op -> uOpText op <+> optParens r x + | isPre op -> uOpText op <> optParens r x + | otherwise -> optParens r x <> uOpText op ApplExpr je xs -> jsToDocR r je <> (parens . hsep . punctuate comma $ map (jsToDocR r) xs) UnsatExpr e -> jsToDocR r $ pseudoSaturate e @@ -235,47 +235,47 @@ encodeJsonChar = \case let h = showHex cp "" in text (prefix ++ replicate (pad - length h) '0' ++ h) -uOpText :: JUOp -> FastString +uOpText :: JUOp -> Doc uOpText = \case - NotOp -> "!" - BNotOp -> "~" - NegOp -> "-" - PlusOp -> "+" - NewOp -> "new" - TypeofOp -> "typeof" - DeleteOp -> "delete" - YieldOp -> "yield" - VoidOp -> "void" - PreIncOp -> "++" - PostIncOp -> "++" - PreDecOp -> "--" - PostDecOp -> "--" - -opText :: JOp -> FastString + NotOp -> text "!" + BNotOp -> text "~" + NegOp -> text "-" + PlusOp -> text "+" + NewOp -> text "new" + TypeofOp -> text "typeof" + DeleteOp -> text "delete" + YieldOp -> text "yield" + VoidOp -> text "void" + PreIncOp -> text "++" + PostIncOp -> text "++" + PreDecOp -> text "--" + PostDecOp -> text "--" + +opText :: JOp -> Doc opText = \case - EqOp -> "==" - StrictEqOp -> "===" - NeqOp -> "!=" - StrictNeqOp -> "!==" - GtOp -> ">" - GeOp -> ">=" - LtOp -> "<" - LeOp -> "<=" - AddOp -> "+" - SubOp -> "-" - MulOp -> "*" - DivOp -> "/" - ModOp -> "%" - LeftShiftOp -> "<<" - RightShiftOp -> ">>" - ZRightShiftOp -> ">>>" - BAndOp -> "&" - BOrOp -> "|" - BXorOp -> "^" - LAndOp -> "&&" - LOrOp -> "||" - InstanceofOp -> "instanceof" - InOp -> "in" + EqOp -> text "==" + StrictEqOp -> text "===" + NeqOp -> text "!=" + StrictNeqOp -> text "!==" + GtOp -> text ">" + GeOp -> text ">=" + LtOp -> text "<" + LeOp -> text "<=" + AddOp -> text "+" + SubOp -> text "-" + MulOp -> text "*" + DivOp -> text "/" + ModOp -> text "%" + LeftShiftOp -> text "<<" + RightShiftOp -> text ">>" + ZRightShiftOp -> text ">>>" + BAndOp -> text "&" + BOrOp -> text "|" + BXorOp -> text "^" + LAndOp -> text "&&" + LOrOp -> text "||" + InstanceofOp -> text "instanceof" + InOp -> text "in" isPre :: JUOp -> Bool ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -774,7 +774,8 @@ check_type (ve at ValidityEnv{ ve_tidy_env = env, ve_ctxt = ctxt where (arg_rank, res_rank) = funArgResRank rank -check_type _ ty = pprPanic "check_type" (ppr ty) +check_type _ ty@(ForAllTy {}) = pprPanic "check_type" (ppr ty) +check_type _ ty@(CoercionTy {}) = pprPanic "check_type" (ppr ty) ---------------------------------------- check_syn_tc_app :: ValidityEnv ===================================== testsuite/driver/runtests.py ===================================== @@ -224,7 +224,7 @@ else: h.close() if v != '': # If it does then use the first utf8 locale that is available - h = os.popen('locale -a | grep -i "utf8\|utf-8" 2>/dev/null', 'r') + h = os.popen('locale -a | grep -i "utf8\\|utf-8" 2>/dev/null', 'r') v = h.readline().strip() h.close() if v != '': ===================================== testsuite/tests/cabal/all.T ===================================== @@ -1,5 +1,5 @@ def normaliseDynlibNames(str): - return re.sub('-ghc[0-9.]+\.', '-ghc.', str) + return re.sub('-ghc[0-9.]+\\.', '-ghc.', str) def ignore_warnings(str): return re.sub(r'Warning:.*\n', '', str) ===================================== testsuite/tests/cmm/should_compile/all.T ===================================== @@ -3,7 +3,7 @@ setTestOpts( ]) test('selfloop', [cmm_src], compile, ['-no-hs-main']) -test('cmm_sink_sp', [ only_ways(['optasm']), grep_errmsg('(\[Sp.*\]).*(=).*(\[.*R1.*\]).*;',[1,2,3]), cmm_src], compile, ['-no-hs-main -ddump-cmm -dsuppress-uniques -O']) +test('cmm_sink_sp', [ only_ways(['optasm']), grep_errmsg('(\\[Sp.*\\]).*(=).*(\\[.*R1.*\\]).*;',[1,2,3]), cmm_src], compile, ['-no-hs-main -ddump-cmm -dsuppress-uniques -O']) test('T16930', normal, makefile_test, ['T16930']) test('T17442', normal, compile, ['']) ===================================== testsuite/tests/codeGen/should_compile/all.T ===================================== @@ -75,9 +75,9 @@ test('T14373', [ js_skip # JS backend doesn't produce Cmm ], multimod_compile_filter, ['T14373', '-fasm -O2 -c -ddump-cmm-from-stg', - 'grep -e "const T14373\.._closure+.;"']) + 'grep -e "const T14373\\.._closure+.;"']) -switch_skeleton_only = 'grep -e "switch \[" -e "case " -e "default: " | sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g"' +switch_skeleton_only = 'grep -e "switch \\[" -e "case " -e "default: " | sed -e "s|\\] .*|\\]|g" -e "s|goto .*|goto |g"' test('T14373a', [ js_skip # JS backend doesn't produce Cmm @@ -95,8 +95,8 @@ test('T14373c', multimod_compile_filter, ['T14373c', '-fasm -O2 -c -ddump-cmm-from-stg', switch_skeleton_only]) -switch_skeleton_and_entries_only = ('grep -e "switch \[" -e "case " -e "default: " -e "Default_entry(" -e "R1 = .*_closure+2;"' - '| sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g" -e "s|R1 = .*_closure+2;.*|R1 = XYZ_closure+2;|g" -e "s|//.*|//|g"') +switch_skeleton_and_entries_only = ('grep -e "switch \\[" -e "case " -e "default: " -e "Default_entry(" -e "R1 = .*_closure+2;"' + '| sed -e "s|\\] .*|\\]|g" -e "s|goto .*|goto |g" -e "s|R1 = .*_closure+2;.*|R1 = XYZ_closure+2;|g" -e "s|//.*|//|g"') test('T14373d', [ js_skip # JS backend doesn't produce Cmm ===================================== testsuite/tests/simplStg/should_compile/all.T ===================================== @@ -11,6 +11,6 @@ setTestOpts(f) test('T13588', [ grep_errmsg('case') ] , compile, ['-dverbose-stg2stg -fno-worker-wrapper']) test('T19717', normal, compile, ['-ddump-stg-final -dsuppress-uniques -dno-typeable-binds']) -test('inferTags002', [ only_ways(['optasm']), grep_errmsg('(call stg\_ap\_0)', [1])], compile, ['-ddump-cmm -dsuppress-uniques -dno-typeable-binds -O']) +test('inferTags002', [ only_ways(['optasm']), grep_errmsg('(call stg\\_ap\\_0)', [1])], compile, ['-ddump-cmm -dsuppress-uniques -dno-typeable-binds -O']) test('T22212', normal, compile, ['-O']) ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -23,7 +23,7 @@ test('T13380c', expect_broken('!3014'), compile, ['']) test('T13380f', normal, compile, ['']) test('T18086', normal, compile, ['-package ghc']) test('T18957', normal, compile, ['']) -test('T16197b', [grep_errmsg('\$wf')], compile, ['-ddump-simpl -dsuppress-uniques -dsuppress-all']) +test('T16197b', [grep_errmsg('\\$wf')], compile, ['-ddump-simpl -dsuppress-uniques -dsuppress-all']) test('T19407', normal, compile, ['']) test('T19871', normal, compile, ['']) test('T16859', normal, compile, ['-package ghc']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/585d3ef6c7f48c4c53d2f1ff9632fde1225ade4b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/585d3ef6c7f48c4c53d2f1ff9632fde1225ade4b You're receiving 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 Jan 9 23:43:09 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 09 Jan 2023 18:43:09 -0500 Subject: [Git][ghc/ghc][wip/misc-cleanup4] Misc cleanup Message-ID: <63bca68d84a98_3b1bf9526202430fc@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/misc-cleanup4 at Glasgow Haskell Compiler / GHC Commits: 23a22261 by Krzysztof Gogolewski at 2023-01-10T00:40:11+01:00 Misc cleanup - Use typeTypeOrConstraint - more symmetric and asserts that that the type is Type or Constraint - Use text "foo" in JS, to make sure the rule fires - Fix escape sequences in Python; they raise a deprecation warning with -Wdefault - - - - - 13 changed files: - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Type.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/JS/Ppr.hs - compiler/GHC/Tc/Validity.hs - testsuite/driver/runtests.py - testsuite/tests/cabal/all.T - testsuite/tests/cmm/should_compile/all.T - testsuite/tests/codeGen/should_compile/all.T - testsuite/tests/simplStg/should_compile/all.T - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -199,8 +199,7 @@ joinToTargets_again (return ()) -} delta <- getDeltaR - fixUpInstrs_ <- mapM (handleComponent delta instr) sccs - let fixUpInstrs = concat fixUpInstrs_ + fixUpInstrs <- concatMapM (handleComponent delta instr) sccs -- make a new basic block containing the fixup code. -- A the end of the current block we will jump to the fixup one, ===================================== compiler/GHC/Core/Make.hs ===================================== @@ -6,7 +6,7 @@ module GHC.Core.Make ( mkCoreLet, mkCoreLets, mkCoreApp, mkCoreApps, mkCoreConApps, mkCoreLams, mkWildCase, mkIfThenElse, - mkWildValBinder, mkWildEvBinder, + mkWildValBinder, mkSingleAltCase, sortQuantVars, castBottomExpr, @@ -54,7 +54,7 @@ import GHC.Prelude import GHC.Platform import GHC.Types.Id -import GHC.Types.Var ( EvVar, setTyVarUnique, visArgConstraintLike ) +import GHC.Types.Var ( setTyVarUnique, visArgConstraintLike ) import GHC.Types.TyThing import GHC.Types.Id.Info import GHC.Types.Cpr @@ -173,9 +173,6 @@ mkCoreAppTyped d (fun, fun_ty) arg * * ********************************************************************* -} -mkWildEvBinder :: PredType -> EvVar -mkWildEvBinder pred = mkWildValBinder ManyTy pred - -- | Make a /wildcard binder/. This is typically used when you need a binder -- that you expect to use only at a *binding* site. Do not use it at -- occurrence sites because it has a single, fixed unique, and it's very @@ -1082,8 +1079,9 @@ mkImpossibleExpr :: Type -> String -> CoreExpr mkImpossibleExpr res_ty str = mkRuntimeErrorApp err_id res_ty str where -- See Note [Type vs Constraint for error ids] - err_id | isConstraintLikeKind (typeKind res_ty) = iMPOSSIBLE_CONSTRAINT_ERROR_ID - | otherwise = iMPOSSIBLE_ERROR_ID + err_id = case typeTypeOrConstraint res_ty of + TypeLike -> iMPOSSIBLE_ERROR_ID + ConstraintLike -> iMPOSSIBLE_CONSTRAINT_ERROR_ID {- Note [Type vs Constraint for error ids] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1207,8 +1205,9 @@ mkAbsentErrorApp :: Type -- The type to instantiate 'a' mkAbsentErrorApp res_ty err_msg = mkApps (Var err_id) [ Type res_ty, err_string ] where - err_id | isConstraintLikeKind (typeKind res_ty) = aBSENT_CONSTRAINT_ERROR_ID - | otherwise = aBSENT_ERROR_ID + err_id = case typeTypeOrConstraint res_ty of + TypeLike -> aBSENT_ERROR_ID + ConstraintLike -> aBSENT_CONSTRAINT_ERROR_ID err_string = Lit (mkLitString err_msg) absentErrorName, absentConstraintErrorName :: Name ===================================== compiler/GHC/Core/Opt/WorkWrap.hs ===================================== @@ -68,9 +68,7 @@ info for exported values). wwTopBinds :: WwOpts -> UniqSupply -> CoreProgram -> CoreProgram wwTopBinds ww_opts us top_binds - = initUs_ us $ do - top_binds' <- mapM (wwBind ww_opts) top_binds - return (concat top_binds') + = initUs_ us $ concatMapM (wwBind ww_opts) top_binds {- ************************************************************************ ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -770,7 +770,7 @@ isBoxedRuntimeRep rep = isJust (isBoxedRuntimeRep_maybe rep) -- expands to `Boxed lev` and returns `Nothing` otherwise. -- -- Types with this runtime rep are represented by pointers on the GC'd heap. -isBoxedRuntimeRep_maybe :: RuntimeRepType -> Maybe Type +isBoxedRuntimeRep_maybe :: RuntimeRepType -> Maybe LevityType isBoxedRuntimeRep_maybe rep | Just (rr_tc, args) <- splitRuntimeRep_maybe rep , rr_tc `hasKey` boxedRepDataConKey ===================================== compiler/GHC/HsToCore/Utils.hs ===================================== @@ -81,7 +81,6 @@ import GHC.Types.Tickish import GHC.Utils.Misc import GHC.Driver.Session import GHC.Driver.Ppr -import GHC.Data.FastString import qualified GHC.LanguageExtensions as LangExt import GHC.Tc.Types.Evidence @@ -995,19 +994,10 @@ mkOptTickBox = flip (foldr Tick) mkBinaryTickBox :: Int -> Int -> CoreExpr -> DsM CoreExpr mkBinaryTickBox ixT ixF e = do - uq <- newUnique this_mod <- getModule - let bndr1 = mkSysLocal (fsLit "t1") uq OneTy boolTy - -- It's always sufficient to pattern-match on a boolean with - -- multiplicity 'One'. - let + let trueBox = Tick (HpcTick this_mod ixT) (Var trueDataConId) falseBox = Tick (HpcTick this_mod ixF) (Var falseDataConId) - trueBox = Tick (HpcTick this_mod ixT) (Var trueDataConId) - -- - return $ Case e bndr1 boolTy - [ Alt (DataAlt falseDataCon) [] falseBox - , Alt (DataAlt trueDataCon) [] trueBox - ] + return $ mkIfThenElse e trueBox falseBox ===================================== compiler/GHC/JS/Ppr.hs ===================================== @@ -152,9 +152,9 @@ defRenderJsS r = \case ValExpr (JFunc is b) -> sep [jsToDocR r i <+> text "= function" <> parens (hsep . punctuate comma . map (jsToDocR r) $ is) <> char '{', nest 2 (jsToDocR r b), text "}"] _ -> jsToDocR r i <+> char '=' <+> jsToDocR r x UOpStat op x - | isPre op && isAlphaOp op -> ftext (uOpText op) <+> optParens r x - | isPre op -> ftext (uOpText op) <> optParens r x - | otherwise -> optParens r x <> ftext (uOpText op) + | isPre op && isAlphaOp op -> uOpText op <+> optParens r x + | isPre op -> uOpText op <> optParens r x + | otherwise -> optParens r x <> uOpText op BlockStat xs -> jsToDocR r (flattenBlocks xs) flattenBlocks :: [JStat] -> [JStat] @@ -174,11 +174,11 @@ defRenderJsE r = \case SelExpr x y -> jsToDocR r x <> char '.' <> jsToDocR r y IdxExpr x y -> jsToDocR r x <> brackets (jsToDocR r y) IfExpr x y z -> parens (jsToDocR r x <+> char '?' <+> jsToDocR r y <+> char ':' <+> jsToDocR r z) - InfixExpr op x y -> parens $ hsep [jsToDocR r x, ftext (opText op), jsToDocR r y] + InfixExpr op x y -> parens $ hsep [jsToDocR r x, opText op, jsToDocR r y] UOpExpr op x - | isPre op && isAlphaOp op -> ftext (uOpText op) <+> optParens r x - | isPre op -> ftext (uOpText op) <> optParens r x - | otherwise -> optParens r x <> ftext (uOpText op) + | isPre op && isAlphaOp op -> uOpText op <+> optParens r x + | isPre op -> uOpText op <> optParens r x + | otherwise -> optParens r x <> uOpText op ApplExpr je xs -> jsToDocR r je <> (parens . hsep . punctuate comma $ map (jsToDocR r) xs) UnsatExpr e -> jsToDocR r $ pseudoSaturate e @@ -235,47 +235,47 @@ encodeJsonChar = \case let h = showHex cp "" in text (prefix ++ replicate (pad - length h) '0' ++ h) -uOpText :: JUOp -> FastString +uOpText :: JUOp -> Doc uOpText = \case - NotOp -> "!" - BNotOp -> "~" - NegOp -> "-" - PlusOp -> "+" - NewOp -> "new" - TypeofOp -> "typeof" - DeleteOp -> "delete" - YieldOp -> "yield" - VoidOp -> "void" - PreIncOp -> "++" - PostIncOp -> "++" - PreDecOp -> "--" - PostDecOp -> "--" - -opText :: JOp -> FastString + NotOp -> text "!" + BNotOp -> text "~" + NegOp -> text "-" + PlusOp -> text "+" + NewOp -> text "new" + TypeofOp -> text "typeof" + DeleteOp -> text "delete" + YieldOp -> text "yield" + VoidOp -> text "void" + PreIncOp -> text "++" + PostIncOp -> text "++" + PreDecOp -> text "--" + PostDecOp -> text "--" + +opText :: JOp -> Doc opText = \case - EqOp -> "==" - StrictEqOp -> "===" - NeqOp -> "!=" - StrictNeqOp -> "!==" - GtOp -> ">" - GeOp -> ">=" - LtOp -> "<" - LeOp -> "<=" - AddOp -> "+" - SubOp -> "-" - MulOp -> "*" - DivOp -> "/" - ModOp -> "%" - LeftShiftOp -> "<<" - RightShiftOp -> ">>" - ZRightShiftOp -> ">>>" - BAndOp -> "&" - BOrOp -> "|" - BXorOp -> "^" - LAndOp -> "&&" - LOrOp -> "||" - InstanceofOp -> "instanceof" - InOp -> "in" + EqOp -> text "==" + StrictEqOp -> text "===" + NeqOp -> text "!=" + StrictNeqOp -> text "!==" + GtOp -> text ">" + GeOp -> text ">=" + LtOp -> text "<" + LeOp -> text "<=" + AddOp -> text "+" + SubOp -> text "-" + MulOp -> text "*" + DivOp -> text "/" + ModOp -> text "%" + LeftShiftOp -> text "<<" + RightShiftOp -> text ">>" + ZRightShiftOp -> text ">>>" + BAndOp -> text "&" + BOrOp -> text "|" + BXorOp -> text "^" + LAndOp -> text "&&" + LOrOp -> text "||" + InstanceofOp -> text "instanceof" + InOp -> text "in" isPre :: JUOp -> Bool ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -774,7 +774,8 @@ check_type (ve at ValidityEnv{ ve_tidy_env = env, ve_ctxt = ctxt where (arg_rank, res_rank) = funArgResRank rank -check_type _ ty = pprPanic "check_type" (ppr ty) +check_type _ ty@(ForAllTy {}) = pprPanic "check_type" (ppr ty) +check_type _ ty@(CoercionTy {}) = pprPanic "check_type" (ppr ty) ---------------------------------------- check_syn_tc_app :: ValidityEnv ===================================== testsuite/driver/runtests.py ===================================== @@ -224,7 +224,7 @@ else: h.close() if v != '': # If it does then use the first utf8 locale that is available - h = os.popen('locale -a | grep -i "utf8\|utf-8" 2>/dev/null', 'r') + h = os.popen(r'locale -a | grep -i "utf8\|utf-8" 2>/dev/null', 'r') v = h.readline().strip() h.close() if v != '': ===================================== testsuite/tests/cabal/all.T ===================================== @@ -1,5 +1,5 @@ def normaliseDynlibNames(str): - return re.sub('-ghc[0-9.]+\.', '-ghc.', str) + return re.sub(r'-ghc[0-9.]+\.', '-ghc.', str) def ignore_warnings(str): return re.sub(r'Warning:.*\n', '', str) ===================================== testsuite/tests/cmm/should_compile/all.T ===================================== @@ -3,7 +3,7 @@ setTestOpts( ]) test('selfloop', [cmm_src], compile, ['-no-hs-main']) -test('cmm_sink_sp', [ only_ways(['optasm']), grep_errmsg('(\[Sp.*\]).*(=).*(\[.*R1.*\]).*;',[1,2,3]), cmm_src], compile, ['-no-hs-main -ddump-cmm -dsuppress-uniques -O']) +test('cmm_sink_sp', [ only_ways(['optasm']), grep_errmsg(r'(\[Sp.*\]).*(=).*(\[.*R1.*\]).*;',[1,2,3]), cmm_src], compile, ['-no-hs-main -ddump-cmm -dsuppress-uniques -O']) test('T16930', normal, makefile_test, ['T16930']) test('T17442', normal, compile, ['']) ===================================== testsuite/tests/codeGen/should_compile/all.T ===================================== @@ -75,9 +75,9 @@ test('T14373', [ js_skip # JS backend doesn't produce Cmm ], multimod_compile_filter, ['T14373', '-fasm -O2 -c -ddump-cmm-from-stg', - 'grep -e "const T14373\.._closure+.;"']) + r'grep -e "const T14373\.._closure+.;"']) -switch_skeleton_only = 'grep -e "switch \[" -e "case " -e "default: " | sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g"' +switch_skeleton_only = r'grep -e "switch \[" -e "case " -e "default: " | sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g"' test('T14373a', [ js_skip # JS backend doesn't produce Cmm @@ -95,8 +95,8 @@ test('T14373c', multimod_compile_filter, ['T14373c', '-fasm -O2 -c -ddump-cmm-from-stg', switch_skeleton_only]) -switch_skeleton_and_entries_only = ('grep -e "switch \[" -e "case " -e "default: " -e "Default_entry(" -e "R1 = .*_closure+2;"' - '| sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g" -e "s|R1 = .*_closure+2;.*|R1 = XYZ_closure+2;|g" -e "s|//.*|//|g"') +switch_skeleton_and_entries_only = (r'grep -e "switch \[" -e "case " -e "default: " -e "Default_entry(" -e "R1 = .*_closure+2;"' + '| sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g" -e "s|R1 = .*_closure+2;.*|R1 = XYZ_closure+2;|g" -e "s|//.*|//|g"') test('T14373d', [ js_skip # JS backend doesn't produce Cmm ===================================== testsuite/tests/simplStg/should_compile/all.T ===================================== @@ -11,6 +11,6 @@ setTestOpts(f) test('T13588', [ grep_errmsg('case') ] , compile, ['-dverbose-stg2stg -fno-worker-wrapper']) test('T19717', normal, compile, ['-ddump-stg-final -dsuppress-uniques -dno-typeable-binds']) -test('inferTags002', [ only_ways(['optasm']), grep_errmsg('(call stg\_ap\_0)', [1])], compile, ['-ddump-cmm -dsuppress-uniques -dno-typeable-binds -O']) +test('inferTags002', [ only_ways(['optasm']), grep_errmsg(r'(call stg\_ap\_0)', [1])], compile, ['-ddump-cmm -dsuppress-uniques -dno-typeable-binds -O']) test('T22212', normal, compile, ['-O']) ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -23,7 +23,7 @@ test('T13380c', expect_broken('!3014'), compile, ['']) test('T13380f', normal, compile, ['']) test('T18086', normal, compile, ['-package ghc']) test('T18957', normal, compile, ['']) -test('T16197b', [grep_errmsg('\$wf')], compile, ['-ddump-simpl -dsuppress-uniques -dsuppress-all']) +test('T16197b', [grep_errmsg(r'\$wf')], compile, ['-ddump-simpl -dsuppress-uniques -dsuppress-all']) test('T19407', normal, compile, ['']) test('T19871', normal, compile, ['']) test('T16859', normal, compile, ['-package ghc']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/23a222619915823acfab1d0295f6cb8a8f42919b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/23a222619915823acfab1d0295f6cb8a8f42919b You're receiving 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 Jan 9 23:44:21 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 09 Jan 2023 18:44:21 -0500 Subject: [Git][ghc/ghc][wip/misc-cleanup4] Misc cleanup Message-ID: <63bca6d587dde_3b1bf952620245190@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/misc-cleanup4 at Glasgow Haskell Compiler / GHC Commits: 327cd746 by Krzysztof Gogolewski at 2023-01-10T00:43:51+01:00 Misc cleanup - Remove unused mkWildEvBinder - Use typeTypeOrConstraint - more symmetric and asserts that that the type is Type or Constraint - Use text "foo" in JS, to make sure the rule fires - Fix escape sequences in Python; they raise a deprecation warning with -Wdefault - - - - - 13 changed files: - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Type.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/JS/Ppr.hs - compiler/GHC/Tc/Validity.hs - testsuite/driver/runtests.py - testsuite/tests/cabal/all.T - testsuite/tests/cmm/should_compile/all.T - testsuite/tests/codeGen/should_compile/all.T - testsuite/tests/simplStg/should_compile/all.T - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -199,8 +199,7 @@ joinToTargets_again (return ()) -} delta <- getDeltaR - fixUpInstrs_ <- mapM (handleComponent delta instr) sccs - let fixUpInstrs = concat fixUpInstrs_ + fixUpInstrs <- concatMapM (handleComponent delta instr) sccs -- make a new basic block containing the fixup code. -- A the end of the current block we will jump to the fixup one, ===================================== compiler/GHC/Core/Make.hs ===================================== @@ -6,7 +6,7 @@ module GHC.Core.Make ( mkCoreLet, mkCoreLets, mkCoreApp, mkCoreApps, mkCoreConApps, mkCoreLams, mkWildCase, mkIfThenElse, - mkWildValBinder, mkWildEvBinder, + mkWildValBinder, mkSingleAltCase, sortQuantVars, castBottomExpr, @@ -54,7 +54,7 @@ import GHC.Prelude import GHC.Platform import GHC.Types.Id -import GHC.Types.Var ( EvVar, setTyVarUnique, visArgConstraintLike ) +import GHC.Types.Var ( setTyVarUnique, visArgConstraintLike ) import GHC.Types.TyThing import GHC.Types.Id.Info import GHC.Types.Cpr @@ -173,9 +173,6 @@ mkCoreAppTyped d (fun, fun_ty) arg * * ********************************************************************* -} -mkWildEvBinder :: PredType -> EvVar -mkWildEvBinder pred = mkWildValBinder ManyTy pred - -- | Make a /wildcard binder/. This is typically used when you need a binder -- that you expect to use only at a *binding* site. Do not use it at -- occurrence sites because it has a single, fixed unique, and it's very @@ -1082,8 +1079,9 @@ mkImpossibleExpr :: Type -> String -> CoreExpr mkImpossibleExpr res_ty str = mkRuntimeErrorApp err_id res_ty str where -- See Note [Type vs Constraint for error ids] - err_id | isConstraintLikeKind (typeKind res_ty) = iMPOSSIBLE_CONSTRAINT_ERROR_ID - | otherwise = iMPOSSIBLE_ERROR_ID + err_id = case typeTypeOrConstraint res_ty of + TypeLike -> iMPOSSIBLE_ERROR_ID + ConstraintLike -> iMPOSSIBLE_CONSTRAINT_ERROR_ID {- Note [Type vs Constraint for error ids] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1207,8 +1205,9 @@ mkAbsentErrorApp :: Type -- The type to instantiate 'a' mkAbsentErrorApp res_ty err_msg = mkApps (Var err_id) [ Type res_ty, err_string ] where - err_id | isConstraintLikeKind (typeKind res_ty) = aBSENT_CONSTRAINT_ERROR_ID - | otherwise = aBSENT_ERROR_ID + err_id = case typeTypeOrConstraint res_ty of + TypeLike -> aBSENT_ERROR_ID + ConstraintLike -> aBSENT_CONSTRAINT_ERROR_ID err_string = Lit (mkLitString err_msg) absentErrorName, absentConstraintErrorName :: Name ===================================== compiler/GHC/Core/Opt/WorkWrap.hs ===================================== @@ -68,9 +68,7 @@ info for exported values). wwTopBinds :: WwOpts -> UniqSupply -> CoreProgram -> CoreProgram wwTopBinds ww_opts us top_binds - = initUs_ us $ do - top_binds' <- mapM (wwBind ww_opts) top_binds - return (concat top_binds') + = initUs_ us $ concatMapM (wwBind ww_opts) top_binds {- ************************************************************************ ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -770,7 +770,7 @@ isBoxedRuntimeRep rep = isJust (isBoxedRuntimeRep_maybe rep) -- expands to `Boxed lev` and returns `Nothing` otherwise. -- -- Types with this runtime rep are represented by pointers on the GC'd heap. -isBoxedRuntimeRep_maybe :: RuntimeRepType -> Maybe Type +isBoxedRuntimeRep_maybe :: RuntimeRepType -> Maybe LevityType isBoxedRuntimeRep_maybe rep | Just (rr_tc, args) <- splitRuntimeRep_maybe rep , rr_tc `hasKey` boxedRepDataConKey ===================================== compiler/GHC/HsToCore/Utils.hs ===================================== @@ -81,7 +81,6 @@ import GHC.Types.Tickish import GHC.Utils.Misc import GHC.Driver.Session import GHC.Driver.Ppr -import GHC.Data.FastString import qualified GHC.LanguageExtensions as LangExt import GHC.Tc.Types.Evidence @@ -995,19 +994,10 @@ mkOptTickBox = flip (foldr Tick) mkBinaryTickBox :: Int -> Int -> CoreExpr -> DsM CoreExpr mkBinaryTickBox ixT ixF e = do - uq <- newUnique this_mod <- getModule - let bndr1 = mkSysLocal (fsLit "t1") uq OneTy boolTy - -- It's always sufficient to pattern-match on a boolean with - -- multiplicity 'One'. - let + let trueBox = Tick (HpcTick this_mod ixT) (Var trueDataConId) falseBox = Tick (HpcTick this_mod ixF) (Var falseDataConId) - trueBox = Tick (HpcTick this_mod ixT) (Var trueDataConId) - -- - return $ Case e bndr1 boolTy - [ Alt (DataAlt falseDataCon) [] falseBox - , Alt (DataAlt trueDataCon) [] trueBox - ] + return $ mkIfThenElse e trueBox falseBox ===================================== compiler/GHC/JS/Ppr.hs ===================================== @@ -152,9 +152,9 @@ defRenderJsS r = \case ValExpr (JFunc is b) -> sep [jsToDocR r i <+> text "= function" <> parens (hsep . punctuate comma . map (jsToDocR r) $ is) <> char '{', nest 2 (jsToDocR r b), text "}"] _ -> jsToDocR r i <+> char '=' <+> jsToDocR r x UOpStat op x - | isPre op && isAlphaOp op -> ftext (uOpText op) <+> optParens r x - | isPre op -> ftext (uOpText op) <> optParens r x - | otherwise -> optParens r x <> ftext (uOpText op) + | isPre op && isAlphaOp op -> uOpText op <+> optParens r x + | isPre op -> uOpText op <> optParens r x + | otherwise -> optParens r x <> uOpText op BlockStat xs -> jsToDocR r (flattenBlocks xs) flattenBlocks :: [JStat] -> [JStat] @@ -174,11 +174,11 @@ defRenderJsE r = \case SelExpr x y -> jsToDocR r x <> char '.' <> jsToDocR r y IdxExpr x y -> jsToDocR r x <> brackets (jsToDocR r y) IfExpr x y z -> parens (jsToDocR r x <+> char '?' <+> jsToDocR r y <+> char ':' <+> jsToDocR r z) - InfixExpr op x y -> parens $ hsep [jsToDocR r x, ftext (opText op), jsToDocR r y] + InfixExpr op x y -> parens $ hsep [jsToDocR r x, opText op, jsToDocR r y] UOpExpr op x - | isPre op && isAlphaOp op -> ftext (uOpText op) <+> optParens r x - | isPre op -> ftext (uOpText op) <> optParens r x - | otherwise -> optParens r x <> ftext (uOpText op) + | isPre op && isAlphaOp op -> uOpText op <+> optParens r x + | isPre op -> uOpText op <> optParens r x + | otherwise -> optParens r x <> uOpText op ApplExpr je xs -> jsToDocR r je <> (parens . hsep . punctuate comma $ map (jsToDocR r) xs) UnsatExpr e -> jsToDocR r $ pseudoSaturate e @@ -235,47 +235,47 @@ encodeJsonChar = \case let h = showHex cp "" in text (prefix ++ replicate (pad - length h) '0' ++ h) -uOpText :: JUOp -> FastString +uOpText :: JUOp -> Doc uOpText = \case - NotOp -> "!" - BNotOp -> "~" - NegOp -> "-" - PlusOp -> "+" - NewOp -> "new" - TypeofOp -> "typeof" - DeleteOp -> "delete" - YieldOp -> "yield" - VoidOp -> "void" - PreIncOp -> "++" - PostIncOp -> "++" - PreDecOp -> "--" - PostDecOp -> "--" - -opText :: JOp -> FastString + NotOp -> text "!" + BNotOp -> text "~" + NegOp -> text "-" + PlusOp -> text "+" + NewOp -> text "new" + TypeofOp -> text "typeof" + DeleteOp -> text "delete" + YieldOp -> text "yield" + VoidOp -> text "void" + PreIncOp -> text "++" + PostIncOp -> text "++" + PreDecOp -> text "--" + PostDecOp -> text "--" + +opText :: JOp -> Doc opText = \case - EqOp -> "==" - StrictEqOp -> "===" - NeqOp -> "!=" - StrictNeqOp -> "!==" - GtOp -> ">" - GeOp -> ">=" - LtOp -> "<" - LeOp -> "<=" - AddOp -> "+" - SubOp -> "-" - MulOp -> "*" - DivOp -> "/" - ModOp -> "%" - LeftShiftOp -> "<<" - RightShiftOp -> ">>" - ZRightShiftOp -> ">>>" - BAndOp -> "&" - BOrOp -> "|" - BXorOp -> "^" - LAndOp -> "&&" - LOrOp -> "||" - InstanceofOp -> "instanceof" - InOp -> "in" + EqOp -> text "==" + StrictEqOp -> text "===" + NeqOp -> text "!=" + StrictNeqOp -> text "!==" + GtOp -> text ">" + GeOp -> text ">=" + LtOp -> text "<" + LeOp -> text "<=" + AddOp -> text "+" + SubOp -> text "-" + MulOp -> text "*" + DivOp -> text "/" + ModOp -> text "%" + LeftShiftOp -> text "<<" + RightShiftOp -> text ">>" + ZRightShiftOp -> text ">>>" + BAndOp -> text "&" + BOrOp -> text "|" + BXorOp -> text "^" + LAndOp -> text "&&" + LOrOp -> text "||" + InstanceofOp -> text "instanceof" + InOp -> text "in" isPre :: JUOp -> Bool ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -774,7 +774,8 @@ check_type (ve at ValidityEnv{ ve_tidy_env = env, ve_ctxt = ctxt where (arg_rank, res_rank) = funArgResRank rank -check_type _ ty = pprPanic "check_type" (ppr ty) +check_type _ ty@(ForAllTy {}) = pprPanic "check_type" (ppr ty) +check_type _ ty@(CoercionTy {}) = pprPanic "check_type" (ppr ty) ---------------------------------------- check_syn_tc_app :: ValidityEnv ===================================== testsuite/driver/runtests.py ===================================== @@ -224,7 +224,7 @@ else: h.close() if v != '': # If it does then use the first utf8 locale that is available - h = os.popen('locale -a | grep -i "utf8\|utf-8" 2>/dev/null', 'r') + h = os.popen(r'locale -a | grep -i "utf8\|utf-8" 2>/dev/null', 'r') v = h.readline().strip() h.close() if v != '': ===================================== testsuite/tests/cabal/all.T ===================================== @@ -1,5 +1,5 @@ def normaliseDynlibNames(str): - return re.sub('-ghc[0-9.]+\.', '-ghc.', str) + return re.sub(r'-ghc[0-9.]+\.', '-ghc.', str) def ignore_warnings(str): return re.sub(r'Warning:.*\n', '', str) ===================================== testsuite/tests/cmm/should_compile/all.T ===================================== @@ -3,7 +3,7 @@ setTestOpts( ]) test('selfloop', [cmm_src], compile, ['-no-hs-main']) -test('cmm_sink_sp', [ only_ways(['optasm']), grep_errmsg('(\[Sp.*\]).*(=).*(\[.*R1.*\]).*;',[1,2,3]), cmm_src], compile, ['-no-hs-main -ddump-cmm -dsuppress-uniques -O']) +test('cmm_sink_sp', [ only_ways(['optasm']), grep_errmsg(r'(\[Sp.*\]).*(=).*(\[.*R1.*\]).*;',[1,2,3]), cmm_src], compile, ['-no-hs-main -ddump-cmm -dsuppress-uniques -O']) test('T16930', normal, makefile_test, ['T16930']) test('T17442', normal, compile, ['']) ===================================== testsuite/tests/codeGen/should_compile/all.T ===================================== @@ -75,9 +75,9 @@ test('T14373', [ js_skip # JS backend doesn't produce Cmm ], multimod_compile_filter, ['T14373', '-fasm -O2 -c -ddump-cmm-from-stg', - 'grep -e "const T14373\.._closure+.;"']) + r'grep -e "const T14373\.._closure+.;"']) -switch_skeleton_only = 'grep -e "switch \[" -e "case " -e "default: " | sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g"' +switch_skeleton_only = r'grep -e "switch \[" -e "case " -e "default: " | sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g"' test('T14373a', [ js_skip # JS backend doesn't produce Cmm @@ -95,8 +95,8 @@ test('T14373c', multimod_compile_filter, ['T14373c', '-fasm -O2 -c -ddump-cmm-from-stg', switch_skeleton_only]) -switch_skeleton_and_entries_only = ('grep -e "switch \[" -e "case " -e "default: " -e "Default_entry(" -e "R1 = .*_closure+2;"' - '| sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g" -e "s|R1 = .*_closure+2;.*|R1 = XYZ_closure+2;|g" -e "s|//.*|//|g"') +switch_skeleton_and_entries_only = (r'grep -e "switch \[" -e "case " -e "default: " -e "Default_entry(" -e "R1 = .*_closure+2;"' + '| sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g" -e "s|R1 = .*_closure+2;.*|R1 = XYZ_closure+2;|g" -e "s|//.*|//|g"') test('T14373d', [ js_skip # JS backend doesn't produce Cmm ===================================== testsuite/tests/simplStg/should_compile/all.T ===================================== @@ -11,6 +11,6 @@ setTestOpts(f) test('T13588', [ grep_errmsg('case') ] , compile, ['-dverbose-stg2stg -fno-worker-wrapper']) test('T19717', normal, compile, ['-ddump-stg-final -dsuppress-uniques -dno-typeable-binds']) -test('inferTags002', [ only_ways(['optasm']), grep_errmsg('(call stg\_ap\_0)', [1])], compile, ['-ddump-cmm -dsuppress-uniques -dno-typeable-binds -O']) +test('inferTags002', [ only_ways(['optasm']), grep_errmsg(r'(call stg\_ap\_0)', [1])], compile, ['-ddump-cmm -dsuppress-uniques -dno-typeable-binds -O']) test('T22212', normal, compile, ['-O']) ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -23,7 +23,7 @@ test('T13380c', expect_broken('!3014'), compile, ['']) test('T13380f', normal, compile, ['']) test('T18086', normal, compile, ['-package ghc']) test('T18957', normal, compile, ['']) -test('T16197b', [grep_errmsg('\$wf')], compile, ['-ddump-simpl -dsuppress-uniques -dsuppress-all']) +test('T16197b', [grep_errmsg(r'\$wf')], compile, ['-ddump-simpl -dsuppress-uniques -dsuppress-all']) test('T19407', normal, compile, ['']) test('T19871', normal, compile, ['']) test('T16859', normal, compile, ['-package ghc']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/327cd74684f6b1d70aa2e4c54f09e4a9d789962f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/327cd74684f6b1d70aa2e4c54f09e4a9d789962f You're receiving 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 Jan 10 01:39:44 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 09 Jan 2023 20:39:44 -0500 Subject: [Git][ghc/ghc][master] Remove RTS hack for configuring Message-ID: <63bcc1e097978_3b1bf95632429362d@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 5d65773e by John Ericson at 2023-01-09T20:39:27-05:00 Remove RTS hack for configuring See the brand new Note [Undefined symbols in the RTS] for additional details. - - - - - 3 changed files: - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Rules/Register.hs - rts/rts.cabal.in Changes: ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -148,6 +148,8 @@ configurePackage context at Context {..} = do -- Figure out what hooks we need. hooks <- case C.buildType (C.flattenPackageDescription gpd) of C.Configure -> pure C.autoconfUserHooks + C.Simple -> pure C.simpleUserHooks + C.Make -> fail "build-type: Make is not supported" -- The 'time' package has a 'C.Custom' Setup.hs, but it's actually -- 'C.Configure' plus a @./Setup test@ hook. However, Cabal is also -- 'C.Custom', but doesn't have a configure script. @@ -155,12 +157,6 @@ configurePackage context at Context {..} = do configureExists <- doesFileExist $ replaceFileName (pkgCabalFile package) "configure" pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks - -- Not quite right, but good enough for us: - _ | package == rts -> - -- Don't try to do post configuration validation for 'rts'. This - -- will simply not work, due to the @ld-options@ and @Stg.h at . - pure $ C.simpleUserHooks { C.postConf = \_ _ _ _ -> return () } - | otherwise -> pure C.simpleUserHooks -- Compute the list of flags, and the Cabal configuration arguments flavourArgs <- args <$> flavour ===================================== hadrian/src/Rules/Register.hs ===================================== @@ -45,6 +45,14 @@ configurePackageRules = do isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend when isGmp $ need [buildP -/- "include/ghc-gmp.h"] + when (pkg == rts) $ do + -- Rts.h is a header listed in the cabal file, and configuring + -- therefore wants to ensure that the header "works" post-configure. + -- But it (transitively) includes these, so we must ensure they exist + -- for that check to work. + need [ buildP -/- "include/ghcautoconf.h" + , buildP -/- "include/ghcplatform.h" + ] Cabal.configurePackage ctx root -/- "**/autogen/cabal_macros.h" %> \out -> do ===================================== rts/rts.cabal.in ===================================== @@ -275,6 +275,8 @@ library stg/SMP.h stg/Ticky.h stg/Types.h + + -- See Note [Undefined symbols in the RTS] if flag(64bit) if flag(leading-underscore) ld-options: @@ -474,6 +476,8 @@ library ld-options: "-Wl,-search_paths_first" -- See Note [fd_set_overflow] "-Wl,-U,___darwin_check_fd_set_overflow" + -- See Note [Undefined symbols in the RTS] + "-Wl,-undefined,dynamic_lookup" if !arch(x86_64) && !arch(aarch64) ld-options: -read_only_relocs warning @@ -714,3 +718,35 @@ library -- , https://github.com/sitsofe/fio/commit/b6a1e63a1ff607692a3caf3c2db2c3d575ba2320 -- The issue was originally reported in #19950 + + +-- Note [Undefined symbols in the RTS] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- The RTS is built with a number of `-u` flags. This is to handle cyclic +-- dependencies between the RTS and other libraries which we normally think of as +-- downstream from the RTS. "Regular" dependencies from usages in those libraries +-- to definitions in the RTS are handled normally. "Reverse" dependencies from +-- usages in the RTS to definitions in those libraries get the `-u` flag in the +-- RTS. +-- +-- The symbols are specified literally, but follow C ABI conventions (as all 3 of +-- C, C--, and Haskell do currently). Thus, we have to be careful to include a +-- leading underscore or not based on those conventions for the given platform in +-- question. +-- +-- A tricky part is that different linkers have different policies regarding +-- undefined symbols (not defined in the current binary, or found in a shared +-- library that could be loaded at run time). GNU Binutils' linker is fine with +-- undefined symbols by default, but Apple's "cctools" linker is not. To appease +-- that linker we either need to do a blanket `-undefined dynamic_lookup` or +-- whitelist each such symbol with an additional `-U` (see the man page for more +-- details). +-- +-- GHC already does `-undefined dynamic_lookup`, so we just do that for now, but +-- we might try to get more precise with `-U` in the future. +-- +-- Note that the RTS also `-u`s some atomics symbols that *are* defined --- and +-- defined within the RTS! It is not immediately clear why this is needed. This +-- dates back to c06e3f46d24ef69f3a3d794f5f604cb8c2a40cbc which mentions a build +-- failure that it was suggested that this fix, but the precise reasoning is not +-- explained. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5d65773eb6bbac76247f97f385772fe366889085 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5d65773eb6bbac76247f97f385772fe366889085 You're receiving 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 Jan 10 01:40:23 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 09 Jan 2023 20:40:23 -0500 Subject: [Git][ghc/ghc][master] Handle shadowing in DmdAnal (#22718) Message-ID: <63bcc2075e3c0_3b1bf95264829906f@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e3fff751 by Sebastian Graf at 2023-01-09T20:40:02-05:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - 1 changed file: - compiler/GHC/Core/Opt/DmdAnal.hs Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -333,7 +333,8 @@ dmdAnalBindLetUp :: TopLevelFlag -> WithDmdType (DmdResult CoreBind a) dmdAnalBindLetUp top_lvl env id rhs anal_body = WithDmdType final_ty (R (NonRec id' rhs') (body')) where - WithDmdType body_ty body' = anal_body env + WithDmdType body_ty body' = anal_body (addInScopeAnalEnv env id) + -- See Note [Bringing a new variable into scope] WithDmdType body_ty' id_dmd = findBndrDmd env body_ty id -- See Note [Finalising boxity for demand signatures] @@ -473,7 +474,8 @@ dmdAnal' env dmd (App fun arg) dmdAnal' env dmd (Lam var body) | isTyVar var = let - WithDmdType body_ty body' = dmdAnal env dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) dmd body + -- See Note [Bringing a new variable into scope] in WithDmdType body_ty (Lam var body') @@ -481,7 +483,8 @@ dmdAnal' env dmd (Lam var body) = let (n, body_dmd) = peelCallDmd dmd -- body_dmd: a demand to analyze the body - WithDmdType body_ty body' = dmdAnal env body_dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) body_dmd body + -- See Note [Bringing a new variable into scope] WithDmdType lam_ty var' = annotateLamIdBndr env body_ty var new_dmd_type = multDmdType n lam_ty in @@ -493,7 +496,9 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt_con bndrs rhs]) -- can consider its field demands when analysing the scrutinee. | want_precise_field_dmds alt_con = let - WithDmdType rhs_ty rhs' = dmdAnal env dmd rhs + rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + WithDmdType rhs_ty rhs' = dmdAnal rhs_env dmd rhs WithDmdType alt_ty1 fld_dmds = findBndrsDmds env rhs_ty bndrs WithDmdType alt_ty2 case_bndr_dmd = findBndrDmd env alt_ty1 case_bndr !case_bndr' = setIdDemandInfo case_bndr case_bndr_dmd @@ -629,7 +634,9 @@ dmdAnalSumAlts env dmd case_bndr (alt:alts) dmdAnalSumAlt :: AnalEnv -> SubDemand -> Id -> CoreAlt -> WithDmdType CoreAlt dmdAnalSumAlt env dmd case_bndr (Alt con bndrs rhs) - | WithDmdType rhs_ty rhs' <- dmdAnal env dmd rhs + | let rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + , WithDmdType rhs_ty rhs' <- dmdAnal rhs_env dmd rhs , WithDmdType alt_ty dmds <- findBndrsDmds env rhs_ty bndrs , let (_ :* case_bndr_sd) = findIdDemand alt_ty case_bndr -- See Note [Demand on case-alternative binders] @@ -2399,7 +2406,7 @@ enterDFun bind env emptySigEnv :: SigEnv emptySigEnv = emptyVarEnv --- | Extend an environment with the strictness IDs attached to the id +-- | Extend an environment with the strictness sigs attached to the Ids extendAnalEnvs :: TopLevelFlag -> AnalEnv -> [Id] -> AnalEnv extendAnalEnvs top_lvl env vars = env { ae_sigs = extendSigEnvs top_lvl (ae_sigs env) vars } @@ -2418,6 +2425,12 @@ extendSigEnv top_lvl sigs var sig = extendVarEnv sigs var (sig, top_lvl) lookupSigEnv :: AnalEnv -> Id -> Maybe (DmdSig, TopLevelFlag) lookupSigEnv env id = lookupVarEnv (ae_sigs env) id +addInScopeAnalEnv :: AnalEnv -> Var -> AnalEnv +addInScopeAnalEnv env id = env { ae_sigs = delVarEnv (ae_sigs env) id } + +addInScopeAnalEnvs :: AnalEnv -> [Var] -> AnalEnv +addInScopeAnalEnvs env ids = env { ae_sigs = delVarEnvList (ae_sigs env) ids } + nonVirgin :: AnalEnv -> AnalEnv nonVirgin env = env { ae_virgin = False } @@ -2456,7 +2469,18 @@ findBndrDmd env dmd_ty id fam_envs = ae_fam_envs env -{- Note [Making dictionary parameters strict] +{- Note [Bringing a new variable into scope] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + f x = blah + g = ...(\f. ...f...)... + +In the body of the '\f', any occurrence of `f` refers to the lambda-bound `f`, +not the top-level `f` (which will be in `ae_sigs`). So it's very important +to delete `f` from `ae_sigs` when we pass a lambda/case/let-up binding of `f`. +Otherwise chaos results (#22718). + +Note [Making dictionary parameters strict] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e3fff7512bbf989386faaa1dccafdad1deabde84 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e3fff7512bbf989386faaa1dccafdad1deabde84 You're receiving 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 Jan 10 02:11:24 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 09 Jan 2023 21:11:24 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: Remove RTS hack for configuring Message-ID: <63bcc94c2a547_3b1bf95632430292f@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 5d65773e by John Ericson at 2023-01-09T20:39:27-05:00 Remove RTS hack for configuring See the brand new Note [Undefined symbols in the RTS] for additional details. - - - - - e3fff751 by Sebastian Graf at 2023-01-09T20:40:02-05:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - d53f6f4d by Oleg Grenrus at 2023-01-09T21:11:02-05:00 Add safe list indexing operator: !? With Joachim's amendments. Implements https://github.com/haskell/core-libraries-committee/issues/110 - - - - - cfaf1ad7 by Nicolas Trangez at 2023-01-09T21:11:03-05:00 rts, tests: limit thread name length to 15 bytes On Linux, `pthread_setname_np` (or rather, the kernel) only allows for thread names up to 16 bytes, including the terminating null byte. This commit adds a note pointing this out in `createOSThread`, and fixes up two instances where a thread name of more than 15 characters long was used (in the RTS, and in a test-case). Fixes: #22366 Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796 - - - - - 64286132 by Matthew Pickering at 2023-01-09T21:11:03-05:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 4724e8d1 by Matthew Pickering at 2023-01-09T21:11:04-05:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. This completes the fix for #22429 - - - - - 2e926b88 by Georgi Lyubenov at 2023-01-09T21:11:07-05:00 Fix outdated link to Happy section on sequences - - - - - 146a1458 by Matthew Pickering at 2023-01-09T21:11:07-05:00 Revert "NCG(x86): Compile add+shift as lea if possible." This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a. See #22666 and #21777 - - - - - 19 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Parser.y - configure.ac - distrib/configure.ac.in - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Rules/Register.hs - libraries/base/Data/List.hs - libraries/base/Data/OldList.hs - libraries/base/GHC/List.hs - libraries/base/changelog.md - m4/ghc_llvm_target.m4 - rts/posix/OSThreads.c - rts/rts.cabal.in - rts/sm/NonMoving.c - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.asm - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.hs - testsuite/tests/codeGen/should_gen_asm/all.T - testsuite/tests/rts/pause-resume/pause_resume.c Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -1048,29 +1048,10 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps -------------------- add_code :: Width -> CmmExpr -> CmmExpr -> NatM Register - -- x + imm add_code rep x (CmmLit (CmmInt y _)) | is32BitInteger y , rep /= W8 -- LEA doesn't support byte size (#18614) = add_int rep x y - -- x + (y << imm) - add_code rep x y - -- Byte size is not supported and 16bit size is slow when computed via LEA - | rep /= W8 && rep /= W16 - -- 2^3 = 8 is the highest multiplicator supported by LEA. - , Just (x,y,shift_bits) <- get_shift x y - = add_shiftL rep x y (fromIntegral shift_bits) - where - -- x + (y << imm) - get_shift x (CmmMachOp (MO_Shl _w) [y, CmmLit (CmmInt shift_bits _)]) - | shift_bits <= 3 - = Just (x, y, shift_bits) - -- (y << imm) + x - get_shift (CmmMachOp (MO_Shl _w) [y, CmmLit (CmmInt shift_bits _)]) x - | shift_bits <= 3 - = Just (x, y, shift_bits) - get_shift _ _ - = Nothing add_code rep x y = trivialCode rep (ADD format) (Just (ADD format)) x y where format = intFormat rep -- TODO: There are other interesting patterns we want to replace @@ -1085,7 +1066,6 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps sub_code rep x y = trivialCode rep (SUB (intFormat rep)) Nothing x y -- our three-operand add instruction: - add_int :: (Width -> CmmExpr -> Integer -> NatM Register) add_int width x y = do (x_reg, x_code) <- getSomeReg x let @@ -1099,22 +1079,6 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps -- return (Any format code) - -- x + (y << shift_bits) using LEA - add_shiftL :: (Width -> CmmExpr -> CmmExpr -> Int -> NatM Register) - add_shiftL width x y shift_bits = do - (x_reg, x_code) <- getSomeReg x - (y_reg, y_code) <- getSomeReg y - let - format = intFormat width - imm = ImmInt 0 - code dst - = (x_code `appOL` y_code) `snocOL` - LEA format - (OpAddr (AddrBaseIndex (EABaseReg x_reg) (EAIndex y_reg (2 ^ shift_bits)) imm)) - (OpReg dst) - -- - return (Any format code) - ---------------------- -- See Note [DIV/IDIV for bytes] ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -333,7 +333,8 @@ dmdAnalBindLetUp :: TopLevelFlag -> WithDmdType (DmdResult CoreBind a) dmdAnalBindLetUp top_lvl env id rhs anal_body = WithDmdType final_ty (R (NonRec id' rhs') (body')) where - WithDmdType body_ty body' = anal_body env + WithDmdType body_ty body' = anal_body (addInScopeAnalEnv env id) + -- See Note [Bringing a new variable into scope] WithDmdType body_ty' id_dmd = findBndrDmd env body_ty id -- See Note [Finalising boxity for demand signatures] @@ -473,7 +474,8 @@ dmdAnal' env dmd (App fun arg) dmdAnal' env dmd (Lam var body) | isTyVar var = let - WithDmdType body_ty body' = dmdAnal env dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) dmd body + -- See Note [Bringing a new variable into scope] in WithDmdType body_ty (Lam var body') @@ -481,7 +483,8 @@ dmdAnal' env dmd (Lam var body) = let (n, body_dmd) = peelCallDmd dmd -- body_dmd: a demand to analyze the body - WithDmdType body_ty body' = dmdAnal env body_dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) body_dmd body + -- See Note [Bringing a new variable into scope] WithDmdType lam_ty var' = annotateLamIdBndr env body_ty var new_dmd_type = multDmdType n lam_ty in @@ -493,7 +496,9 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt_con bndrs rhs]) -- can consider its field demands when analysing the scrutinee. | want_precise_field_dmds alt_con = let - WithDmdType rhs_ty rhs' = dmdAnal env dmd rhs + rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + WithDmdType rhs_ty rhs' = dmdAnal rhs_env dmd rhs WithDmdType alt_ty1 fld_dmds = findBndrsDmds env rhs_ty bndrs WithDmdType alt_ty2 case_bndr_dmd = findBndrDmd env alt_ty1 case_bndr !case_bndr' = setIdDemandInfo case_bndr case_bndr_dmd @@ -629,7 +634,9 @@ dmdAnalSumAlts env dmd case_bndr (alt:alts) dmdAnalSumAlt :: AnalEnv -> SubDemand -> Id -> CoreAlt -> WithDmdType CoreAlt dmdAnalSumAlt env dmd case_bndr (Alt con bndrs rhs) - | WithDmdType rhs_ty rhs' <- dmdAnal env dmd rhs + | let rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + , WithDmdType rhs_ty rhs' <- dmdAnal rhs_env dmd rhs , WithDmdType alt_ty dmds <- findBndrsDmds env rhs_ty bndrs , let (_ :* case_bndr_sd) = findIdDemand alt_ty case_bndr -- See Note [Demand on case-alternative binders] @@ -2399,7 +2406,7 @@ enterDFun bind env emptySigEnv :: SigEnv emptySigEnv = emptyVarEnv --- | Extend an environment with the strictness IDs attached to the id +-- | Extend an environment with the strictness sigs attached to the Ids extendAnalEnvs :: TopLevelFlag -> AnalEnv -> [Id] -> AnalEnv extendAnalEnvs top_lvl env vars = env { ae_sigs = extendSigEnvs top_lvl (ae_sigs env) vars } @@ -2418,6 +2425,12 @@ extendSigEnv top_lvl sigs var sig = extendVarEnv sigs var (sig, top_lvl) lookupSigEnv :: AnalEnv -> Id -> Maybe (DmdSig, TopLevelFlag) lookupSigEnv env id = lookupVarEnv (ae_sigs env) id +addInScopeAnalEnv :: AnalEnv -> Var -> AnalEnv +addInScopeAnalEnv env id = env { ae_sigs = delVarEnv (ae_sigs env) id } + +addInScopeAnalEnvs :: AnalEnv -> [Var] -> AnalEnv +addInScopeAnalEnvs env ids = env { ae_sigs = delVarEnvList (ae_sigs env) ids } + nonVirgin :: AnalEnv -> AnalEnv nonVirgin env = env { ae_virgin = False } @@ -2456,7 +2469,18 @@ findBndrDmd env dmd_ty id fam_envs = ae_fam_envs env -{- Note [Making dictionary parameters strict] +{- Note [Bringing a new variable into scope] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + f x = blah + g = ...(\f. ...f...)... + +In the body of the '\f', any occurrence of `f` refers to the lambda-bound `f`, +not the top-level `f` (which will be in `ae_sigs`). So it's very important +to delete `f` from `ae_sigs` when we pass a lambda/case/let-up binding of `f`. +Otherwise chaos results (#22718). + +Note [Making dictionary parameters strict] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? ===================================== compiler/GHC/Parser.y ===================================== @@ -540,8 +540,9 @@ importdecls This might seem like an awfully roundabout way to declare a list; plus, to add insult to injury you have to reverse the results at the end. The answer is that left recursion prevents us from running out of stack space when parsing long -sequences. See: https://www.haskell.org/happy/doc/html/sec-sequences.html for -more guidance. +sequences. See: +https://haskell-happy.readthedocs.io/en/latest/using.html#parsing-sequences +for more guidance. By adding/removing branches, you can affect what lists are accepted. Here are the most common patterns, rewritten as regular expressions for clarity: ===================================== configure.ac ===================================== @@ -667,6 +667,8 @@ GHC_LLVM_TARGET_SET_VAR # we intend to pass trough --targets to llvm as is. LLVMTarget_CPP=` echo "$LlvmTarget"` AC_SUBST(LLVMTarget_CPP) +# The target is substituted into the distrib/configure.ac file +AC_SUBST(LlvmTarget) dnl ** See whether cc supports --target= and set dnl CONF_CC_OPTS_STAGE[012] accordingly. ===================================== distrib/configure.ac.in ===================================== @@ -18,6 +18,8 @@ dnl-------------------------------------------------------------------- dnl Various things from the source distribution configure bootstrap_target=@TargetPlatform@ +bootstrap_llvm_target=@LlvmTarget@ + TargetHasRTSLinker=@TargetHasRTSLinker@ AC_SUBST(TargetHasRTSLinker) @@ -169,6 +171,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG # Stage 3 won't be supported by cross-compilation FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) +FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) +FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + AC_SUBST(CONF_CC_OPTS_STAGE0) AC_SUBST(CONF_CC_OPTS_STAGE1) AC_SUBST(CONF_CC_OPTS_STAGE2) ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -148,6 +148,8 @@ configurePackage context at Context {..} = do -- Figure out what hooks we need. hooks <- case C.buildType (C.flattenPackageDescription gpd) of C.Configure -> pure C.autoconfUserHooks + C.Simple -> pure C.simpleUserHooks + C.Make -> fail "build-type: Make is not supported" -- The 'time' package has a 'C.Custom' Setup.hs, but it's actually -- 'C.Configure' plus a @./Setup test@ hook. However, Cabal is also -- 'C.Custom', but doesn't have a configure script. @@ -155,12 +157,6 @@ configurePackage context at Context {..} = do configureExists <- doesFileExist $ replaceFileName (pkgCabalFile package) "configure" pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks - -- Not quite right, but good enough for us: - _ | package == rts -> - -- Don't try to do post configuration validation for 'rts'. This - -- will simply not work, due to the @ld-options@ and @Stg.h at . - pure $ C.simpleUserHooks { C.postConf = \_ _ _ _ -> return () } - | otherwise -> pure C.simpleUserHooks -- Compute the list of flags, and the Cabal configuration arguments flavourArgs <- args <$> flavour ===================================== hadrian/src/Rules/Register.hs ===================================== @@ -45,6 +45,14 @@ configurePackageRules = do isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend when isGmp $ need [buildP -/- "include/ghc-gmp.h"] + when (pkg == rts) $ do + -- Rts.h is a header listed in the cabal file, and configuring + -- therefore wants to ensure that the header "works" post-configure. + -- But it (transitively) includes these, so we must ensure they exist + -- for that check to work. + need [ buildP -/- "include/ghcautoconf.h" + , buildP -/- "include/ghcplatform.h" + ] Cabal.configurePackage ctx root -/- "**/autogen/cabal_macros.h" %> \out -> do ===================================== libraries/base/Data/List.hs ===================================== @@ -127,6 +127,7 @@ module Data.List -- | These functions treat a list @xs@ as a indexed collection, -- with indices ranging from 0 to @'length' xs - 1 at . + , (!?) , (!!) , elemIndex ===================================== libraries/base/Data/OldList.hs ===================================== @@ -127,6 +127,7 @@ module Data.OldList -- | These functions treat a list @xs@ as a indexed collection, -- with indices ranging from 0 to @'length' xs - 1 at . + , (!?) , (!!) , elemIndex ===================================== libraries/base/GHC/List.hs ===================================== @@ -31,7 +31,7 @@ module GHC.List ( -- Other functions foldl1', concat, concatMap, map, (++), filter, lookup, - head, last, tail, init, uncons, (!!), + head, last, tail, init, uncons, (!?), (!!), scanl, scanl1, scanl', scanr, scanr1, iterate, iterate', repeat, replicate, cycle, take, drop, splitAt, takeWhile, dropWhile, span, break, reverse, @@ -49,7 +49,7 @@ import GHC.Num (Num(..)) import GHC.Num.Integer (Integer) import GHC.Stack.Types (HasCallStack) -infixl 9 !! +infixl 9 !?, !! infix 4 `elem`, `notElem` -- $setup @@ -1370,9 +1370,10 @@ concat = foldr (++) [] -- >>> ['a', 'b', 'c'] !! (-1) -- *** Exception: Prelude.!!: negative index -- --- WARNING: This function is partial. You can use --- --- instead. +-- WARNING: This function is partial, and should only be used if you are +-- sure that the indexing will not fail. Otherwise, use 'Data.List.!?'. +-- +-- WARNING: This function takes linear time in the index. #if defined(USE_REPORT_PRELUDE) (!!) :: [a] -> Int -> a xs !! n | n < 0 = errorWithoutStackTrace "Prelude.!!: negative index" @@ -1401,6 +1402,30 @@ xs !! n _ -> r (k-1)) tooLarge xs n #endif +-- | List index (subscript) operator, starting from 0. Returns 'Nothing' +-- if the index is out of bounds +-- +-- >>> ['a', 'b', 'c'] !? 0 +-- Just 'a' +-- >>> ['a', 'b', 'c'] !? 2 +-- Just 'c' +-- >>> ['a', 'b', 'c'] !? 3 +-- Nothing +-- >>> ['a', 'b', 'c'] !? (-1) +-- Nothing +-- +-- This is the total variant of the partial '!!' operator. +-- +-- WARNING: This function takes linear time in the index. +(!?) :: [a] -> Int -> Maybe a + +{-# INLINABLE (!?) #-} +xs !? n + | n < 0 = Nothing + | otherwise = foldr (\x r k -> case k of + 0 -> Just x + _ -> r (k-1)) (const Nothing) xs n + -------------------------------------------------------------- -- The zip family -------------------------------------------------------------- ===================================== libraries/base/changelog.md ===================================== @@ -58,6 +58,8 @@ 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`. + * Add `Data.List.!?` per + [CLC proposal #110](https://github.com/haskell/core-libraries-committee/issues/110). ## 4.17.0.0 *August 2022* ===================================== m4/ghc_llvm_target.m4 ===================================== @@ -50,5 +50,10 @@ AC_DEFUN([GHC_LLVM_TARGET], [ # require it. AC_DEFUN([GHC_LLVM_TARGET_SET_VAR], [ AC_REQUIRE([FPTOOLS_SET_PLATFORMS_VARS]) - GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + if test "$bootstrap_llvm_target" != "" + then + LlvmTarget=$bootstrap_llvm_target + else + GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + fi ]) ===================================== rts/posix/OSThreads.c ===================================== @@ -218,6 +218,12 @@ start_thread (void *param) return startProc(startParam); } +/* Note: at least on Linux/Glibc, `pthread_setname_np` restricts the name of + * a thread to 16 bytes, including the terminating null byte. Hence, make sure + * to only pass in names of up to 15 characters. Otherwise, + * `pthread_setname_np` when called in `start_thread` will fail with `ERANGE`, + * which is not checked for, and the thread won't be named at all. + */ int createOSThread (OSThreadId* pId, const char *name, OSThreadProc *startProc, void *param) ===================================== rts/rts.cabal.in ===================================== @@ -275,6 +275,8 @@ library stg/SMP.h stg/Ticky.h stg/Types.h + + -- See Note [Undefined symbols in the RTS] if flag(64bit) if flag(leading-underscore) ld-options: @@ -474,6 +476,8 @@ library ld-options: "-Wl,-search_paths_first" -- See Note [fd_set_overflow] "-Wl,-U,___darwin_check_fd_set_overflow" + -- See Note [Undefined symbols in the RTS] + "-Wl,-undefined,dynamic_lookup" if !arch(x86_64) && !arch(aarch64) ld-options: -read_only_relocs warning @@ -714,3 +718,35 @@ library -- , https://github.com/sitsofe/fio/commit/b6a1e63a1ff607692a3caf3c2db2c3d575ba2320 -- The issue was originally reported in #19950 + + +-- Note [Undefined symbols in the RTS] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- The RTS is built with a number of `-u` flags. This is to handle cyclic +-- dependencies between the RTS and other libraries which we normally think of as +-- downstream from the RTS. "Regular" dependencies from usages in those libraries +-- to definitions in the RTS are handled normally. "Reverse" dependencies from +-- usages in the RTS to definitions in those libraries get the `-u` flag in the +-- RTS. +-- +-- The symbols are specified literally, but follow C ABI conventions (as all 3 of +-- C, C--, and Haskell do currently). Thus, we have to be careful to include a +-- leading underscore or not based on those conventions for the given platform in +-- question. +-- +-- A tricky part is that different linkers have different policies regarding +-- undefined symbols (not defined in the current binary, or found in a shared +-- library that could be loaded at run time). GNU Binutils' linker is fine with +-- undefined symbols by default, but Apple's "cctools" linker is not. To appease +-- that linker we either need to do a blanket `-undefined dynamic_lookup` or +-- whitelist each such symbol with an additional `-U` (see the man page for more +-- details). +-- +-- GHC already does `-undefined dynamic_lookup`, so we just do that for now, but +-- we might try to get more precise with `-U` in the future. +-- +-- Note that the RTS also `-u`s some atomics symbols that *are* defined --- and +-- defined within the RTS! It is not immediately clear why this is needed. This +-- dates back to c06e3f46d24ef69f3a3d794f5f604cb8c2a40cbc which mentions a build +-- failure that it was suggested that this fix, but the precise reasoning is not +-- explained. ===================================== rts/sm/NonMoving.c ===================================== @@ -1015,7 +1015,7 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) nonmoving_write_barrier_enabled = true; debugTrace(DEBUG_nonmoving_gc, "Starting concurrent mark thread"); OSThreadId thread; - if (createOSThread(&thread, "non-moving mark thread", + if (createOSThread(&thread, "nonmoving-mark", nonmovingConcurrentMark, mark_queue) != 0) { barf("nonmovingCollect: failed to spawn mark thread: %s", strerror(errno)); } ===================================== testsuite/tests/codeGen/should_gen_asm/AddMulX86.asm deleted ===================================== @@ -1,46 +0,0 @@ -.section .text -.align 8 -.align 8 - .quad 8589934604 - .quad 0 - .long 14 - .long 0 -.globl AddMulX86_f_info -.type AddMulX86_f_info, @function -AddMulX86_f_info: -.LcAx: - leaq (%r14,%rsi,8),%rbx - jmp *(%rbp) - .size AddMulX86_f_info, .-AddMulX86_f_info -.section .data -.align 8 -.align 1 -.globl AddMulX86_f_closure -.type AddMulX86_f_closure, @object -AddMulX86_f_closure: - .quad AddMulX86_f_info -.section .text -.align 8 -.align 8 - .quad 8589934604 - .quad 0 - .long 14 - .long 0 -.globl AddMulX86_g_info -.type AddMulX86_g_info, @function -AddMulX86_g_info: -.LcAL: - leaq (%r14,%rsi,8),%rbx - jmp *(%rbp) - .size AddMulX86_g_info, .-AddMulX86_g_info -.section .data -.align 8 -.align 1 -.globl AddMulX86_g_closure -.type AddMulX86_g_closure, @object -AddMulX86_g_closure: - .quad AddMulX86_g_info -.section .note.GNU-stack,"", at progbits -.ident "GHC 9.3.20220228" - - ===================================== testsuite/tests/codeGen/should_gen_asm/AddMulX86.hs deleted ===================================== @@ -1,12 +0,0 @@ -{-# LANGUAGE MagicHash #-} - -module AddMulX86 where - -import GHC.Exts - -f :: Int# -> Int# -> Int# -f x y = - x +# (y *# 8#) -- Should result in a lea instruction, which we grep the assembly output for. - -g x y = - (y *# 8#) +# x -- Should result in a lea instruction, which we grep the assembly output for. ===================================== testsuite/tests/codeGen/should_gen_asm/all.T ===================================== @@ -10,4 +10,3 @@ test('memset-unroll', is_amd64_codegen, compile_cmp_asm, ['cmm', '']) test('bytearray-memset-unroll', is_amd64_codegen, compile_grep_asm, ['hs', True, '']) test('bytearray-memcpy-unroll', is_amd64_codegen, compile_grep_asm, ['hs', True, '']) test('T18137', [when(opsys('darwin'), skip), only_ways(llvm_ways)], compile_grep_asm, ['hs', False, '-fllvm -split-sections']) -test('AddMulX86', is_amd64_codegen, compile_cmp_asm, ['hs', '-dno-typeable-binds']) ===================================== testsuite/tests/rts/pause-resume/pause_resume.c ===================================== @@ -187,7 +187,7 @@ void pauseAndResumeViaThread ) { OSThreadId threadId; - createOSThread(&threadId, "Pause and resume thread", &pauseAndResumeViaThread_helper, (void *)count); + createOSThread(&threadId, "pause-resume", &pauseAndResumeViaThread_helper, (void *)count); } const int TIMEOUT = 1000000; // 1 second View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b474a7c7229ad846e492920aeecf1970180daa63...146a145835f5c2e82da4dd0bcb90702460505a01 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b474a7c7229ad846e492920aeecf1970180daa63...146a145835f5c2e82da4dd0bcb90702460505a01 You're receiving 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 Jan 10 04:42:53 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Mon, 09 Jan 2023 23:42:53 -0500 Subject: [Git][ghc/ghc][wip/rts-configure-0] 18 commits: Misc cleanup Message-ID: <63bceccdc74f5_3b1bf952620326572@gitlab.mail> John Ericson pushed to branch wip/rts-configure-0 at Glasgow Haskell Compiler / GHC Commits: 541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - 28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00 Add support for sized literals in the bytecode interpreter. The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945 - - - - - ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00 rts: MUT_VAR is not a StgMutArrPtrs There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs. - - - - - 6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s - - - - - 73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. - - - - - 8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 5d65773e by John Ericson at 2023-01-09T20:39:27-05:00 Remove RTS hack for configuring See the brand new Note [Undefined symbols in the RTS] for additional details. - - - - - e3fff751 by Sebastian Graf at 2023-01-09T20:40:02-05:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - 65a07527 by John Ericson at 2023-01-09T23:40:48-05:00 Give the RTS it's own configure script Currently it doesn't do much anything, we are just trying to introduce it without breaking the build. Later, we will move functionality from the top-level configure script over to it. We need to bump Cabal for https://github.com/haskell/cabal/pull/8649; to facilitate and existing hack of skipping some configure checks for the RTS we now need to skip just *part* not *all* of the "post configure" hook, as running the configure script (which we definitely want to do) is also implemented as part of the "post configure" hook. But doing this requires exposing functionality that wasn't exposed before. - - - - - 30 changed files: - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - boot - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/HsToCore/ListComp.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.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/59e112cddbdda5e38f32df3f954f83d2a37ac783...65a07527316b1cfef564b62cbc809c118b3973ff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/59e112cddbdda5e38f32df3f954f83d2a37ac783...65a07527316b1cfef564b62cbc809c118b3973ff You're receiving 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 Jan 10 04:50:11 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Mon, 09 Jan 2023 23:50:11 -0500 Subject: [Git][ghc/ghc][wip/rts-configure-symbols] 31 commits: Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Message-ID: <63bcee831c825_3b1bf9563243271ef@gitlab.mail> John Ericson pushed to branch wip/rts-configure-symbols at Glasgow Haskell Compiler / GHC Commits: 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - 541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - 28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00 Add support for sized literals in the bytecode interpreter. The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945 - - - - - ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00 rts: MUT_VAR is not a StgMutArrPtrs There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs. - - - - - 6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s - - - - - 73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. - - - - - 8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 5d65773e by John Ericson at 2023-01-09T20:39:27-05:00 Remove RTS hack for configuring See the brand new Note [Undefined symbols in the RTS] for additional details. - - - - - e3fff751 by Sebastian Graf at 2023-01-09T20:40:02-05:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - 65a07527 by John Ericson at 2023-01-09T23:40:48-05:00 Give the RTS it's own configure script Currently it doesn't do much anything, we are just trying to introduce it without breaking the build. Later, we will move functionality from the top-level configure script over to it. We need to bump Cabal for https://github.com/haskell/cabal/pull/8649; to facilitate and existing hack of skipping some configure checks for the RTS we now need to skip just *part* not *all* of the "post configure" hook, as running the configure script (which we definitely want to do) is also implemented as part of the "post configure" hook. But doing this requires exposing functionality that wasn't exposed before. - - - - - 3cbf646d by John Ericson at 2023-01-09T23:50:02-05:00 Get newer Cabal for Hadrian - - - - - a5f611a4 by John Ericson at 2023-01-09T23:50:02-05:00 rts: Move external symbols logic to the configure script This is much more terse because we are programatically handling the leading underscore. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - boot - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Data/EnumSet.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/DocString.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Binds.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/dde92d14a0dc64a1d3025ab97773bed72727b006...a5f611a4c4564bb1f9b5fd856279f7e3608b82d7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dde92d14a0dc64a1d3025ab97773bed72727b006...a5f611a4c4564bb1f9b5fd856279f7e3608b82d7 You're receiving 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 Jan 10 05:47:18 2023 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Tue, 10 Jan 2023 00:47:18 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] 4 commits: Remove RTS hack for configuring Message-ID: <63bcfbe634f97_3b1bf93fcc990327552@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 5d65773e by John Ericson at 2023-01-09T20:39:27-05:00 Remove RTS hack for configuring See the brand new Note [Undefined symbols in the RTS] for additional details. - - - - - e3fff751 by Sebastian Graf at 2023-01-09T20:40:02-05:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - 04ae209b by Luite Stegeman at 2023-01-10T14:44:42+09:00 Add PrimCallConv support to GHCi This adds support for calling Cmm code from bytecode using the native calling convention, allowing modules that use `foreign import prim` to be loaded and debugged in GHCi. This patch introduces a new `PRIMCALL` bytecode instruction and a helper stack frame `stg_primcall`. The code is based on the existing functionality for dealing with unboxed tuples in bytecode, which has been generalised to handle arbitrary calls. Fixes #22051 - - - - - ab529bfa by Luite Stegeman at 2023-01-10T14:44:42+09:00 remove stack limit for bytecode primcalls and some documentation fixes - - - - - 25 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Foreign.hs - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Rules/Register.hs - rts/Disassembler.c - rts/Interpreter.c - rts/RtsSymbols.c - rts/StgMiscClosures.cmm - rts/include/rts/Bytecodes.h - rts/include/stg/MiscClosures.h - rts/rts.cabal.in - testsuite/tests/ghci/prog014/prog014.T - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout-ws-32 - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm - + testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile - + testsuite/tests/ghci/should_run/GHCiPrimCall/all.T Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -12,7 +12,7 @@ module GHC.ByteCode.Asm ( bcoFreeNames, SizedSeq, sizeSS, ssElts, iNTERP_STACK_CHECK_THRESH, - mkTupleInfoLit + mkNativeCallInfoLit ) where import GHC.Prelude @@ -32,7 +32,6 @@ import GHC.Types.Unique.DSet import GHC.Utils.Outputable import GHC.Utils.Panic -import GHC.Utils.Panic.Plain import GHC.Core.TyCon import GHC.Data.FastString @@ -40,7 +39,7 @@ import GHC.Data.SizedSeq import GHC.StgToCmm.Layout ( ArgRep(..) ) import GHC.Cmm.Expr -import GHC.Cmm.CallConv ( tupleRegsCover ) +import GHC.Cmm.CallConv ( allArgRegsCover ) import GHC.Platform import GHC.Platform.Profile @@ -202,7 +201,8 @@ assembleBCO platform (ProtoBCO { protoBCOName = nm (final_insns, final_lits, final_ptrs) <- flip execStateT initial_state $ runAsm platform long_jumps env asm -- precomputed size should be equal to final size - massert (n_insns == sizeSS final_insns) + massertPpr (n_insns == sizeSS final_insns) + (text "bytecode instruction count mismatch") let asm_insns = ssElts final_insns insns_arr = Array.listArray (0, fromIntegral n_insns - 1) asm_insns @@ -351,7 +351,8 @@ largeArg platform w = case platformWordSize platform of fromIntegral (w `shiftR` 32), fromIntegral (w `shiftR` 16), fromIntegral w] - PW4 -> assert (w < fromIntegral (maxBound :: Word32)) $ + PW4 -> assertPpr (w < fromIntegral (maxBound :: Word32)) + (text "largeArg too big:" <+> ppr w) $ [fromIntegral (w `shiftR` 16), fromIntegral w] @@ -388,14 +389,14 @@ assembleI platform i = case i of -> do let ul_bco = assembleBCO platform proto p <- ioptr (liftM BCOPtrBCO ul_bco) emit (push_alts pk) [Op p] - PUSH_ALTS_TUPLE proto tuple_info tuple_proto + PUSH_ALTS_TUPLE proto call_info tuple_proto -> do let ul_bco = assembleBCO platform proto ul_tuple_bco = assembleBCO platform tuple_proto p <- ioptr (liftM BCOPtrBCO ul_bco) p_tup <- ioptr (liftM BCOPtrBCO ul_tuple_bco) info <- int (fromIntegral $ - mkTupleInfoSig platform tuple_info) + mkNativeCallInfoSig platform call_info) emit bci_PUSH_ALTS_T [Op p, Op info, Op p_tup] PUSH_PAD8 -> emit bci_PUSH_PAD8 [] @@ -491,6 +492,7 @@ assembleI platform i = case i of RETURN_TUPLE -> emit bci_RETURN_T [] CCALL off m_addr i -> do np <- addr m_addr emit bci_CCALL [SmallOp off, Op np, SmallOp i] + PRIMCALL -> emit bci_PRIMCALL [] BRK_FUN index uniq cc -> do p1 <- ptr BCOPtrBreakArray q <- int (getKey uniq) np <- addr cc @@ -580,41 +582,44 @@ return_unlifted V64 = error "return_unlifted: vector" maximum number of tuple elements may be larger. Elements can also take multiple words on the stack (for example Double# on a 32 bit platform). - -} -maxTupleNativeStackSize :: WordOff -maxTupleNativeStackSize = 62 +maxTupleReturnNativeStackSize :: WordOff +maxTupleReturnNativeStackSize = 62 {- - Construct the tuple_info word that stg_ctoi_t and stg_ret_t use - to convert a tuple between the native calling convention and the + Construct the call_info word that stg_ctoi_t, stg_ret_t and stg_primcall + use to convert arguments between the native calling convention and the interpreter. - See Note [GHCi tuple layout] for more information. + See Note [GHCi and native call registers] for more information. -} -mkTupleInfoSig :: Platform -> TupleInfo -> Word32 -mkTupleInfoSig platform TupleInfo{..} - | tupleNativeStackSize > maxTupleNativeStackSize - = pprPanic "mkTupleInfoSig: tuple too big for the bytecode compiler" - (ppr tupleNativeStackSize <+> text "stack words." <+> +mkNativeCallInfoSig :: Platform -> NativeCallInfo -> Word32 +mkNativeCallInfoSig platform NativeCallInfo{..} + | nativeCallType == NativeTupleReturn && nativeCallStackSpillSize > maxTupleReturnNativeStackSize + = pprPanic "mkNativeCallInfoSig: tuple too big for the bytecode compiler" + (ppr nativeCallStackSpillSize <+> text "stack words." <+> text "Use -fobject-code to get around this limit" ) | otherwise - = assert (length regs <= 24) {- 24 bits for bitmap -} - assert (tupleNativeStackSize < 255) {- 8 bits for stack size -} - assert (all (`elem` regs) (regSetToList tupleRegs)) {- all regs accounted for -} - foldl' reg_bit 0 (zip regs [0..]) .|. - (fromIntegral tupleNativeStackSize `shiftL` 24) + = assertPpr (length regs <= 24) (text "too many registers for bitmap:" <+> ppr (length regs)) {- 24 bits for register bitmap -} + assertPpr (cont_offset < 255) (text "continuation offset too large:" <+> ppr cont_offset) {- 8 bits for continuation offset (only for NativeTupleReturn) -} + assertPpr (all (`elem` regs) (regSetToList nativeCallRegs)) (text "not all registers accounted for") {- all regs accounted for -} + foldl' reg_bit 0 (zip regs [0..]) .|. (cont_offset `shiftL` 24) where + cont_offset :: Word32 + cont_offset + | nativeCallType == NativeTupleReturn = fromIntegral nativeCallStackSpillSize + | otherwise = 0 -- there is no continuation for primcalls + reg_bit :: Word32 -> (GlobalReg, Int) -> Word32 reg_bit x (r, n) - | r `elemRegSet` tupleRegs = x .|. 1 `shiftL` n - | otherwise = x - regs = tupleRegsCover platform + | r `elemRegSet` nativeCallRegs = x .|. 1 `shiftL` n + | otherwise = x + regs = allArgRegsCover platform -mkTupleInfoLit :: Platform -> TupleInfo -> Literal -mkTupleInfoLit platform tuple_info = - mkLitWord platform . fromIntegral $ mkTupleInfoSig platform tuple_info +mkNativeCallInfoLit :: Platform -> NativeCallInfo -> Literal +mkNativeCallInfoLit platform call_info = + mkLitWord platform . fromIntegral $ mkNativeCallInfoSig platform call_info -- Make lists of host-sized words for literals, so that when the -- words are placed in memory at increasing addresses, the ===================================== compiler/GHC/ByteCode/Instr.hs ===================================== @@ -90,7 +90,7 @@ data BCInstr | PUSH_ALTS (ProtoBCO Name) | PUSH_ALTS_UNLIFTED (ProtoBCO Name) ArgRep | PUSH_ALTS_TUPLE (ProtoBCO Name) -- continuation - !TupleInfo + !NativeCallInfo (ProtoBCO Name) -- tuple return BCO -- Pushing 8, 16 and 32 bits of padding (for constructors). @@ -184,6 +184,8 @@ data BCInstr -- (XXX: inefficient, but I don't know -- what the alignment constraints are.) + | PRIMCALL + -- For doing magic ByteArray passing to foreign calls | SWIZZLE Word16 -- to the ptr N words down the stack, Word16 -- add M (interpreted as a signed 16-bit entity) @@ -269,8 +271,8 @@ instance Outputable BCInstr where ppr (PUSH_ALTS bco) = hang (text "PUSH_ALTS") 2 (ppr bco) ppr (PUSH_ALTS_UNLIFTED bco pk) = hang (text "PUSH_ALTS_UNLIFTED" <+> ppr pk) 2 (ppr bco) - ppr (PUSH_ALTS_TUPLE bco tuple_info tuple_bco) = - hang (text "PUSH_ALTS_TUPLE" <+> ppr tuple_info) + ppr (PUSH_ALTS_TUPLE bco call_info tuple_bco) = + hang (text "PUSH_ALTS_TUPLE" <+> ppr call_info) 2 (ppr tuple_bco $+$ ppr bco) @@ -340,6 +342,7 @@ instance Outputable BCInstr where 0x1 -> text "(interruptible)" 0x2 -> text "(unsafe)" _ -> empty) + ppr PRIMCALL = text "PRIMCALL" ppr (SWIZZLE stkoff n) = text "SWIZZLE " <+> text "stkoff" <+> ppr stkoff <+> text "by" <+> ppr n ppr ENTER = text "ENTER" @@ -382,11 +385,11 @@ bciStackUse (PUSH_ALTS bco) = 2 {- profiling only, restore CCCS -} + bciStackUse (PUSH_ALTS_UNLIFTED bco _) = 2 {- profiling only, restore CCCS -} + 4 + protoBCOStackUse bco bciStackUse (PUSH_ALTS_TUPLE bco info _) = - -- (tuple_bco, tuple_info word, cont_bco, stg_ctoi_t) + -- (tuple_bco, call_info word, cont_bco, stg_ctoi_t) -- tuple - -- (tuple_info, tuple_bco, stg_ret_t) + -- (call_info, tuple_bco, stg_ret_t) 1 {- profiling only -} + - 7 + fromIntegral (tupleSize info) + protoBCOStackUse bco + 7 + fromIntegral (nativeCallSize info) + protoBCOStackUse bco bciStackUse (PUSH_PAD8) = 1 -- overapproximation bciStackUse (PUSH_PAD16) = 1 -- overapproximation bciStackUse (PUSH_PAD32) = 1 -- overapproximation on 64bit arch @@ -443,6 +446,7 @@ bciStackUse RETURN{} = 0 bciStackUse RETURN_UNLIFTED{} = 1 -- pushes stg_ret_X for some X bciStackUse RETURN_TUPLE{} = 1 -- pushes stg_ret_t header bciStackUse CCALL{} = 0 +bciStackUse PRIMCALL{} = 1 -- pushes stg_primcall bciStackUse SWIZZLE{} = 0 bciStackUse BRK_FUN{} = 0 ===================================== compiler/GHC/ByteCode/Types.hs ===================================== @@ -10,7 +10,7 @@ module GHC.ByteCode.Types ( CompiledByteCode(..), seqCompiledByteCode , FFIInfo(..) , RegBitmap(..) - , TupleInfo(..), voidTupleInfo + , NativeCallType(..), NativeCallInfo(..), voidTupleReturnInfo, voidPrimCallInfo , ByteOff(..), WordOff(..) , UnlinkedBCO(..), BCOPtr(..), BCONPtr(..) , ItblEnv, ItblPtr(..) @@ -105,22 +105,32 @@ newtype RegBitmap = RegBitmap { unRegBitmap :: Word32 } See GHC.StgToByteCode.layoutTuple for more details. -} -data TupleInfo = TupleInfo - { tupleSize :: !WordOff -- total size of tuple in words - , tupleRegs :: !GlobalRegSet - , tupleNativeStackSize :: !WordOff {- words spilled on the stack by - GHCs native calling convention -} - } deriving (Show) - -instance Outputable TupleInfo where - ppr TupleInfo{..} = text " ppr tupleSize <+> - text "stack" <+> ppr tupleNativeStackSize <+> - text "regs" <+> - ppr (map (text @SDoc . show) $ regSetToList tupleRegs) <> - char '>' - -voidTupleInfo :: TupleInfo -voidTupleInfo = TupleInfo 0 emptyRegSet 0 + +data NativeCallType = NativePrimCall + | NativeTupleReturn + deriving (Eq) + +data NativeCallInfo = NativeCallInfo + { nativeCallType :: !NativeCallType + , nativeCallSize :: !WordOff -- total size of arguments in words + , nativeCallRegs :: !GlobalRegSet + , nativeCallStackSpillSize :: !WordOff {- words spilled on the stack by + GHCs native calling convention -} + } + +instance Outputable NativeCallInfo where + ppr NativeCallInfo{..} = text " ppr nativeCallSize <+> + text "stack" <+> ppr nativeCallStackSpillSize <+> + text "regs" <+> + ppr (map (text @SDoc . show) $ regSetToList nativeCallRegs) <> + char '>' + + +voidTupleReturnInfo :: NativeCallInfo +voidTupleReturnInfo = NativeCallInfo NativeTupleReturn 0 emptyRegSet 0 + +voidPrimCallInfo :: NativeCallInfo +voidPrimCallInfo = NativeCallInfo NativePrimCall 0 emptyRegSet 0 type ItblEnv = NameEnv (Name, ItblPtr) -- We need the Name in the range so we know which ===================================== compiler/GHC/Cmm/CallConv.hs ===================================== @@ -3,7 +3,7 @@ module GHC.Cmm.CallConv ( assignArgumentsPos, assignStack, realArgRegsCover, - tupleRegsCover + allArgRegsCover ) where import GHC.Prelude @@ -220,12 +220,105 @@ realArgRegsCover platform realLongRegs platform -- we don't save XMM registers if they are not used for parameter passing --- Like realArgRegsCover but always includes the node. This covers the real --- and virtual registers used for unboxed tuples. --- --- Note: if anything changes in how registers for unboxed tuples overlap, --- make sure to also update GHC.StgToByteCode.layoutTuple. -tupleRegsCover :: Platform -> [GlobalReg] -tupleRegsCover platform = +{- + + Note [GHCi and native call registers] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + The GHCi bytecode interpreter does not have access to the STG registers + that the native calling convention uses for passing arguments. It uses + helper stack frames to move values between the stack and registers. + + If only a single register needs to be moved, GHCi uses a specific stack + frame. For example stg_ctoi_R1p saves a heap pointer value from STG register + R1 and stg_ctoi_D1 saves a double precision floating point value from D1. + In the other direction, helpers stg_ret_p and stg_ret_d move a value from + the stack to the R1 and D1 registers, respectively. + + When GHCi needs to move more than one register it cannot use a specific + helper frame. It would simply be impossible to create a helper for all + possible combinations of register values. Instead, there are generic helper + stack frames that use a call_info word that describes the active registers + and the number of stack words used by the arguments of a call. + + These helper stack frames are currently: + + - stg_ret_t: return a tuple to the continuation at the top of + the stack + - stg_ctoi_t: convert a tuple return value to be used in + bytecode + - stg_primcall: call a function + + + The call_info word contains a bitmap of the active registers + for the call and and a stack offset. The layout is as follows: + + - bit 0-23: Bitmap of active registers for the call, the + order corresponds to the list returned by + allArgRegsCover. For example if bit 0 (the least + significant bit) is set, the first register in the + allArgRegsCover list is active. Bit 1 for the + second register in the list and so on. + + - bit 24-31: Unsigned byte indicating the stack offset + of the continuation in words. For tuple returns + this is the number of words returned on the + stack. For primcalls this field is unused, since + we don't jump to a continuation. + + The upper 32 bits on 64 bit platforms are currently unused. + + If a register is smaller than a word on the stack (for example a + single precision float on a 64 bit system), then the stack slot + is padded to a whole word. + + Example: + + If a call has three arguments passed registers and + additional two words of arguments on the stack, then + three bits in the bitmap in bits 0-23 would be set. And + Bit 24-31 would be 00000010 (two in binary). + + The values on the stack before a call to POP_ARG_REGS would + be as follows: + + ... + stack_arg_1 + stack_arg_2 + register_arg_3 + register_arg_2 + register_arg_1 <- Sp + + A call to POP_ARG_REGS(call_info) would move register_arg_1 + to the register corresponding to the lowest set bit in the + call_info word. register_arg_2 would be moved to the register + corresponding to the second lowest set bit, and so on. + + After POP_ARG_REGS(call_info), the stack pointer Sp points + to the topmost stack argument, so the stack looks as follows: + + ... + stack_arg_1 + stack_arg_2 <- Sp + + At this point all the arguments are in place and we are ready + to jump to the native function. + + On x86_64, the double precision (Dn) and single precision + floating (Fn) point registers overlap, e.g. D1 uses the same + physical register as F1. On this platform, the list returned + by allArgRegsCover contains only entries for the double + precision registers. If an argument is passed in register + Fn, the bit corresponding to Dn should be set. + + Note: if anything changes in how registers for native calls overlap, + make sure to also update GHC.StgToByteCode.layoutNativeCall + -} + +-- Like realArgRegsCover but always includes the node. This covers all real +-- and virtual registers actually used for passing arguments. + +allArgRegsCover :: Platform -> [GlobalReg] +allArgRegsCover platform = nub (VanillaReg 1 VGcPtr : realArgRegsCover platform) ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -1233,8 +1233,8 @@ stmtMacros = listToUFM [ ( fsLit "SAVE_REGS", \[] -> emitSaveRegs ), ( fsLit "RESTORE_REGS", \[] -> emitRestoreRegs ), - ( fsLit "PUSH_TUPLE_REGS", \[live_regs] -> emitPushTupleRegs live_regs ), - ( fsLit "POP_TUPLE_REGS", \[live_regs] -> emitPopTupleRegs live_regs ), + ( fsLit "PUSH_ARG_REGS", \[live_regs] -> emitPushArgRegs live_regs ), + ( fsLit "POP_ARG_REGS", \[live_regs] -> emitPopArgRegs live_regs ), ( fsLit "LDV_ENTER", \[e] -> ldvEnter e ), ( fsLit "LDV_RECORD_CREATE", \[e] -> ldvRecordCreate e ), ===================================== compiler/GHC/Cmm/Reg.hs ===================================== @@ -223,7 +223,7 @@ instance Eq GlobalReg where _r1 == _r2 = False -- NOTE: this Ord instance affects the tuple layout in GHCi, see --- Note [GHCi tuple layout] +-- Note [GHCi and native call registers] instance Ord GlobalReg where compare (VanillaReg i _) (VanillaReg j _) = compare i j -- Ignore type when seeking clashes ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -333,7 +333,8 @@ dmdAnalBindLetUp :: TopLevelFlag -> WithDmdType (DmdResult CoreBind a) dmdAnalBindLetUp top_lvl env id rhs anal_body = WithDmdType final_ty (R (NonRec id' rhs') (body')) where - WithDmdType body_ty body' = anal_body env + WithDmdType body_ty body' = anal_body (addInScopeAnalEnv env id) + -- See Note [Bringing a new variable into scope] WithDmdType body_ty' id_dmd = findBndrDmd env body_ty id -- See Note [Finalising boxity for demand signatures] @@ -473,7 +474,8 @@ dmdAnal' env dmd (App fun arg) dmdAnal' env dmd (Lam var body) | isTyVar var = let - WithDmdType body_ty body' = dmdAnal env dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) dmd body + -- See Note [Bringing a new variable into scope] in WithDmdType body_ty (Lam var body') @@ -481,7 +483,8 @@ dmdAnal' env dmd (Lam var body) = let (n, body_dmd) = peelCallDmd dmd -- body_dmd: a demand to analyze the body - WithDmdType body_ty body' = dmdAnal env body_dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) body_dmd body + -- See Note [Bringing a new variable into scope] WithDmdType lam_ty var' = annotateLamIdBndr env body_ty var new_dmd_type = multDmdType n lam_ty in @@ -493,7 +496,9 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt_con bndrs rhs]) -- can consider its field demands when analysing the scrutinee. | want_precise_field_dmds alt_con = let - WithDmdType rhs_ty rhs' = dmdAnal env dmd rhs + rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + WithDmdType rhs_ty rhs' = dmdAnal rhs_env dmd rhs WithDmdType alt_ty1 fld_dmds = findBndrsDmds env rhs_ty bndrs WithDmdType alt_ty2 case_bndr_dmd = findBndrDmd env alt_ty1 case_bndr !case_bndr' = setIdDemandInfo case_bndr case_bndr_dmd @@ -629,7 +634,9 @@ dmdAnalSumAlts env dmd case_bndr (alt:alts) dmdAnalSumAlt :: AnalEnv -> SubDemand -> Id -> CoreAlt -> WithDmdType CoreAlt dmdAnalSumAlt env dmd case_bndr (Alt con bndrs rhs) - | WithDmdType rhs_ty rhs' <- dmdAnal env dmd rhs + | let rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + , WithDmdType rhs_ty rhs' <- dmdAnal rhs_env dmd rhs , WithDmdType alt_ty dmds <- findBndrsDmds env rhs_ty bndrs , let (_ :* case_bndr_sd) = findIdDemand alt_ty case_bndr -- See Note [Demand on case-alternative binders] @@ -2399,7 +2406,7 @@ enterDFun bind env emptySigEnv :: SigEnv emptySigEnv = emptyVarEnv --- | Extend an environment with the strictness IDs attached to the id +-- | Extend an environment with the strictness sigs attached to the Ids extendAnalEnvs :: TopLevelFlag -> AnalEnv -> [Id] -> AnalEnv extendAnalEnvs top_lvl env vars = env { ae_sigs = extendSigEnvs top_lvl (ae_sigs env) vars } @@ -2418,6 +2425,12 @@ extendSigEnv top_lvl sigs var sig = extendVarEnv sigs var (sig, top_lvl) lookupSigEnv :: AnalEnv -> Id -> Maybe (DmdSig, TopLevelFlag) lookupSigEnv env id = lookupVarEnv (ae_sigs env) id +addInScopeAnalEnv :: AnalEnv -> Var -> AnalEnv +addInScopeAnalEnv env id = env { ae_sigs = delVarEnv (ae_sigs env) id } + +addInScopeAnalEnvs :: AnalEnv -> [Var] -> AnalEnv +addInScopeAnalEnvs env ids = env { ae_sigs = delVarEnvList (ae_sigs env) ids } + nonVirgin :: AnalEnv -> AnalEnv nonVirgin env = env { ae_virgin = False } @@ -2456,7 +2469,18 @@ findBndrDmd env dmd_ty id fam_envs = ae_fam_envs env -{- Note [Making dictionary parameters strict] +{- Note [Bringing a new variable into scope] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + f x = blah + g = ...(\f. ...f...)... + +In the body of the '\f', any occurrence of `f` refers to the lambda-bound `f`, +not the top-level `f` (which will be in `ae_sigs`). So it's very important +to delete `f` from `ae_sigs` when we pass a lambda/case/let-up binding of `f`. +Otherwise chaos results (#22718). + +Note [Making dictionary parameters strict] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -58,7 +58,7 @@ import GHC.Data.FastString import GHC.Utils.Panic import GHC.Utils.Panic.Plain import GHC.Utils.Exception (evaluate) -import GHC.StgToCmm.Closure ( NonVoid(..), fromNonVoid, nonVoidIds ) +import GHC.StgToCmm.Closure ( NonVoid(..), fromNonVoid, nonVoidIds, argPrimRep ) import GHC.StgToCmm.Layout import GHC.Runtime.Heap.Layout hiding (WordOff, ByteOff, wordsToBytes) import GHC.Data.Bitmap @@ -464,10 +464,10 @@ returnUnliftedReps d s szb reps = do [rep] -> return (unitOL $ RETURN_UNLIFTED (toArgRep platform rep)) -- otherwise use RETURN_TUPLE with a tuple descriptor nv_reps -> do - let (tuple_info, args_offsets) = layoutTuple profile 0 (primRepCmmType platform) nv_reps + let (call_info, args_offsets) = layoutNativeCall profile NativeTupleReturn 0 (primRepCmmType platform) nv_reps args_ptrs = map (\(rep, off) -> (isFollowableArg (toArgRep platform rep), off)) args_offsets - tuple_bco <- emitBc (tupleBCO platform tuple_info args_ptrs) - return $ PUSH_UBX (mkTupleInfoLit platform tuple_info) 1 `consOL` + tuple_bco <- emitBc (tupleBCO platform call_info args_ptrs) + return $ PUSH_UBX (mkNativeCallInfoLit platform call_info) 1 `consOL` PUSH_BCO tuple_bco `consOL` unitOL RETURN_TUPLE return ( mkSlideB platform szb (d - s) -- clear to sequel @@ -484,7 +484,11 @@ returnUnboxedTuple d s p es = do profile <- getProfile let platform = profilePlatform profile arg_ty e = primRepCmmType platform (atomPrimRep e) - (tuple_info, tuple_components) = layoutTuple profile d arg_ty es + (call_info, tuple_components) = layoutNativeCall profile + NativeTupleReturn + d + arg_ty + es go _ pushes [] = return (reverse pushes) go !dd pushes ((a, off):cs) = do (push, szb) <- pushAtom dd p a massert (off == dd + szb) @@ -492,7 +496,7 @@ returnUnboxedTuple d s p es = do pushes <- go d [] tuple_components ret <- returnUnliftedReps d s - (wordsToBytes platform $ tupleSize tuple_info) + (wordsToBytes platform $ nativeCallSize call_info) (map atomPrimRep es) return (mconcat pushes `appOL` ret) @@ -648,14 +652,14 @@ schemeT d s p app -- Case 1 schemeT d s p (StgOpApp (StgFCallOp (CCall ccall_spec) _ty) args result_ty) = if isSupportedCConv ccall_spec - then generateCCall d s p ccall_spec result_ty (reverse args) + then generateCCall d s p ccall_spec result_ty args else unsupportedCConvException schemeT d s p (StgOpApp (StgPrimOp op) args _ty) = doTailCall d s p (primOpId op) (reverse args) -schemeT _d _s _p (StgOpApp StgPrimCallOp{} _args _ty) - = unsupportedCConvException +schemeT d s p (StgOpApp (StgPrimCallOp (PrimCall label unit)) args result_ty) + = generatePrimCall d s p label (Just unit) result_ty args -- Case 2: Unboxed tuple schemeT d s p (StgConApp con _cn args _tys) @@ -840,18 +844,18 @@ doCase d s p scrut bndr alts | ubx_frame = wordSize platform | otherwise = 0 - (bndr_size, tuple_info, args_offsets) + (bndr_size, call_info, args_offsets) | ubx_tuple_frame = let bndr_ty = primRepCmmType platform bndr_reps = filter (not.isVoidRep) (bcIdPrimReps bndr) - (tuple_info, args_offsets) = - layoutTuple profile 0 bndr_ty bndr_reps - in ( wordsToBytes platform (tupleSize tuple_info) - , tuple_info + (call_info, args_offsets) = + layoutNativeCall profile NativeTupleReturn 0 bndr_ty bndr_reps + in ( wordsToBytes platform (nativeCallSize call_info) + , call_info , args_offsets ) | otherwise = ( wordsToBytes platform (idSizeW platform bndr) - , voidTupleInfo + , voidTupleReturnInfo , [] ) @@ -885,17 +889,18 @@ doCase d s p scrut bndr alts | isUnboxedTupleType bndr_ty || isUnboxedSumType bndr_ty = let bndr_ty = primRepCmmType platform . bcIdPrimRep tuple_start = d_bndr - (tuple_info, args_offsets) = - layoutTuple profile - 0 - bndr_ty - bndrs + (call_info, args_offsets) = + layoutNativeCall profile + NativeTupleReturn + 0 + bndr_ty + bndrs stack_bot = d_alts p' = Map.insertList [ (arg, tuple_start - - wordsToBytes platform (tupleSize tuple_info) + + wordsToBytes platform (nativeCallSize call_info) + offset) | (arg, offset) <- args_offsets , not (isVoidRep $ bcIdPrimRep arg)] @@ -981,8 +986,8 @@ doCase d s p scrut bndr alts -- unboxed tuples get two more words, the second is a pointer (tuple_bco) (extra_pointers, extra_slots) - | ubx_tuple_frame && profiling = ([1], 3) -- tuple_info, tuple_BCO, CCCS - | ubx_tuple_frame = ([1], 2) -- tuple_info, tuple_BCO + | ubx_tuple_frame && profiling = ([1], 3) -- call_info, tuple_BCO, CCCS + | ubx_tuple_frame = ([1], 2) -- call_info, tuple_BCO | otherwise = ([], 0) bitmap_size = trunc16W $ fromIntegral extra_slots + @@ -1028,8 +1033,8 @@ doCase d s p scrut bndr alts let args_ptrs = map (\(rep, off) -> (isFollowableArg (toArgRep platform rep), off)) args_offsets - tuple_bco <- emitBc (tupleBCO platform tuple_info args_ptrs) - return (PUSH_ALTS_TUPLE alt_bco' tuple_info tuple_bco + tuple_bco <- emitBc (tupleBCO platform call_info args_ptrs) + return (PUSH_ALTS_TUPLE alt_bco' call_info tuple_bco `consOL` scrut_code) else let push_alts | not ubx_frame @@ -1050,14 +1055,15 @@ doCase d s p scrut bndr alts -- The native calling convention uses registers for tuples, but in the -- bytecode interpreter, all values live on the stack. -layoutTuple :: Profile - -> ByteOff - -> (a -> CmmType) - -> [a] - -> ( TupleInfo -- See Note [GHCi TupleInfo] - , [(a, ByteOff)] -- argument, offset on stack - ) -layoutTuple profile start_off arg_ty reps = +layoutNativeCall :: Profile + -> NativeCallType + -> ByteOff + -> (a -> CmmType) + -> [a] + -> ( NativeCallInfo -- See Note [GHCi TupleInfo] + , [(a, ByteOff)] -- argument, offset on stack + ) +layoutNativeCall profile call_type start_off arg_ty reps = let platform = profilePlatform profile (orig_stk_bytes, pos) = assignArgumentsPos profile 0 @@ -1070,7 +1076,7 @@ layoutTuple profile start_off arg_ty reps = -- sort the register parameters by register and add them to the stack regs_order :: Map.Map GlobalReg Int - regs_order = Map.fromList $ zip (tupleRegsCover platform) [0..] + regs_order = Map.fromList $ zip (allArgRegsCover platform) [0..] reg_order :: GlobalReg -> (Int, GlobalReg) reg_order reg | Just n <- Map.lookup reg regs_order = (n, reg) @@ -1099,10 +1105,11 @@ layoutTuple profile start_off arg_ty reps = get_byte_off _ = panic "GHC.StgToByteCode.layoutTuple get_byte_off" - in ( TupleInfo - { tupleSize = bytesToWords platform (ByteOff new_stk_bytes) - , tupleRegs = regs_set - , tupleNativeStackSize = bytesToWords platform + in ( NativeCallInfo + { nativeCallType = call_type + , nativeCallSize = bytesToWords platform (ByteOff new_stk_bytes) + , nativeCallRegs = regs_set + , nativeCallStackSpillSize = bytesToWords platform (ByteOff orig_stk_bytes) } , sortBy (comparing snd) $ @@ -1127,7 +1134,7 @@ usePlainReturn t ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We have the bytecode instructions RETURN_TUPLE and PUSH_ALTS_TUPLE to return and receive arbitrary unboxed tuples, respectively. These - instructions use the helper data tuple_BCO and tuple_info. + instructions use the helper data tuple_BCO and call_info. The helper data is used to convert tuples between GHCs native calling convention (object code), which uses stack and registers, and the bytecode @@ -1139,7 +1146,7 @@ usePlainReturn t ================= Bytecode that returns a tuple first pushes all the tuple fields followed - by the appropriate tuple_info and tuple_BCO onto the stack. It then + by the appropriate call_info and tuple_BCO onto the stack. It then executes the RETURN_TUPLE instruction, which causes the interpreter to push stg_ret_t_info to the top of the stack. The stack (growing down) then looks as follows: @@ -1150,14 +1157,14 @@ usePlainReturn t tuple_field_2 ... tuple_field_n - tuple_info + call_info tuple_BCO stg_ret_t_info <- Sp If next_frame is bytecode, the interpreter will start executing it. If it's object code, the interpreter jumps back to the scheduler, which in turn jumps to stg_ret_t. stg_ret_t converts the tuple to the native - calling convention using the description in tuple_info, and then jumps + calling convention using the description in call_info, and then jumps to next_frame. @@ -1169,13 +1176,13 @@ usePlainReturn t tuple. The PUSH_ALTS_TUPLE instuction contains three pieces of data: * cont_BCO: the continuation that receives the tuple - * tuple_info: see below + * call_info: see below * tuple_BCO: see below The interpreter pushes these onto the stack when the PUSH_ALTS_TUPLE instruction is executed, followed by stg_ctoi_tN_info, with N depending on the number of stack words used by the tuple in the GHC native calling - convention. N is derived from tuple_info. + convention. N is derived from call_info. For example if we expect a tuple with three words on the stack, the stack looks as follows after PUSH_ALTS_TUPLE: @@ -1186,7 +1193,7 @@ usePlainReturn t cont_free_var_2 ... cont_free_var_n - tuple_info + call_info tuple_BCO cont_BCO stg_ctoi_t3_info <- Sp @@ -1206,20 +1213,20 @@ usePlainReturn t that is already on the stack. - The tuple_info word + The call_info word =================== - The tuple_info word describes the stack and STG register (e.g. R1..R6, - D1..D6) usage for the tuple. tuple_info contains enough information to + The call_info word describes the stack and STG register (e.g. R1..R6, + D1..D6) usage for the tuple. call_info contains enough information to convert the tuple between the stack-only bytecode and stack+registers GHC native calling conventions. - See Note [GHCi tuple layout] for more details of how the data is packed - in a single word. + See Note [GHCi and native call registers] for more details of how the + data is packed in a single word. -} -tupleBCO :: Platform -> TupleInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name +tupleBCO :: Platform -> NativeCallInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name tupleBCO platform info pointers = mkProtoBCO platform invented_name body_code (Left []) 0{-no arity-} bitmap_size bitmap False{-is alts-} @@ -1233,15 +1240,103 @@ tupleBCO platform info pointers = -} invented_name = mkSystemVarName (mkPseudoUniqueE 0) (fsLit "tuple") - -- the first word in the frame is the tuple_info word, + -- the first word in the frame is the call_info word, -- which is not a pointer - bitmap_size = trunc16W $ 1 + tupleSize info + bitmap_size = trunc16W $ 1 + nativeCallSize info bitmap = intsToReverseBitmap platform (fromIntegral bitmap_size) $ map ((+1) . fromIntegral . bytesToWords platform . snd) (filter fst pointers) body_code = mkSlideW 0 1 -- pop frame header `snocOL` RETURN_TUPLE -- and add it again +primCallBCO :: Platform -> NativeCallInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name +primCallBCO platform args_info pointers = + mkProtoBCO platform invented_name body_code (Left []) + 0{-no arity-} bitmap_size bitmap False{-is alts-} + + where + {- + The primcall BCO is never referred to by name, so we can get away + with using a fake name here. We will need to change this if we want + to save some memory by sharing the BCO between places that have + the same tuple shape + -} + invented_name = mkSystemVarName (mkPseudoUniqueE 0) (fsLit "primcall") + + -- the first three words in the frame are the BCO describing the + -- pointers in the frame, the call_info word and the pointer + -- to the Cmm function being called. None of these is a pointer that + -- should be followed by the garbage collector + bitmap_size = trunc16W $ 2 + nativeCallSize args_info + bitmap = intsToReverseBitmap platform (fromIntegral bitmap_size) $ + map ((+2) . fromIntegral . bytesToWords platform . snd) + (filter fst pointers) + -- if the primcall BCO is ever run it's a bug, since the BCO should only + -- be pushed immediately before running the PRIMCALL bytecode instruction, + -- which immediately leaves the interpreter to jump to the stg_primcall_info + -- Cmm function + body_code = unitOL CASEFAIL + +-- ----------------------------------------------------------------------------- +-- Deal with a primitive call to native code. + +generatePrimCall + :: StackDepth + -> Sequel + -> BCEnv + -> CLabelString -- where to call + -> Maybe Unit + -> Type + -> [StgArg] -- args (atoms) + -> BcM BCInstrList +generatePrimCall d s p target _mb_unit _result_ty args + = do + profile <- getProfile + let + platform = profilePlatform profile + + non_void VoidRep = False + non_void _ = True + + nv_args :: [StgArg] + nv_args = filter (non_void . argPrimRep) args + + (args_info, args_offsets) = + layoutNativeCall profile + NativePrimCall + d + (primRepCmmType platform . argPrimRep) + nv_args + + args_ptrs :: [(Bool, ByteOff)] + args_ptrs = + map (\(r, off) -> + (isFollowableArg (toArgRep platform . argPrimRep $ r), off)) + args_offsets + + push_target = PUSH_UBX (LitLabel target Nothing IsFunction) 1 + push_info = PUSH_UBX (mkNativeCallInfoLit platform args_info) 1 + {- + compute size to move payload (without stg_primcall_info header) + + size of arguments plus three words for: + - function pointer to the target + - call_info word + - BCO to describe the stack frame + -} + szb = wordsToBytes platform (nativeCallSize args_info + 3) + go _ pushes [] = return (reverse pushes) + go !dd pushes ((a, off):cs) = do (push, szb) <- pushAtom dd p a + massert (off == dd + szb) + go (dd + szb) (push:pushes) cs + push_args <- go d [] args_offsets + args_bco <- emitBc (primCallBCO platform args_info args_ptrs) + return $ mconcat push_args `appOL` + (push_target `consOL` + push_info `consOL` + PUSH_BCO args_bco `consOL` + (mkSlideB platform szb (d - s) `appOL` unitOL PRIMCALL)) + -- ----------------------------------------------------------------------------- -- Deal with a CCall. @@ -1259,11 +1354,17 @@ generateCCall -> Type -> [StgArg] -- args (atoms) -> BcM BCInstrList -generateCCall d0 s p (CCallSpec target cconv safety) result_ty args_r_to_l +generateCCall d0 s p (CCallSpec target PrimCallConv _) result_ty args + | (StaticTarget _ label mb_unit _) <- target + = generatePrimCall d0 s p label mb_unit result_ty args + | otherwise + = panic "GHC.StgToByteCode.generateCCall: primcall convention only supports static targets" +generateCCall d0 s p (CCallSpec target cconv safety) result_ty args = do profile <- getProfile let + args_r_to_l = reverse args platform = profilePlatform profile -- useful constants addr_size_b :: ByteOff @@ -2007,7 +2108,7 @@ isSupportedCConv :: CCallSpec -> Bool isSupportedCConv (CCallSpec _ cconv _) = case cconv of CCallConv -> True -- we explicitly pattern match on every StdCallConv -> True -- convention to ensure that a warning - PrimCallConv -> False -- is triggered when a new one is added + PrimCallConv -> True -- is triggered when a new one is added JavaScriptCallConv -> False CApiConv -> True ===================================== compiler/GHC/StgToCmm/Foreign.hs ===================================== @@ -15,8 +15,8 @@ module GHC.StgToCmm.Foreign ( emitLoadThreadState, emitSaveRegs, emitRestoreRegs, - emitPushTupleRegs, - emitPopTupleRegs, + emitPushArgRegs, + emitPopArgRegs, loadThreadState, emitOpenNursery, emitCloseNursery, @@ -349,7 +349,7 @@ emitRestoreRegs = do -- bytecode interpreter. -- -- The "live registers" bitmap corresponds to the list of registers given by --- 'tupleRegsCover', with the least significant bit indicating liveness of +-- 'allArgRegsCover', with the least significant bit indicating liveness of -- the first register in the list. -- -- Each register is saved to a stack slot of one or more machine words, even @@ -362,12 +362,12 @@ emitRestoreRegs = do -- if((mask & 2) != 0) { Sp_adj(-1); Sp(0) = R2; } -- if((mask & 1) != 0) { Sp_adj(-1); Sp(0) = R1; } -- --- See Note [GHCi tuple layout] +-- See Note [GHCi and native call registers] -emitPushTupleRegs :: CmmExpr -> FCode () -emitPushTupleRegs regs_live = do +emitPushArgRegs :: CmmExpr -> FCode () +emitPushArgRegs regs_live = do platform <- getPlatform - let regs = zip (tupleRegsCover platform) [0..] + let regs = zip (allArgRegsCover platform) [0..] save_arg (reg, n) = let mask = CmmLit (CmmInt (1 `shiftL` n) (wordWidth platform)) live = cmmAndWord platform regs_live mask @@ -381,11 +381,11 @@ emitPushTupleRegs regs_live = do in mkCmmIfThen cond $ catAGraphs [adj_sp, save_reg] emit . catAGraphs =<< mapM save_arg (reverse regs) --- | Pop a subset of STG registers from the stack (see 'emitPushTupleRegs') -emitPopTupleRegs :: CmmExpr -> FCode () -emitPopTupleRegs regs_live = do +-- | Pop a subset of STG registers from the stack (see 'emitPushArgRegs') +emitPopArgRegs :: CmmExpr -> FCode () +emitPopArgRegs regs_live = do platform <- getPlatform - let regs = zip (tupleRegsCover platform) [0..] + let regs = zip (allArgRegsCover platform) [0..] save_arg (reg, n) = let mask = CmmLit (CmmInt (1 `shiftL` n) (wordWidth platform)) live = cmmAndWord platform regs_live mask ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -148,6 +148,8 @@ configurePackage context at Context {..} = do -- Figure out what hooks we need. hooks <- case C.buildType (C.flattenPackageDescription gpd) of C.Configure -> pure C.autoconfUserHooks + C.Simple -> pure C.simpleUserHooks + C.Make -> fail "build-type: Make is not supported" -- The 'time' package has a 'C.Custom' Setup.hs, but it's actually -- 'C.Configure' plus a @./Setup test@ hook. However, Cabal is also -- 'C.Custom', but doesn't have a configure script. @@ -155,12 +157,6 @@ configurePackage context at Context {..} = do configureExists <- doesFileExist $ replaceFileName (pkgCabalFile package) "configure" pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks - -- Not quite right, but good enough for us: - _ | package == rts -> - -- Don't try to do post configuration validation for 'rts'. This - -- will simply not work, due to the @ld-options@ and @Stg.h at . - pure $ C.simpleUserHooks { C.postConf = \_ _ _ _ -> return () } - | otherwise -> pure C.simpleUserHooks -- Compute the list of flags, and the Cabal configuration arguments flavourArgs <- args <$> flavour ===================================== hadrian/src/Rules/Register.hs ===================================== @@ -45,6 +45,14 @@ configurePackageRules = do isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend when isGmp $ need [buildP -/- "include/ghc-gmp.h"] + when (pkg == rts) $ do + -- Rts.h is a header listed in the cabal file, and configuring + -- therefore wants to ensure that the header "works" post-configure. + -- But it (transitively) includes these, so we must ensure they exist + -- for that check to work. + need [ buildP -/- "include/ghcautoconf.h" + , buildP -/- "include/ghcplatform.h" + ] Cabal.configurePackage ctx root -/- "**/autogen/cabal_macros.h" %> \out -> do ===================================== rts/Disassembler.c ===================================== @@ -83,6 +83,9 @@ disInstr ( StgBCO *bco, int pc ) debugBelch("CCALL marshaller at 0x%" FMT_HexWord "\n", literals[instrs[pc]] ); pc += 1; break; + case bci_PRIMCALL: + debugBelch("PRIMCALL\n"); + break; case bci_STKCHECK: { StgWord stk_words_reqd = BCO_GET_LARGE_ARG + 1; debugBelch("STKCHECK %" FMT_Word "\n", (W_)stk_words_reqd ); ===================================== rts/Interpreter.c ===================================== @@ -2038,6 +2038,12 @@ run_BCO: goto nextInsn; } + case bci_PRIMCALL: { + Sp_subW(1); + SpW(0) = (W_)&stg_primcall_info; + RETURN_TO_SCHEDULER_NO_PAUSE(ThreadRunGHC, ThreadYielding); + } + case bci_CCALL: { void *tok; int stk_offset = BCO_NEXT; ===================================== rts/RtsSymbols.c ===================================== @@ -602,6 +602,7 @@ extern char **environ; SymI_HasDataProto(stg_ret_l_info) \ SymI_HasDataProto(stg_ret_t_info) \ SymI_HasDataProto(stg_ctoi_t) \ + SymI_HasDataProto(stg_primcall_info) \ SymI_HasDataProto(stg_gc_prim_p) \ SymI_HasDataProto(stg_gc_prim_pp) \ SymI_HasDataProto(stg_gc_prim_n) \ ===================================== rts/StgMiscClosures.cmm ===================================== @@ -366,20 +366,10 @@ MK_STG_CTOI_T(61) MK_STG_CTOI_T(62) /* - Note [GHCi tuple layout] - ~~~~~~~~~~~~~~~~~~~~~~~~ - the tuple_info word describes the register and stack usage of the tuple: + Convert a tuple return value to be used in bytecode. - [ ssss ssss rrrr rrrr rrrr rrrr rrrr rrrr ] - - - r: bitmap of live registers, corresponding to the list of registers - returned by GHC.Cmm.CallConv.tupleRegsCover (the least significant - bit corresponds to the first element in the list) - - s: number of words on stack (in addition to registers) - - The order of the live registers in the bitmap is the same as the list - given by GHC.Cmm.CallConv.tupleRegsCover, with the least significant - bit corresponding to the first register in the list. + See Note [GHCi and native call registers] for information on how + values are moved between the stack and registers. */ stg_ctoi_t @@ -402,7 +392,7 @@ stg_ctoi_t Sp = Sp - WDS(tuple_stack); - PUSH_TUPLE_REGS(tuple_info); + PUSH_ARG_REGS(tuple_info); /* jump to the BCO that will finish the return of the tuple */ Sp_adj(-3); @@ -423,13 +413,57 @@ INFO_TABLE_RET( stg_ret_t, RET_BCO ) /* number of words spilled on stack */ tuple_stack = (tuple_info >> 24) & 0xff; - POP_TUPLE_REGS(tuple_info); + POP_ARG_REGS(tuple_info); /* Sp points to the topmost argument now */ jump %ENTRY_CODE(Sp(tuple_stack)) [*]; // NB. all registers live! } + /* + + The stg_primcall frame is used by the bytecode interpreter to call + a Cmm function. The frame contains a call_info word that contains + a bitmap describing the register arguments. + + When the target function is called, Sp points to the topmost stack + argument. + + ... + next_stack_frame + arg_1 + arg_2 + ... + arg_n + target_funptr (pointer to the function we're calling) + call_info (describes the registers containing the arguments) + primcall_BCO (contains bitmap describing pointers in args) + stg_primcall_info <- Sp + + See Note [GHCi and native call registers] for information on the call_info + word and how registers are moved between the stack and registers. + + */ + +INFO_TABLE_RET ( stg_primcall, RET_BCO ) +{ + W_ args_info, prim_fun; + + /* Sp(1) would be the BCO containing the stack description bitmap */ + args_info = Sp(2); + prim_fun = Sp(3); + + Sp_adj(4); + + /* Sp points to the top of the register arguments now, + load them into actual registers */ + POP_ARG_REGS(args_info); + + /* Sp points to the topmost stack argument now */ + + jump prim_fun [*]; // NB. all registers live! +} + /* * Dummy info table pushed on the top of the stack when the interpreter * should apply the BCO on the stack to its arguments, also on the ===================================== rts/include/rts/Bytecodes.h ===================================== @@ -112,6 +112,8 @@ #define bci_TESTLT_W8 85 #define bci_TESTEQ_W8 86 +#define bci_PRIMCALL 87 + /* If you need to go past 255 then you will run into the flags */ /* If you need to go below 0x0100 then you will run into the instructions */ ===================================== rts/include/stg/MiscClosures.h ===================================== @@ -160,6 +160,7 @@ RTS_RET(stg_ctoi_t60); RTS_RET(stg_ctoi_t61); RTS_RET(stg_ctoi_t62); +RTS_RET(stg_primcall); RTS_RET(stg_apply_interp); RTS_RET(stg_dead_thread); ===================================== rts/rts.cabal.in ===================================== @@ -275,6 +275,8 @@ library stg/SMP.h stg/Ticky.h stg/Types.h + + -- See Note [Undefined symbols in the RTS] if flag(64bit) if flag(leading-underscore) ld-options: @@ -474,6 +476,8 @@ library ld-options: "-Wl,-search_paths_first" -- See Note [fd_set_overflow] "-Wl,-U,___darwin_check_fd_set_overflow" + -- See Note [Undefined symbols in the RTS] + "-Wl,-undefined,dynamic_lookup" if !arch(x86_64) && !arch(aarch64) ld-options: -read_only_relocs warning @@ -714,3 +718,35 @@ library -- , https://github.com/sitsofe/fio/commit/b6a1e63a1ff607692a3caf3c2db2c3d575ba2320 -- The issue was originally reported in #19950 + + +-- Note [Undefined symbols in the RTS] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- The RTS is built with a number of `-u` flags. This is to handle cyclic +-- dependencies between the RTS and other libraries which we normally think of as +-- downstream from the RTS. "Regular" dependencies from usages in those libraries +-- to definitions in the RTS are handled normally. "Reverse" dependencies from +-- usages in the RTS to definitions in those libraries get the `-u` flag in the +-- RTS. +-- +-- The symbols are specified literally, but follow C ABI conventions (as all 3 of +-- C, C--, and Haskell do currently). Thus, we have to be careful to include a +-- leading underscore or not based on those conventions for the given platform in +-- question. +-- +-- A tricky part is that different linkers have different policies regarding +-- undefined symbols (not defined in the current binary, or found in a shared +-- library that could be loaded at run time). GNU Binutils' linker is fine with +-- undefined symbols by default, but Apple's "cctools" linker is not. To appease +-- that linker we either need to do a blanket `-undefined dynamic_lookup` or +-- whitelist each such symbol with an additional `-U` (see the man page for more +-- details). +-- +-- GHC already does `-undefined dynamic_lookup`, so we just do that for now, but +-- we might try to get more precise with `-U` in the future. +-- +-- Note that the RTS also `-u`s some atomics symbols that *are* defined --- and +-- defined within the RTS! It is not immediately clear why this is needed. This +-- dates back to c06e3f46d24ef69f3a3d794f5f604cb8c2a40cbc which mentions a build +-- failure that it was suggested that this fix, but the precise reasoning is not +-- explained. ===================================== testsuite/tests/ghci/prog014/prog014.T ===================================== @@ -1,6 +1,5 @@ test('prog014', [extra_files(['Primop.hs', 'dummy.c']), - expect_fail, # bytecode compiler doesn't support foreign import prim extra_run_opts('dummy.o'), pre_cmd('$MAKE -s --no-print-directory prog014')], ghci_script, ['prog014.script']) ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs ===================================== @@ -0,0 +1,279 @@ +{-# LANGUAGE ForeignFunctionInterface, GHCForeignImportPrim, UnliftedFFITypes, MagicHash, UnboxedTuples #-} + +module Main where + +import GHC.Int +import GHC.Word +import GHC.Prim +import GHC.Exts +import GHC.Types +import Unsafe.Coerce +import GHC.IO + +data Box (a :: UnliftedType) = MkBox a + +i2a :: Int -> Any +i2a = unsafeCoerce + +a2i :: Any -> Int +a2i = unsafeCoerce + +main :: IO () +main = do + + let i8s :: [Int8] + i8s = [0, -1, 1, minBound, maxBound] + + i16s :: [Int16] + i16s = [0, -1, 1, minBound, maxBound] + + i32s :: [Int32] + i32s = [0, -1, 1, minBound, maxBound] + + i64s :: [Int64] + i64s = [0, -1, 1, minBound, maxBound] + + ws :: [Word] + ws = [0, 1, 2, maxBound] + + fs :: [Float] + fs = [-0, 0, -1, 1, -2, 2, 1/0, 1e37, -1e-37] + + ds :: [Double] + ds = [-0, 0, -1, 1, -2, 2, 1/0, 1e307, -1e-307] + + ls :: [Word64] + ls = [0, 1, 2, 4294967296, maxBound] + + mi2a :: Maybe Integer -> Any + mi2a = unsafeCoerce + + a2mi :: Any -> Maybe Integer + a2mi = unsafeCoerce + + a0, a1, a2, a3 :: Any + a0 = mi2a Nothing + a1 = mi2a (Just 1) + a2 = mi2a (Just 18446744073709551617) + a3 = mi2a (Just (-18446744073709551617)) + + as :: [Any] + as = [a0, a1, a2, a3] + + + putStrLn "zero arguments" + IO (\st -> case cmm_zero st of (# st' #) -> (# st', () #)) + print =<< IO (\st -> case cmm_zero_w st of (# st', w #) -> (# st', W# w #)) + print =<< IO (\st -> case cmm_zero_d st of (# st', w #) -> (# st', D# w #)) + print =<< IO (\st -> case cmm_zero_f st of (# st', w #) -> (# st', F# w #)) + + -- XXX zero argument functions + + putStrLn "one argument functions" + print [ I8# (cmm_one1_i8 x) | (I8# x) <- i8s ] + print [ I16# (cmm_one1_i16 x) | (I16# x) <- i16s ] + print [ I32# (cmm_one1_i32 x) | (I32# x) <- i32s ] + print [ I64# (cmm_one1_i64 x) | (I64# x) <- i64s ] + print [ case cmm_one1_p x of (# y #) -> a2mi y | x <- as ] + print [ W# (cmm_one1_w x) | (W# x) <- ws ] + print [ F# (cmm_one1_f x) | (F# x) <- fs ] + print [ D# (cmm_one1_d x) | (D# x) <- ds ] + print [ W64# (cmm_one1_l x) | (W64# x) <- ls ] + + print [ case cmm_one2_i8 x of (# y1, y2 #) -> (I8# y1, I8# y2) | (I8# x) <- i8s ] + print [ case cmm_one2_i16 x of (# y1, y2 #) -> (I16# y1, I16# y2) | (I16# x) <- i16s ] + print [ case cmm_one2_i32 x of (# y1, y2 #) -> (I32# y1, I32# y2) | (I32# x) <- i32s ] + print [ case cmm_one2_i64 x of (# y1, y2 #) -> (I64# y1, I64# y2) | (I64# x) <- i64s ] + print [ case cmm_one2_p x of (# y1, y2 #) -> (a2mi y1, a2mi y2) | x <- as ] + print [ case cmm_one2_w x of (# y1, y2 #) -> (W# y1, W# y2) | (W# x) <- ws ] + print [ case cmm_one2_f x of (# y1, y2 #) -> (F# y1, F# y2) | (F# x) <- fs ] + print [ case cmm_one2_d x of (# y1, y2 #) -> (D# y1, D# y2) | (D# x) <- ds ] + print [ case cmm_one2_l x of (# y1, y2 #) -> (W64# y1, W64# y2) | (W64# x) <- ls ] + + putStrLn "two argument functions" + print [ I8# (cmm_two1_i8 x1 x2) | (I8# x1) <- i8s, (I8# x2) <- i8s ] + print [ I16# (cmm_two1_i16 x1 x2) | (I16# x1) <- i16s, (I16# x2) <- i16s ] + print [ I32# (cmm_two1_i32 x1 x2) | (I32# x1) <- i32s, (I32# x2) <- i32s ] + print [ I64# (cmm_two1_i64 x1 x2) | (I64# x1) <- i64s, (I64# x2) <- i64s ] + print [ case cmm_two1_p x1 x2 of (# y #) -> a2mi y | x1 <- as, x2 <- as ] + print [ W# (cmm_two1_w x1 x2) | (W# x1) <- ws, (W# x2) <- ws ] + print [ F# (cmm_two1_f x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_two1_d x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ W64# (cmm_two1_l x1 x2) | (W64# x1) <- ls, (W64# x2) <- ls ] + + print [ I8# (cmm_two2_i8 x1 x2) | (I8# x1) <- i8s, (I8# x2) <- i8s ] + print [ I16# (cmm_two2_i16 x1 x2) | (I16# x1) <- i16s, (I16# x2) <- i16s ] + print [ I32# (cmm_two2_i32 x1 x2) | (I32# x1) <- i32s, (I32# x2) <- i32s ] + print [ I64# (cmm_two2_i64 x1 x2) | (I64# x1) <- i64s, (I64# x2) <- i64s ] + print [ case cmm_two2_p x1 x2 of (# y #) -> a2mi y | x1 <- as, x2 <- as ] + print [ W# (cmm_two2_w x1 x2) | (W# x1) <- ws, (W# x2) <- ws ] + print [ F# (cmm_two2_f x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_two2_d x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ W64# (cmm_two2_l x1 x2) | (W64# x1) <- ls, (W64# x2) <- ls ] + + putStrLn "additional floating point tests" + print [ F# (cmm_floating_1 x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_floating_2 x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ F# (cmm_floating_3 x1 x2) | (F# x1) <- fs, (D# x2) <- ds ] + print [ D# (cmm_floating_4 x1 x2) | (F# x1) <- fs, (D# x2) <- ds ] + print [ case cmm_floating_5 x1 x2 3.0e1# 4.0e2## 5.0e3# 6.0e4## 7.0e5# 8.0e6## of (# y1, y2 #) -> (F# y1, D# y2) + | (F# x1) <- fs, (D# x2) <- ds ] + print [ case cmm_floating_6 x1 x2 3.0e1## 4.0e2# 5.0e3## 6.0e4# 7.0e5## 8.0e6# of (# y1, y2 #) -> (D# y1, F# y2) + | (D# x1) <- ds, (F# x2) <- fs ] + print [ case cmm_floating_7 w1 x1 x2 + 4## 5.0e1# 6.0e2## + 7## 8.0e3# 9.0e4## + 10## 11.0e5# 12.0e6## + 13## 14.0e7# 15.0e8## + 16## 17.0e9# 18.0e10## + 19## 20.0e11# 21.0e12## of (# y1, y2, y3 #) -> (W# y1, F# y2, D# y3) + | (W# w1) <- ws, (F# x1) <- fs, (D# x2) <- ds ] + + putStrLn "various sized tuple returns" + print [ case cmm_tuple_1 x1 x2 3## of (# y1, y2, y3 #) -> (W# y1, W# y2, W# y3) | (W# x1) <- ws, (W# x2) <- ws] + print [ case cmm_tuple_2 x1 x2 3## 4## a0 a1 7.0## 8.0## a2 a3 11.0# 12.0# + of (# y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12 #) -> + (F# y1, F# y2, a2mi y3, a2mi y4, D# y5, D# y6, a2mi y7, a2mi y8, W# y9, W# y10, a2mi y11, a2mi y12) + | x1 <- as, x2 <- as ] + print [ case cmm_tuple_3 x1 x2 a0 3.0## a1 5.0# + of (# y1, y2, y3, y4, y5, y6 #) -> (F# y1, a2mi y2, D# y3, a2mi y4, W# y5, a2mi y6) + | x1 <- as, (W# x2) <- ws ] + print [ case cmm_tuple_4 x1 x2 of (# y1, y2 #) -> (a2mi y1, a2mi y2) | x1 <- as, x2 <- as ] + + putStrLn "arrays" + MkBox marr0 <- IO (\s -> case newArray# 10# a0 s of (# s', a #) -> (# s', MkBox a #)) + MkBox marr1 <- IO (\s -> case newArray# 12# a1 s of (# s', a #) -> (# s', MkBox a #)) + MkBox arr0 <- IO (\s -> case unsafeFreezeArray# marr0 s of (# s', a #) -> (# s', MkBox a #)) + MkBox arr1 <- IO (\s -> case unsafeFreezeArray# marr1 s of (# s', a #) -> (# s', MkBox a #)) + print (I# (cmm_array_1 arr0), I# (cmm_array_1 arr1)) + case cmm_array_2 arr0 arr1 of (# arr2, arr3 #) -> print (I# (cmm_array_1 arr2), I# (cmm_array_1 arr3)) + + putStrLn "many arguments" + print (W# (cmm_many_arguments 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## 65## 66## 67## 68## 69## 70## 71## 72## 73## 74## 75## 76## 77## 78## 79## 80## 81## 82## 83## 84## 85## 86## 87## 88## 89## 90## 91## 92## 93## 94## 95## 96## 97## 98## 99## 100## 101## 102## 103## 104## 105## 106## 107## 108## 109## 110## 111## 112## 113## 114## 115## 116## 117## 118## 119## 120## 121## 122## 123## 124## 125## 126## 127## 128## 129## 130## 131## 132## 133## 134## 135## 136## 137## 138## 139## 140## 141## 142## 143## 144## 145## 146## 147## 148## 149## 150## 151## 152## 153## 154## 155## 156## 157## 158## 159## 160## 161## 162## 163## 164## 165## 166## 167## 168## 169## 170## 171## 172## 173## 174## 175## 176## 177## 178## 179## 180## 181## 182## 183## 184## 185## 186## 187## 188## 189## 190## 191## 192## 193## 194## 195## 196## 197## 198## 199## 200## 201## 202## 203## 204## 205## 206## 207## 208## 209## 210## 211## 212## 213## 214## 215## 216## 217## 218## 219## 220## 221## 222## 223## 224## 225## 226## 227## 228## 229## 230## 231## 232## 233## 234## 235## 236## 237## 238## 239## 240## 241## 242## 243## 244## 245## 246## 247## 248## 249## 250## 251## 252## 253## 254## 255## 256## 257## 258## 259## 260## 261## 262## 263## 264## 265## 266## 267## 268## 269## 270## 271## 272## 273## 274## 275## 276## 277## 278## 279## 280## 281## 282## 283## 284## 285## 286## 287## 288## 289## 290## 291## 292## 293## 294## 295## 296## 297## 298## 299## 300## 301## 302## 303## 304## 305## 306## 307## 308## 309## 310## 311## 312## 313## 314## 315## 316## 317## 318## 319## 320## 321## 322## 323## 324## 325## 326## 327## 328## 329## 330## 331## 332## 333## 334## 335## 336## 337## 338## 339## 340## 341## 342## 343## 344## 345## 346## 347## 348## 349## 350## 351## 352## 353## 354## 355## 356## 357## 358## 359## 360## 361## 362## 363## 364## 365## 366## 367## 368## 369## 370## 371## 372## 373## 374## 375## 376## 377## 378## 379## 380## 381## 382## 383## 384## 385## 386## 387## 388## 389## 390## 391## 392## 393## 394## 395## 396## 397## 398## 399## 400##)) + +-- XXX why don't we accept State# RealWorld -> State# RealWorld ? +foreign import prim cmm_zero :: State# RealWorld -> (# State# RealWorld #) +foreign import prim cmm_zero_w :: State# RealWorld -> (# State# RealWorld, Word# #) +foreign import prim cmm_zero_d :: State# RealWorld -> (# State# RealWorld, Double# #) +foreign import prim cmm_zero_f :: State# RealWorld -> (# State# RealWorld, Float# #) + +-- one argument functions +foreign import prim cmm_one1_i8 :: Int8# -> Int8# +foreign import prim cmm_one1_i16 :: Int16# -> Int16# +foreign import prim cmm_one1_i32 :: Int32# -> Int32# +foreign import prim cmm_one1_i64 :: Int64# -> Int64# +foreign import prim cmm_one1_p :: Any -> (# Any #) +foreign import prim cmm_one1_w :: Word# -> Word# +foreign import prim cmm_one1_f :: Float# -> Float# +foreign import prim cmm_one1_d :: Double# -> Double# +foreign import prim cmm_one1_l :: Word64# -> Word64# + +foreign import prim cmm_one2_i8 :: Int8# -> (# Int8#, Int8# #) +foreign import prim cmm_one2_i16 :: Int16# -> (# Int16#, Int16# #) +foreign import prim cmm_one2_i32 :: Int32# -> (# Int32#, Int32# #) +foreign import prim cmm_one2_i64 :: Int64# -> (# Int64#, Int64# #) +foreign import prim cmm_one2_p :: Any -> (# Any, Any #) +foreign import prim cmm_one2_w :: Word# -> (# Word#, Word# #) +foreign import prim cmm_one2_f :: Float# -> (# Float#, Float# #) +foreign import prim cmm_one2_d :: Double# -> (# Double#, Double# #) +foreign import prim cmm_one2_l :: Word64# -> (# Word64#, Word64# #) + +-- two argument functions +foreign import prim cmm_two1_i8 :: Int8# -> Int8# -> Int8# +foreign import prim cmm_two1_i16 :: Int16# -> Int16# -> Int16# +foreign import prim cmm_two1_i32 :: Int32# -> Int32# -> Int32# +foreign import prim cmm_two1_i64 :: Int64# -> Int64# -> Int64# +foreign import prim cmm_two1_p :: Any -> Any -> (# Any #) +foreign import prim cmm_two1_w :: Word# -> Word# -> Word# +foreign import prim cmm_two1_f :: Float# -> Float# -> Float# +foreign import prim cmm_two1_d :: Double# -> Double# -> Double# +foreign import prim cmm_two1_l :: Word64# -> Word64# -> Word64# + +foreign import prim cmm_two2_i8 :: Int8# -> Int8# -> Int8# +foreign import prim cmm_two2_i16 :: Int16# -> Int16# -> Int16# +foreign import prim cmm_two2_i32 :: Int32# -> Int32# -> Int32# +foreign import prim cmm_two2_i64 :: Int64# -> Int64# -> Int64# +foreign import prim cmm_two2_p :: Any -> Any -> (# Any #) +foreign import prim cmm_two2_w :: Word# -> Word# -> Word# +foreign import prim cmm_two2_f :: Float# -> Float# -> Float# +foreign import prim cmm_two2_d :: Double# -> Double# -> Double# +foreign import prim cmm_two2_l :: Word64# -> Word64# -> Word64# + +{- additional tests for floating point, since D_ and F_ registers + overlap on some platforms -} + +foreign import prim cmm_floating_1 :: Float# -> Float# -> Float# +foreign import prim cmm_floating_2 :: Double# -> Double# -> Double# +foreign import prim cmm_floating_3 :: Float# -> Double# -> Float# +foreign import prim cmm_floating_4 :: Float# -> Double# -> Double# +foreign import prim cmm_floating_5 :: Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> (# Float#, Double# #) +foreign import prim cmm_floating_6 :: Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> (# Double#, Float# #) +foreign import prim cmm_floating_7 :: Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> (# Word#, Float#, Double# #) +-- various sized tuple returns + +foreign import prim cmm_tuple_1 :: Word# -> Word# -> Word# -> (# Word# , Word#, Word# #) +foreign import prim cmm_tuple_2 :: Any -> Any -> Word# -> Word# -> Any -> Any -> Double# -> Double# -> Any -> Any -> Float# -> Float# -> + (# Float#, Float#, Any, Any, Double#, Double#, Any, Any, Word#, Word#, Any, Any #) +foreign import prim cmm_tuple_3 :: Any -> Word# -> Any -> Double# -> Any -> Float# -> + (# Float#, Any, Double#, Any, Word#, Any #) +foreign import prim cmm_tuple_4 :: Any -> Any -> (# Any, Any #) + +-- boxed primitive types + +-- get the length of an array +foreign import prim cmm_array_1 :: Array# Any -> Int# +-- return some arrays +foreign import prim cmm_array_2 :: Array# Any -> Array# Any -> (# Array# Any, Array# Any #) + +foreign import prim cmm_many_arguments :: + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout ===================================== @@ -0,0 +1,60 @@ +zero arguments +123 +1.0 +1.0 +one argument functions +[0,-1,1,-128,127] +[0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,18446744073709551615] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615] +[(0,0),(-1,-1),(1,1),(-128,-128),(127,127)] +[(0,0),(-1,-1),(1,1),(-32768,-32768),(32767,32767)] +[(0,0),(-1,-1),(1,1),(-2147483648,-2147483648),(2147483647,2147483647)] +[(0,0),(-1,-1),(1,1),(-9223372036854775808,-9223372036854775808),(9223372036854775807,9223372036854775807)] +[(Nothing,Nothing),(Just 1,Just 1),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just (-18446744073709551617))] +[(0,0),(1,1),(2,2),(18446744073709551615,18446744073709551615)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e37,1.0e37),(-1.0e-37,-1.0e-37)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e307,1.0e307),(-1.0e-307,-1.0e-307)] +[(0,0),(1,1),(2,2),(4294967296,4294967296),(18446744073709551615,18446744073709551615)] +two argument functions +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-128,-128,-128,-128,-128,127,127,127,127,127] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-32768,-32768,-32768,-32768,-32768,32767,32767,32767,32767,32767] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,2147483647,2147483647,2147483647,2147483647,2147483647] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807] +[Nothing,Nothing,Nothing,Nothing,Just 1,Just 1,Just 1,Just 1,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617)] +[0,0,0,0,1,1,1,1,2,2,2,2,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307] +[0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,4294967296,4294967296,4294967296,4294967296,4294967296,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127] +[0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,18446744073709551615,0,1,2,18446744073709551615,0,1,2,18446744073709551615,0,1,2,18446744073709551615] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615] +additional floating point tests +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e37,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e37,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e37,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e37,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,Infinity,2.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-2.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e307,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e307,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e307,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e307,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,Infinity,2.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-2.0e-307] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e307),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e307),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e307),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e307),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e307),(Infinity,8060400.0),(1.0e37,8060400.0),(1.0e37,8060400.0),(1.0e37,8060399.0),(1.0e37,8060401.0),(1.0e37,8060398.0),(1.0e37,8060402.0),(1.0e37,Infinity),(1.0e37,1.0e307),(1.0e37,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0)] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e37),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e37),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e37),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e37),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e37),(Infinity,8060400.0),(1.0e307,8060400.0),(1.0e307,8060400.0),(1.0e307,8060399.0),(1.0e307,8060401.0),(1.0e307,8060398.0),(1.0e307,8060402.0),(1.0e307,Infinity),(1.0e307,1.0e37),(1.0e307,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0)] +[(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.1181512090599e13),(69,Infinity,2.1181512090601e13),(69,Infinity,2.1181512090598e13),(69,Infinity,2.1181512090602e13),(69,Infinity,Infinity),(69,Infinity,1.0e307),(69,Infinity,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.1181512090599e13),(69,1.0e37,2.1181512090601e13),(69,1.0e37,2.1181512090598e13),(69,1.0e37,2.1181512090602e13),(69,1.0e37,Infinity),(69,1.0e37,1.0e307),(69,1.0e37,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.1181512090599e13),(70,Infinity,2.1181512090601e13),(70,Infinity,2.1181512090598e13),(70,Infinity,2.1181512090602e13),(70,Infinity,Infinity),(70,Infinity,1.0e307),(70,Infinity,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.1181512090599e13),(70,1.0e37,2.1181512090601e13),(70,1.0e37,2.1181512090598e13),(70,1.0e37,2.1181512090602e13),(70,1.0e37,Infinity),(70,1.0e37,1.0e307),(70,1.0e37,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.1181512090599e13),(71,Infinity,2.1181512090601e13),(71,Infinity,2.1181512090598e13),(71,Infinity,2.1181512090602e13),(71,Infinity,Infinity),(71,Infinity,1.0e307),(71,Infinity,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.1181512090599e13),(71,1.0e37,2.1181512090601e13),(71,1.0e37,2.1181512090598e13),(71,1.0e37,2.1181512090602e13),(71,1.0e37,Infinity),(71,1.0e37,1.0e307),(71,1.0e37,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.1181512090599e13),(68,Infinity,2.1181512090601e13),(68,Infinity,2.1181512090598e13),(68,Infinity,2.1181512090602e13),(68,Infinity,Infinity),(68,Infinity,1.0e307),(68,Infinity,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.1181512090599e13),(68,1.0e37,2.1181512090601e13),(68,1.0e37,2.1181512090598e13),(68,1.0e37,2.1181512090602e13),(68,1.0e37,Infinity),(68,1.0e37,1.0e307),(68,1.0e37,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13)] +various sized tuple returns +[(3,0,0),(3,1,0),(3,2,0),(3,18446744073709551615,0),(3,0,1),(3,1,1),(3,2,1),(3,18446744073709551615,1),(3,0,2),(3,1,2),(3,2,2),(3,18446744073709551615,2),(3,0,18446744073709551615),(3,1,18446744073709551615),(3,2,18446744073709551615),(3,18446744073709551615,18446744073709551615)] +[(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just (-18446744073709551617))] +[(5.0,Just 1,3.0,Nothing,0,Nothing),(5.0,Just 1,3.0,Nothing,1,Nothing),(5.0,Just 1,3.0,Nothing,2,Nothing),(5.0,Just 1,3.0,Nothing,18446744073709551615,Nothing),(5.0,Just 1,3.0,Nothing,0,Just 1),(5.0,Just 1,3.0,Nothing,1,Just 1),(5.0,Just 1,3.0,Nothing,2,Just 1),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just 1),(5.0,Just 1,3.0,Nothing,0,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,1,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,2,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,0,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,1,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,2,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just (-18446744073709551617))] +[(Nothing,Nothing),(Just 1,Nothing),(Just 18446744073709551617,Nothing),(Just (-18446744073709551617),Nothing),(Nothing,Just 1),(Just 1,Just 1),(Just 18446744073709551617,Just 1),(Just (-18446744073709551617),Just 1),(Nothing,Just 18446744073709551617),(Just 1,Just 18446744073709551617),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just 18446744073709551617),(Nothing,Just (-18446744073709551617)),(Just 1,Just (-18446744073709551617)),(Just 18446744073709551617,Just (-18446744073709551617)),(Just (-18446744073709551617),Just (-18446744073709551617))] +arrays +(11,13) +(13,11) +many arguments +80200 ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout-ws-32 ===================================== @@ -0,0 +1,60 @@ +zero arguments +123 +1.0 +1.0 +one argument functions +[0,-1,1,-128,127] +[0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,4294967295] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615] +[(0,0),(-1,-1),(1,1),(-128,-128),(127,127)] +[(0,0),(-1,-1),(1,1),(-32768,-32768),(32767,32767)] +[(0,0),(-1,-1),(1,1),(-2147483648,-2147483648),(2147483647,2147483647)] +[(0,0),(-1,-1),(1,1),(-9223372036854775808,-9223372036854775808),(9223372036854775807,9223372036854775807)] +[(Nothing,Nothing),(Just 1,Just 1),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just (-18446744073709551617))] +[(0,0),(1,1),(2,2),(4294967295,4294967295)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e37,1.0e37),(-1.0e-37,-1.0e-37)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e307,1.0e307),(-1.0e-307,-1.0e-307)] +[(0,0),(1,1),(2,2),(4294967296,4294967296),(18446744073709551615,18446744073709551615)] +two argument functions +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-128,-128,-128,-128,-128,127,127,127,127,127] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-32768,-32768,-32768,-32768,-32768,32767,32767,32767,32767,32767] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,2147483647,2147483647,2147483647,2147483647,2147483647] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807] +[Nothing,Nothing,Nothing,Nothing,Just 1,Just 1,Just 1,Just 1,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617)] +[0,0,0,0,1,1,1,1,2,2,2,2,4294967295,4294967295,4294967295,4294967295] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307] +[0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,4294967296,4294967296,4294967296,4294967296,4294967296,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127] +[0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,4294967295,0,1,2,4294967295,0,1,2,4294967295,0,1,2,4294967295] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615] +additional floating point tests +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e37,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e37,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e37,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e37,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,Infinity,2.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-2.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e307,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e307,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e307,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e307,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,Infinity,2.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-2.0e-307] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e307),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e307),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e307),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e307),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e307),(Infinity,8060400.0),(1.0e37,8060400.0),(1.0e37,8060400.0),(1.0e37,8060399.0),(1.0e37,8060401.0),(1.0e37,8060398.0),(1.0e37,8060402.0),(1.0e37,Infinity),(1.0e37,1.0e307),(1.0e37,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0)] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e37),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e37),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e37),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e37),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e37),(Infinity,8060400.0),(1.0e307,8060400.0),(1.0e307,8060400.0),(1.0e307,8060399.0),(1.0e307,8060401.0),(1.0e307,8060398.0),(1.0e307,8060402.0),(1.0e307,Infinity),(1.0e307,1.0e37),(1.0e307,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0)] +[(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.1181512090599e13),(69,Infinity,2.1181512090601e13),(69,Infinity,2.1181512090598e13),(69,Infinity,2.1181512090602e13),(69,Infinity,Infinity),(69,Infinity,1.0e307),(69,Infinity,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.1181512090599e13),(69,1.0e37,2.1181512090601e13),(69,1.0e37,2.1181512090598e13),(69,1.0e37,2.1181512090602e13),(69,1.0e37,Infinity),(69,1.0e37,1.0e307),(69,1.0e37,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.1181512090599e13),(70,Infinity,2.1181512090601e13),(70,Infinity,2.1181512090598e13),(70,Infinity,2.1181512090602e13),(70,Infinity,Infinity),(70,Infinity,1.0e307),(70,Infinity,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.1181512090599e13),(70,1.0e37,2.1181512090601e13),(70,1.0e37,2.1181512090598e13),(70,1.0e37,2.1181512090602e13),(70,1.0e37,Infinity),(70,1.0e37,1.0e307),(70,1.0e37,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.1181512090599e13),(71,Infinity,2.1181512090601e13),(71,Infinity,2.1181512090598e13),(71,Infinity,2.1181512090602e13),(71,Infinity,Infinity),(71,Infinity,1.0e307),(71,Infinity,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.1181512090599e13),(71,1.0e37,2.1181512090601e13),(71,1.0e37,2.1181512090598e13),(71,1.0e37,2.1181512090602e13),(71,1.0e37,Infinity),(71,1.0e37,1.0e307),(71,1.0e37,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.1181512090599e13),(68,Infinity,2.1181512090601e13),(68,Infinity,2.1181512090598e13),(68,Infinity,2.1181512090602e13),(68,Infinity,Infinity),(68,Infinity,1.0e307),(68,Infinity,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.1181512090599e13),(68,1.0e37,2.1181512090601e13),(68,1.0e37,2.1181512090598e13),(68,1.0e37,2.1181512090602e13),(68,1.0e37,Infinity),(68,1.0e37,1.0e307),(68,1.0e37,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13)] +various sized tuple returns +[(3,0,0),(3,1,0),(3,2,0),(3,4294967295,0),(3,0,1),(3,1,1),(3,2,1),(3,4294967295,1),(3,0,2),(3,1,2),(3,2,2),(3,4294967295,2),(3,0,4294967295),(3,1,4294967295),(3,2,4294967295),(3,4294967295,4294967295)] +[(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just (-18446744073709551617))] +[(5.0,Just 1,3.0,Nothing,0,Nothing),(5.0,Just 1,3.0,Nothing,1,Nothing),(5.0,Just 1,3.0,Nothing,2,Nothing),(5.0,Just 1,3.0,Nothing,4294967295,Nothing),(5.0,Just 1,3.0,Nothing,0,Just 1),(5.0,Just 1,3.0,Nothing,1,Just 1),(5.0,Just 1,3.0,Nothing,2,Just 1),(5.0,Just 1,3.0,Nothing,4294967295,Just 1),(5.0,Just 1,3.0,Nothing,0,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,1,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,2,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,4294967295,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,0,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,1,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,2,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,4294967295,Just (-18446744073709551617))] +[(Nothing,Nothing),(Just 1,Nothing),(Just 18446744073709551617,Nothing),(Just (-18446744073709551617),Nothing),(Nothing,Just 1),(Just 1,Just 1),(Just 18446744073709551617,Just 1),(Just (-18446744073709551617),Just 1),(Nothing,Just 18446744073709551617),(Just 1,Just 18446744073709551617),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just 18446744073709551617),(Nothing,Just (-18446744073709551617)),(Just 1,Just (-18446744073709551617)),(Just 18446744073709551617,Just (-18446744073709551617)),(Just (-18446744073709551617),Just (-18446744073709551617))] +arrays +(11,13) +(13,11) +many arguments +80200 ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm ===================================== @@ -0,0 +1,230 @@ +#include "Cmm.h" + +/* zero arguments */ +cmm_zero() { /* ccall puts("cmm_zero"); buffering gets in the way */ return (); } +cmm_zero_w() { return (123::W_); } +cmm_zero_d() { return (1.0::D_); } +cmm_zero_f() { return (1.0::F_); } +cmm_zero_l() { return (123::L_); } + +/* one argument functions */ +cmm_one1_i8(I8 x) { return (x); } +cmm_one1_i16(I16 x) { return (x); } +cmm_one1_i32(I32 x) { return (x); } +cmm_one1_i64(I64 x) { return (x); } +cmm_one1_p(P_ x) { return (x); } +cmm_one1_w(W_ x) { return (x); } +cmm_one1_f(F_ x) { return (x); } +cmm_one1_d(D_ x) { return (x); } +cmm_one1_l(L_ x) { return (x); } + +cmm_one2_i8(I8 x) { return (x,x); } +cmm_one2_i16(I16 x) { return (x,x); } +cmm_one2_i32(I32 x) { return (x,x); } +cmm_one2_i64(I64 x) { return (x,x); } +cmm_one2_p(P_ x) { return (x,x); } +cmm_one2_w(W_ x) { return (x,x); } +cmm_one2_f(F_ x) { return (x,x); } +cmm_one2_d(D_ x) { return (x,x); } +cmm_one2_l(L_ x) { return (x,x); } + + +/* two argument functions */ +cmm_two1_i8(I8 x, I8 y) { return (x); } +cmm_two1_i16(I16 x, I16 y) { return (x); } +cmm_two1_i32(I32 x, I32 y) { return (x); } +cmm_two1_i64(I64 x, I64 y) { return (x); } +cmm_two1_p(P_ x, P_ y) { return (x); } +cmm_two1_w(W_ x, W_ y) { return (x); } +cmm_two1_f(F_ x, F_ y) { return (x); } +cmm_two1_d(D_ x, D_ y) { return (x); } +cmm_two1_l(L_ x, L_ y) { return (x); } + +cmm_two2_i8(I8 x, I8 y) { return (y); } +cmm_two2_i16(I16 x, I16 y) { return (y); } +cmm_two2_i32(I32 x, I32 y) { return (y); } +cmm_two2_i64(I64 x, I64 y) { return (y); } +cmm_two2_p(P_ x, P_ y) { return (y); } +cmm_two2_w(W_ x, W_ y) { return (y); } +cmm_two2_f(F_ x, F_ y) { return (y); } +cmm_two2_d(D_ x, D_ y) { return (y); } +cmm_two2_l(L_ x, L_ y) { return (y); } + +/* additional tests for floating point, since D_ and F_ registers + overlap on some platforms */ +cmm_floating_1(F_ x, F_ y) { F_ z; z = %fadd(x, y); return (z); } +cmm_floating_2(D_ x, D_ y) { D_ z; z = %fadd(x, y); return (z); } +cmm_floating_3(F_ x, D_ y) { return (x); } +cmm_floating_4(F_ x, D_ y) { return (y); } + + +cmm_floating_5(F_ x1, D_ x2, F_ x3, D_ x4, F_ x5, D_ x6, F_ x7, D_ x8) { + F_ y1; + D_ y2; + + y1 = %fadd(x1,x3); + y1 = %fadd(y1,x5); + y1 = %fadd(y1,x7); + + y2 = %fadd(x2,x4); + y2 = %fadd(y2,x6); + y2 = %fadd(y2,x8); + + return (y1, y2); +} + + +cmm_floating_6(D_ x1, F_ x2, D_ x3, F_ x4, D_ x5, F_ x6, D_ x7, F_ x8) { + D_ y1; + F_ y2; + + y1 = %fadd(x1,x3); + y1 = %fadd(y1,x5); + y1 = %fadd(y1,x7); + + y2 = %fadd(x2,x4); + y2 = %fadd(y2,x6); + y2 = %fadd(y2,x8); + + return (y1, y2); +} + + +cmm_floating_7( W_ x1, F_ x2, D_ x3 + , W_ x4, F_ x5, D_ x6 + , W_ x7, F_ x8, D_ x9 + , W_ x10, F_ x11, D_ x12 + , W_ x13, F_ x14, D_ x15 + , W_ x16, F_ x17, D_ x18 + , W_ x19, F_ x20, D_ x21 + ) { + W_ y1; + F_ y2; + D_ y3; + y1 = x1+x4+x7+x10+x13+x16+x19; + + y2 = %fadd(x2,x5); + y2 = %fadd(y2,x8); + y2 = %fadd(y2,x11); + y2 = %fadd(y2,x14); + y2 = %fadd(y2,x17); + y2 = %fadd(y2,x20); + + y3 = %fadd(x3,x6); + y3 = %fadd(y3,x9); + y3 = %fadd(y3,x12); + y3 = %fadd(y3,x15); + y3 = %fadd(y3,x18); + y3 = %fadd(y3,x21); + + return ( y1, y2, y3 ); +} + + +/* various sized tuple returns */ + +cmm_tuple_1(W_ x, W_ y, W_ z) { return (z, y, x); } +cmm_tuple_2(P_ p1, P_ p2, W_ w1, W_ w2, P_ p3, P_ p4, D_ d1, D_ d2, P_ p5, P_ p6, F_ f1, F_ f2) { + return (f2, f1, p6, p5, d2, d1, p4, p3, w2, w1, p2, p1); +} +cmm_tuple_3(P_ p1, W_ w1, P_ p2, D_ d1, P_ p3, F_ f1) { + return (f1, p3, d1, p2, w1, p1); +} +cmm_tuple_4(P_ p1, P_ p2) { return (p2, p1); } + +/* working with arrays */ +cmm_array_1(P_ x) { + W_ size; + size = StgMutArrPtrs_size(x); + return (size); +} + +/* return two arrays */ +cmm_array_2(P_ x, P_ y) { + return (y, x); +} + +/* many arguments */ +cmm_many_arguments(W_ x1, W_ x2, W_ x3, W_ x4, W_ x5, W_ x6, W_ x7, W_ x8, W_ x9, W_ x10, + W_ x11, W_ x12, W_ x13, W_ x14, W_ x15, W_ x16, W_ x17, W_ x18, W_ x19, W_ x20, + W_ x21, W_ x22, W_ x23, W_ x24, W_ x25, W_ x26, W_ x27, W_ x28, W_ x29, W_ x30, + W_ x31, W_ x32, W_ x33, W_ x34, W_ x35, W_ x36, W_ x37, W_ x38, W_ x39, W_ x40, + W_ x41, W_ x42, W_ x43, W_ x44, W_ x45, W_ x46, W_ x47, W_ x48, W_ x49, W_ x50, + W_ x51, W_ x52, W_ x53, W_ x54, W_ x55, W_ x56, W_ x57, W_ x58, W_ x59, W_ x60, + W_ x61, W_ x62, W_ x63, W_ x64, W_ x65, W_ x66, W_ x67, W_ x68, W_ x69, W_ x70, + W_ x71, W_ x72, W_ x73, W_ x74, W_ x75, W_ x76, W_ x77, W_ x78, W_ x79, W_ x80, + W_ x81, W_ x82, W_ x83, W_ x84, W_ x85, W_ x86, W_ x87, W_ x88, W_ x89, W_ x90, + W_ x91, W_ x92, W_ x93, W_ x94, W_ x95, W_ x96, W_ x97, W_ x98, W_ x99, W_ x100, + W_ x101, W_ x102, W_ x103, W_ x104, W_ x105, W_ x106, W_ x107, W_ x108, W_ x109, W_ x110, + W_ x111, W_ x112, W_ x113, W_ x114, W_ x115, W_ x116, W_ x117, W_ x118, W_ x119, W_ x120, + W_ x121, W_ x122, W_ x123, W_ x124, W_ x125, W_ x126, W_ x127, W_ x128, W_ x129, W_ x130, + W_ x131, W_ x132, W_ x133, W_ x134, W_ x135, W_ x136, W_ x137, W_ x138, W_ x139, W_ x140, + W_ x141, W_ x142, W_ x143, W_ x144, W_ x145, W_ x146, W_ x147, W_ x148, W_ x149, W_ x150, + W_ x151, W_ x152, W_ x153, W_ x154, W_ x155, W_ x156, W_ x157, W_ x158, W_ x159, W_ x160, + W_ x161, W_ x162, W_ x163, W_ x164, W_ x165, W_ x166, W_ x167, W_ x168, W_ x169, W_ x170, + W_ x171, W_ x172, W_ x173, W_ x174, W_ x175, W_ x176, W_ x177, W_ x178, W_ x179, W_ x180, + W_ x181, W_ x182, W_ x183, W_ x184, W_ x185, W_ x186, W_ x187, W_ x188, W_ x189, W_ x190, + W_ x191, W_ x192, W_ x193, W_ x194, W_ x195, W_ x196, W_ x197, W_ x198, W_ x199, W_ x200, + W_ x201, W_ x202, W_ x203, W_ x204, W_ x205, W_ x206, W_ x207, W_ x208, W_ x209, W_ x210, + W_ x211, W_ x212, W_ x213, W_ x214, W_ x215, W_ x216, W_ x217, W_ x218, W_ x219, W_ x220, + W_ x221, W_ x222, W_ x223, W_ x224, W_ x225, W_ x226, W_ x227, W_ x228, W_ x229, W_ x230, + W_ x231, W_ x232, W_ x233, W_ x234, W_ x235, W_ x236, W_ x237, W_ x238, W_ x239, W_ x240, + W_ x241, W_ x242, W_ x243, W_ x244, W_ x245, W_ x246, W_ x247, W_ x248, W_ x249, W_ x250, + W_ x251, W_ x252, W_ x253, W_ x254, W_ x255, W_ x256, W_ x257, W_ x258, W_ x259, W_ x260, + W_ x261, W_ x262, W_ x263, W_ x264, W_ x265, W_ x266, W_ x267, W_ x268, W_ x269, W_ x270, + W_ x271, W_ x272, W_ x273, W_ x274, W_ x275, W_ x276, W_ x277, W_ x278, W_ x279, W_ x280, + W_ x281, W_ x282, W_ x283, W_ x284, W_ x285, W_ x286, W_ x287, W_ x288, W_ x289, W_ x290, + W_ x291, W_ x292, W_ x293, W_ x294, W_ x295, W_ x296, W_ x297, W_ x298, W_ x299, W_ x300, + W_ x301, W_ x302, W_ x303, W_ x304, W_ x305, W_ x306, W_ x307, W_ x308, W_ x309, W_ x310, + W_ x311, W_ x312, W_ x313, W_ x314, W_ x315, W_ x316, W_ x317, W_ x318, W_ x319, W_ x320, + W_ x321, W_ x322, W_ x323, W_ x324, W_ x325, W_ x326, W_ x327, W_ x328, W_ x329, W_ x330, + W_ x331, W_ x332, W_ x333, W_ x334, W_ x335, W_ x336, W_ x337, W_ x338, W_ x339, W_ x340, + W_ x341, W_ x342, W_ x343, W_ x344, W_ x345, W_ x346, W_ x347, W_ x348, W_ x349, W_ x350, + W_ x351, W_ x352, W_ x353, W_ x354, W_ x355, W_ x356, W_ x357, W_ x358, W_ x359, W_ x360, + W_ x361, W_ x362, W_ x363, W_ x364, W_ x365, W_ x366, W_ x367, W_ x368, W_ x369, W_ x370, + W_ x371, W_ x372, W_ x373, W_ x374, W_ x375, W_ x376, W_ x377, W_ x378, W_ x379, W_ x380, + W_ x381, W_ x382, W_ x383, W_ x384, W_ x385, W_ x386, W_ x387, W_ x388, W_ x389, W_ x390, + W_ x391, W_ x392, W_ x393, W_ x394, W_ x395, W_ x396, W_ x397, W_ x398, W_ x399, W_ x400) { + W_ y; + y = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + + x21 + x22 + x23 + x24 + x25 + x26 + x27 + x28 + x29 + x30 + + x31 + x32 + x33 + x34 + x35 + x36 + x37 + x38 + x39 + x40 + + x41 + x42 + x43 + x44 + x45 + x46 + x47 + x48 + x49 + x50 + + x51 + x52 + x53 + x54 + x55 + x56 + x57 + x58 + x59 + x60 + + x61 + x62 + x63 + x64 + x65 + x66 + x67 + x68 + x69 + x70 + + x71 + x72 + x73 + x74 + x75 + x76 + x77 + x78 + x79 + x80 + + x81 + x82 + x83 + x84 + x85 + x86 + x87 + x88 + x89 + x90 + + x91 + x92 + x93 + x94 + x95 + x96 + x97 + x98 + x99 + x100 + + x101 + x102 + x103 + x104 + x105 + x106 + x107 + x108 + x109 + x110 + + x111 + x112 + x113 + x114 + x115 + x116 + x117 + x118 + x119 + x120 + + x121 + x122 + x123 + x124 + x125 + x126 + x127 + x128 + x129 + x130 + + x131 + x132 + x133 + x134 + x135 + x136 + x137 + x138 + x139 + x140 + + x141 + x142 + x143 + x144 + x145 + x146 + x147 + x148 + x149 + x150 + + x151 + x152 + x153 + x154 + x155 + x156 + x157 + x158 + x159 + x160 + + x161 + x162 + x163 + x164 + x165 + x166 + x167 + x168 + x169 + x170 + + x171 + x172 + x173 + x174 + x175 + x176 + x177 + x178 + x179 + x180 + + x181 + x182 + x183 + x184 + x185 + x186 + x187 + x188 + x189 + x190 + + x191 + x192 + x193 + x194 + x195 + x196 + x197 + x198 + x199 + x200 + + x201 + x202 + x203 + x204 + x205 + x206 + x207 + x208 + x209 + x210 + + x211 + x212 + x213 + x214 + x215 + x216 + x217 + x218 + x219 + x220 + + x221 + x222 + x223 + x224 + x225 + x226 + x227 + x228 + x229 + x230 + + x231 + x232 + x233 + x234 + x235 + x236 + x237 + x238 + x239 + x240 + + x241 + x242 + x243 + x244 + x245 + x246 + x247 + x248 + x249 + x250 + + x251 + x252 + x253 + x254 + x255 + x256 + x257 + x258 + x259 + x260 + + x261 + x262 + x263 + x264 + x265 + x266 + x267 + x268 + x269 + x270 + + x271 + x272 + x273 + x274 + x275 + x276 + x277 + x278 + x279 + x280 + + x281 + x282 + x283 + x284 + x285 + x286 + x287 + x288 + x289 + x290 + + x291 + x292 + x293 + x294 + x295 + x296 + x297 + x298 + x299 + x300 + + x301 + x302 + x303 + x304 + x305 + x306 + x307 + x308 + x309 + x310 + + x311 + x312 + x313 + x314 + x315 + x316 + x317 + x318 + x319 + x320 + + x321 + x322 + x323 + x324 + x325 + x326 + x327 + x328 + x329 + x330 + + x331 + x332 + x333 + x334 + x335 + x336 + x337 + x338 + x339 + x340 + + x341 + x342 + x343 + x344 + x345 + x346 + x347 + x348 + x349 + x350 + + x351 + x352 + x353 + x354 + x355 + x356 + x357 + x358 + x359 + x360 + + x361 + x362 + x363 + x364 + x365 + x366 + x367 + x368 + x369 + x370 + + x371 + x372 + x373 + x374 + x375 + x376 + x377 + x378 + x379 + x380 + + x381 + x382 + x383 + x384 + x385 + x386 + x387 + x388 + x389 + x390 + + x391 + x392 + x393 + x394 + x395 + x396 + x397 + x398 + x399 + x400; + return (y); +} ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile ===================================== @@ -0,0 +1,4 @@ +.PHONY: GHCiPrimCall +GHCiPrimCall: + '$(TEST_HC)' $(TEST_HC_OPTS) -fPIC -v0 -c GHCiPrimCall_cmm.cmm + -'$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -e main GHCiPrimCall.hs GHCiPrimCall_cmm.o || echo $$? >&2 ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/all.T ===================================== @@ -0,0 +1,2 @@ +test('GHCiPrimCall', [req_interp], makefile_test, ['GHCiPrimCall']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/00577d1ade77980df5eb304b0811c171261c63c0...ab529bfae98fcd9dbf09b06243a3c3fd9304c6cb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/00577d1ade77980df5eb304b0811c171261c63c0...ab529bfae98fcd9dbf09b06243a3c3fd9304c6cb You're receiving 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 Jan 10 05:49:11 2023 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Tue, 10 Jan 2023 00:49:11 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] Add PrimCallConv support to GHCi Message-ID: <63bcfc57eb314_3b1bf95260c3281da@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 422d296f by Luite Stegeman at 2023-01-10T14:48:01+09:00 Add PrimCallConv support to GHCi This adds support for calling Cmm code from bytecode using the native calling convention, allowing modules that use `foreign import prim` to be loaded and debugged in GHCi. This patch introduces a new `PRIMCALL` bytecode instruction and a helper stack frame `stg_primcall`. The code is based on the existing functionality for dealing with unboxed tuples in bytecode, which has been generalised to handle arbitrary calls. Fixes #22051 - - - - - 21 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Foreign.hs - rts/Disassembler.c - rts/Interpreter.c - rts/RtsSymbols.c - rts/StgMiscClosures.cmm - rts/include/rts/Bytecodes.h - rts/include/stg/MiscClosures.h - testsuite/tests/ghci/prog014/prog014.T - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout-ws-32 - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm - + testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile - + testsuite/tests/ghci/should_run/GHCiPrimCall/all.T Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -12,7 +12,7 @@ module GHC.ByteCode.Asm ( bcoFreeNames, SizedSeq, sizeSS, ssElts, iNTERP_STACK_CHECK_THRESH, - mkTupleInfoLit + mkNativeCallInfoLit ) where import GHC.Prelude @@ -32,7 +32,6 @@ import GHC.Types.Unique.DSet import GHC.Utils.Outputable import GHC.Utils.Panic -import GHC.Utils.Panic.Plain import GHC.Core.TyCon import GHC.Data.FastString @@ -40,7 +39,7 @@ import GHC.Data.SizedSeq import GHC.StgToCmm.Layout ( ArgRep(..) ) import GHC.Cmm.Expr -import GHC.Cmm.CallConv ( tupleRegsCover ) +import GHC.Cmm.CallConv ( allArgRegsCover ) import GHC.Platform import GHC.Platform.Profile @@ -202,7 +201,8 @@ assembleBCO platform (ProtoBCO { protoBCOName = nm (final_insns, final_lits, final_ptrs) <- flip execStateT initial_state $ runAsm platform long_jumps env asm -- precomputed size should be equal to final size - massert (n_insns == sizeSS final_insns) + massertPpr (n_insns == sizeSS final_insns) + (text "bytecode instruction count mismatch") let asm_insns = ssElts final_insns insns_arr = Array.listArray (0, fromIntegral n_insns - 1) asm_insns @@ -351,7 +351,8 @@ largeArg platform w = case platformWordSize platform of fromIntegral (w `shiftR` 32), fromIntegral (w `shiftR` 16), fromIntegral w] - PW4 -> assert (w < fromIntegral (maxBound :: Word32)) $ + PW4 -> assertPpr (w < fromIntegral (maxBound :: Word32)) + (text "largeArg too big:" <+> ppr w) $ [fromIntegral (w `shiftR` 16), fromIntegral w] @@ -388,14 +389,14 @@ assembleI platform i = case i of -> do let ul_bco = assembleBCO platform proto p <- ioptr (liftM BCOPtrBCO ul_bco) emit (push_alts pk) [Op p] - PUSH_ALTS_TUPLE proto tuple_info tuple_proto + PUSH_ALTS_TUPLE proto call_info tuple_proto -> do let ul_bco = assembleBCO platform proto ul_tuple_bco = assembleBCO platform tuple_proto p <- ioptr (liftM BCOPtrBCO ul_bco) p_tup <- ioptr (liftM BCOPtrBCO ul_tuple_bco) info <- int (fromIntegral $ - mkTupleInfoSig platform tuple_info) + mkNativeCallInfoSig platform call_info) emit bci_PUSH_ALTS_T [Op p, Op info, Op p_tup] PUSH_PAD8 -> emit bci_PUSH_PAD8 [] @@ -491,6 +492,7 @@ assembleI platform i = case i of RETURN_TUPLE -> emit bci_RETURN_T [] CCALL off m_addr i -> do np <- addr m_addr emit bci_CCALL [SmallOp off, Op np, SmallOp i] + PRIMCALL -> emit bci_PRIMCALL [] BRK_FUN index uniq cc -> do p1 <- ptr BCOPtrBreakArray q <- int (getKey uniq) np <- addr cc @@ -580,41 +582,44 @@ return_unlifted V64 = error "return_unlifted: vector" maximum number of tuple elements may be larger. Elements can also take multiple words on the stack (for example Double# on a 32 bit platform). - -} -maxTupleNativeStackSize :: WordOff -maxTupleNativeStackSize = 62 +maxTupleReturnNativeStackSize :: WordOff +maxTupleReturnNativeStackSize = 62 {- - Construct the tuple_info word that stg_ctoi_t and stg_ret_t use - to convert a tuple between the native calling convention and the + Construct the call_info word that stg_ctoi_t, stg_ret_t and stg_primcall + use to convert arguments between the native calling convention and the interpreter. - See Note [GHCi tuple layout] for more information. + See Note [GHCi and native call registers] for more information. -} -mkTupleInfoSig :: Platform -> TupleInfo -> Word32 -mkTupleInfoSig platform TupleInfo{..} - | tupleNativeStackSize > maxTupleNativeStackSize - = pprPanic "mkTupleInfoSig: tuple too big for the bytecode compiler" - (ppr tupleNativeStackSize <+> text "stack words." <+> +mkNativeCallInfoSig :: Platform -> NativeCallInfo -> Word32 +mkNativeCallInfoSig platform NativeCallInfo{..} + | nativeCallType == NativeTupleReturn && nativeCallStackSpillSize > maxTupleReturnNativeStackSize + = pprPanic "mkNativeCallInfoSig: tuple too big for the bytecode compiler" + (ppr nativeCallStackSpillSize <+> text "stack words." <+> text "Use -fobject-code to get around this limit" ) | otherwise - = assert (length regs <= 24) {- 24 bits for bitmap -} - assert (tupleNativeStackSize < 255) {- 8 bits for stack size -} - assert (all (`elem` regs) (regSetToList tupleRegs)) {- all regs accounted for -} - foldl' reg_bit 0 (zip regs [0..]) .|. - (fromIntegral tupleNativeStackSize `shiftL` 24) + = assertPpr (length regs <= 24) (text "too many registers for bitmap:" <+> ppr (length regs)) {- 24 bits for register bitmap -} + assertPpr (cont_offset < 255) (text "continuation offset too large:" <+> ppr cont_offset) {- 8 bits for continuation offset (only for NativeTupleReturn) -} + assertPpr (all (`elem` regs) (regSetToList nativeCallRegs)) (text "not all registers accounted for") {- all regs accounted for -} + foldl' reg_bit 0 (zip regs [0..]) .|. (cont_offset `shiftL` 24) where + cont_offset :: Word32 + cont_offset + | nativeCallType == NativeTupleReturn = fromIntegral nativeCallStackSpillSize + | otherwise = 0 -- there is no continuation for primcalls + reg_bit :: Word32 -> (GlobalReg, Int) -> Word32 reg_bit x (r, n) - | r `elemRegSet` tupleRegs = x .|. 1 `shiftL` n - | otherwise = x - regs = tupleRegsCover platform + | r `elemRegSet` nativeCallRegs = x .|. 1 `shiftL` n + | otherwise = x + regs = allArgRegsCover platform -mkTupleInfoLit :: Platform -> TupleInfo -> Literal -mkTupleInfoLit platform tuple_info = - mkLitWord platform . fromIntegral $ mkTupleInfoSig platform tuple_info +mkNativeCallInfoLit :: Platform -> NativeCallInfo -> Literal +mkNativeCallInfoLit platform call_info = + mkLitWord platform . fromIntegral $ mkNativeCallInfoSig platform call_info -- Make lists of host-sized words for literals, so that when the -- words are placed in memory at increasing addresses, the ===================================== compiler/GHC/ByteCode/Instr.hs ===================================== @@ -90,7 +90,7 @@ data BCInstr | PUSH_ALTS (ProtoBCO Name) | PUSH_ALTS_UNLIFTED (ProtoBCO Name) ArgRep | PUSH_ALTS_TUPLE (ProtoBCO Name) -- continuation - !TupleInfo + !NativeCallInfo (ProtoBCO Name) -- tuple return BCO -- Pushing 8, 16 and 32 bits of padding (for constructors). @@ -184,6 +184,8 @@ data BCInstr -- (XXX: inefficient, but I don't know -- what the alignment constraints are.) + | PRIMCALL + -- For doing magic ByteArray passing to foreign calls | SWIZZLE Word16 -- to the ptr N words down the stack, Word16 -- add M (interpreted as a signed 16-bit entity) @@ -269,8 +271,8 @@ instance Outputable BCInstr where ppr (PUSH_ALTS bco) = hang (text "PUSH_ALTS") 2 (ppr bco) ppr (PUSH_ALTS_UNLIFTED bco pk) = hang (text "PUSH_ALTS_UNLIFTED" <+> ppr pk) 2 (ppr bco) - ppr (PUSH_ALTS_TUPLE bco tuple_info tuple_bco) = - hang (text "PUSH_ALTS_TUPLE" <+> ppr tuple_info) + ppr (PUSH_ALTS_TUPLE bco call_info tuple_bco) = + hang (text "PUSH_ALTS_TUPLE" <+> ppr call_info) 2 (ppr tuple_bco $+$ ppr bco) @@ -340,6 +342,7 @@ instance Outputable BCInstr where 0x1 -> text "(interruptible)" 0x2 -> text "(unsafe)" _ -> empty) + ppr PRIMCALL = text "PRIMCALL" ppr (SWIZZLE stkoff n) = text "SWIZZLE " <+> text "stkoff" <+> ppr stkoff <+> text "by" <+> ppr n ppr ENTER = text "ENTER" @@ -382,11 +385,11 @@ bciStackUse (PUSH_ALTS bco) = 2 {- profiling only, restore CCCS -} + bciStackUse (PUSH_ALTS_UNLIFTED bco _) = 2 {- profiling only, restore CCCS -} + 4 + protoBCOStackUse bco bciStackUse (PUSH_ALTS_TUPLE bco info _) = - -- (tuple_bco, tuple_info word, cont_bco, stg_ctoi_t) + -- (tuple_bco, call_info word, cont_bco, stg_ctoi_t) -- tuple - -- (tuple_info, tuple_bco, stg_ret_t) + -- (call_info, tuple_bco, stg_ret_t) 1 {- profiling only -} + - 7 + fromIntegral (tupleSize info) + protoBCOStackUse bco + 7 + fromIntegral (nativeCallSize info) + protoBCOStackUse bco bciStackUse (PUSH_PAD8) = 1 -- overapproximation bciStackUse (PUSH_PAD16) = 1 -- overapproximation bciStackUse (PUSH_PAD32) = 1 -- overapproximation on 64bit arch @@ -443,6 +446,7 @@ bciStackUse RETURN{} = 0 bciStackUse RETURN_UNLIFTED{} = 1 -- pushes stg_ret_X for some X bciStackUse RETURN_TUPLE{} = 1 -- pushes stg_ret_t header bciStackUse CCALL{} = 0 +bciStackUse PRIMCALL{} = 1 -- pushes stg_primcall bciStackUse SWIZZLE{} = 0 bciStackUse BRK_FUN{} = 0 ===================================== compiler/GHC/ByteCode/Types.hs ===================================== @@ -10,7 +10,7 @@ module GHC.ByteCode.Types ( CompiledByteCode(..), seqCompiledByteCode , FFIInfo(..) , RegBitmap(..) - , TupleInfo(..), voidTupleInfo + , NativeCallType(..), NativeCallInfo(..), voidTupleReturnInfo, voidPrimCallInfo , ByteOff(..), WordOff(..) , UnlinkedBCO(..), BCOPtr(..), BCONPtr(..) , ItblEnv, ItblPtr(..) @@ -105,22 +105,32 @@ newtype RegBitmap = RegBitmap { unRegBitmap :: Word32 } See GHC.StgToByteCode.layoutTuple for more details. -} -data TupleInfo = TupleInfo - { tupleSize :: !WordOff -- total size of tuple in words - , tupleRegs :: !GlobalRegSet - , tupleNativeStackSize :: !WordOff {- words spilled on the stack by - GHCs native calling convention -} - } deriving (Show) - -instance Outputable TupleInfo where - ppr TupleInfo{..} = text " ppr tupleSize <+> - text "stack" <+> ppr tupleNativeStackSize <+> - text "regs" <+> - ppr (map (text @SDoc . show) $ regSetToList tupleRegs) <> - char '>' - -voidTupleInfo :: TupleInfo -voidTupleInfo = TupleInfo 0 emptyRegSet 0 + +data NativeCallType = NativePrimCall + | NativeTupleReturn + deriving (Eq) + +data NativeCallInfo = NativeCallInfo + { nativeCallType :: !NativeCallType + , nativeCallSize :: !WordOff -- total size of arguments in words + , nativeCallRegs :: !GlobalRegSet + , nativeCallStackSpillSize :: !WordOff {- words spilled on the stack by + GHCs native calling convention -} + } + +instance Outputable NativeCallInfo where + ppr NativeCallInfo{..} = text " ppr nativeCallSize <+> + text "stack" <+> ppr nativeCallStackSpillSize <+> + text "regs" <+> + ppr (map (text @SDoc . show) $ regSetToList nativeCallRegs) <> + char '>' + + +voidTupleReturnInfo :: NativeCallInfo +voidTupleReturnInfo = NativeCallInfo NativeTupleReturn 0 emptyRegSet 0 + +voidPrimCallInfo :: NativeCallInfo +voidPrimCallInfo = NativeCallInfo NativePrimCall 0 emptyRegSet 0 type ItblEnv = NameEnv (Name, ItblPtr) -- We need the Name in the range so we know which ===================================== compiler/GHC/Cmm/CallConv.hs ===================================== @@ -3,7 +3,7 @@ module GHC.Cmm.CallConv ( assignArgumentsPos, assignStack, realArgRegsCover, - tupleRegsCover + allArgRegsCover ) where import GHC.Prelude @@ -220,12 +220,105 @@ realArgRegsCover platform realLongRegs platform -- we don't save XMM registers if they are not used for parameter passing --- Like realArgRegsCover but always includes the node. This covers the real --- and virtual registers used for unboxed tuples. --- --- Note: if anything changes in how registers for unboxed tuples overlap, --- make sure to also update GHC.StgToByteCode.layoutTuple. -tupleRegsCover :: Platform -> [GlobalReg] -tupleRegsCover platform = +{- + + Note [GHCi and native call registers] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + The GHCi bytecode interpreter does not have access to the STG registers + that the native calling convention uses for passing arguments. It uses + helper stack frames to move values between the stack and registers. + + If only a single register needs to be moved, GHCi uses a specific stack + frame. For example stg_ctoi_R1p saves a heap pointer value from STG register + R1 and stg_ctoi_D1 saves a double precision floating point value from D1. + In the other direction, helpers stg_ret_p and stg_ret_d move a value from + the stack to the R1 and D1 registers, respectively. + + When GHCi needs to move more than one register it cannot use a specific + helper frame. It would simply be impossible to create a helper for all + possible combinations of register values. Instead, there are generic helper + stack frames that use a call_info word that describes the active registers + and the number of stack words used by the arguments of a call. + + These helper stack frames are currently: + + - stg_ret_t: return a tuple to the continuation at the top of + the stack + - stg_ctoi_t: convert a tuple return value to be used in + bytecode + - stg_primcall: call a function + + + The call_info word contains a bitmap of the active registers + for the call and and a stack offset. The layout is as follows: + + - bit 0-23: Bitmap of active registers for the call, the + order corresponds to the list returned by + allArgRegsCover. For example if bit 0 (the least + significant bit) is set, the first register in the + allArgRegsCover list is active. Bit 1 for the + second register in the list and so on. + + - bit 24-31: Unsigned byte indicating the stack offset + of the continuation in words. For tuple returns + this is the number of words returned on the + stack. For primcalls this field is unused, since + we don't jump to a continuation. + + The upper 32 bits on 64 bit platforms are currently unused. + + If a register is smaller than a word on the stack (for example a + single precision float on a 64 bit system), then the stack slot + is padded to a whole word. + + Example: + + If a call has three arguments passed registers and + additional two words of arguments on the stack, then + three bits in the bitmap in bits 0-23 would be set. And + Bit 24-31 would be 00000010 (two in binary). + + The values on the stack before a call to POP_ARG_REGS would + be as follows: + + ... + stack_arg_1 + stack_arg_2 + register_arg_3 + register_arg_2 + register_arg_1 <- Sp + + A call to POP_ARG_REGS(call_info) would move register_arg_1 + to the register corresponding to the lowest set bit in the + call_info word. register_arg_2 would be moved to the register + corresponding to the second lowest set bit, and so on. + + After POP_ARG_REGS(call_info), the stack pointer Sp points + to the topmost stack argument, so the stack looks as follows: + + ... + stack_arg_1 + stack_arg_2 <- Sp + + At this point all the arguments are in place and we are ready + to jump to the native function. + + On x86_64, the double precision (Dn) and single precision + floating (Fn) point registers overlap, e.g. D1 uses the same + physical register as F1. On this platform, the list returned + by allArgRegsCover contains only entries for the double + precision registers. If an argument is passed in register + Fn, the bit corresponding to Dn should be set. + + Note: if anything changes in how registers for native calls overlap, + make sure to also update GHC.StgToByteCode.layoutNativeCall + -} + +-- Like realArgRegsCover but always includes the node. This covers all real +-- and virtual registers actually used for passing arguments. + +allArgRegsCover :: Platform -> [GlobalReg] +allArgRegsCover platform = nub (VanillaReg 1 VGcPtr : realArgRegsCover platform) ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -1233,8 +1233,8 @@ stmtMacros = listToUFM [ ( fsLit "SAVE_REGS", \[] -> emitSaveRegs ), ( fsLit "RESTORE_REGS", \[] -> emitRestoreRegs ), - ( fsLit "PUSH_TUPLE_REGS", \[live_regs] -> emitPushTupleRegs live_regs ), - ( fsLit "POP_TUPLE_REGS", \[live_regs] -> emitPopTupleRegs live_regs ), + ( fsLit "PUSH_ARG_REGS", \[live_regs] -> emitPushArgRegs live_regs ), + ( fsLit "POP_ARG_REGS", \[live_regs] -> emitPopArgRegs live_regs ), ( fsLit "LDV_ENTER", \[e] -> ldvEnter e ), ( fsLit "LDV_RECORD_CREATE", \[e] -> ldvRecordCreate e ), ===================================== compiler/GHC/Cmm/Reg.hs ===================================== @@ -223,7 +223,7 @@ instance Eq GlobalReg where _r1 == _r2 = False -- NOTE: this Ord instance affects the tuple layout in GHCi, see --- Note [GHCi tuple layout] +-- Note [GHCi and native call registers] instance Ord GlobalReg where compare (VanillaReg i _) (VanillaReg j _) = compare i j -- Ignore type when seeking clashes ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -58,7 +58,7 @@ import GHC.Data.FastString import GHC.Utils.Panic import GHC.Utils.Panic.Plain import GHC.Utils.Exception (evaluate) -import GHC.StgToCmm.Closure ( NonVoid(..), fromNonVoid, nonVoidIds ) +import GHC.StgToCmm.Closure ( NonVoid(..), fromNonVoid, nonVoidIds, argPrimRep ) import GHC.StgToCmm.Layout import GHC.Runtime.Heap.Layout hiding (WordOff, ByteOff, wordsToBytes) import GHC.Data.Bitmap @@ -464,10 +464,10 @@ returnUnliftedReps d s szb reps = do [rep] -> return (unitOL $ RETURN_UNLIFTED (toArgRep platform rep)) -- otherwise use RETURN_TUPLE with a tuple descriptor nv_reps -> do - let (tuple_info, args_offsets) = layoutTuple profile 0 (primRepCmmType platform) nv_reps + let (call_info, args_offsets) = layoutNativeCall profile NativeTupleReturn 0 (primRepCmmType platform) nv_reps args_ptrs = map (\(rep, off) -> (isFollowableArg (toArgRep platform rep), off)) args_offsets - tuple_bco <- emitBc (tupleBCO platform tuple_info args_ptrs) - return $ PUSH_UBX (mkTupleInfoLit platform tuple_info) 1 `consOL` + tuple_bco <- emitBc (tupleBCO platform call_info args_ptrs) + return $ PUSH_UBX (mkNativeCallInfoLit platform call_info) 1 `consOL` PUSH_BCO tuple_bco `consOL` unitOL RETURN_TUPLE return ( mkSlideB platform szb (d - s) -- clear to sequel @@ -484,7 +484,11 @@ returnUnboxedTuple d s p es = do profile <- getProfile let platform = profilePlatform profile arg_ty e = primRepCmmType platform (atomPrimRep e) - (tuple_info, tuple_components) = layoutTuple profile d arg_ty es + (call_info, tuple_components) = layoutNativeCall profile + NativeTupleReturn + d + arg_ty + es go _ pushes [] = return (reverse pushes) go !dd pushes ((a, off):cs) = do (push, szb) <- pushAtom dd p a massert (off == dd + szb) @@ -492,7 +496,7 @@ returnUnboxedTuple d s p es = do pushes <- go d [] tuple_components ret <- returnUnliftedReps d s - (wordsToBytes platform $ tupleSize tuple_info) + (wordsToBytes platform $ nativeCallSize call_info) (map atomPrimRep es) return (mconcat pushes `appOL` ret) @@ -648,14 +652,14 @@ schemeT d s p app -- Case 1 schemeT d s p (StgOpApp (StgFCallOp (CCall ccall_spec) _ty) args result_ty) = if isSupportedCConv ccall_spec - then generateCCall d s p ccall_spec result_ty (reverse args) + then generateCCall d s p ccall_spec result_ty args else unsupportedCConvException schemeT d s p (StgOpApp (StgPrimOp op) args _ty) = doTailCall d s p (primOpId op) (reverse args) -schemeT _d _s _p (StgOpApp StgPrimCallOp{} _args _ty) - = unsupportedCConvException +schemeT d s p (StgOpApp (StgPrimCallOp (PrimCall label unit)) args result_ty) + = generatePrimCall d s p label (Just unit) result_ty args -- Case 2: Unboxed tuple schemeT d s p (StgConApp con _cn args _tys) @@ -840,18 +844,18 @@ doCase d s p scrut bndr alts | ubx_frame = wordSize platform | otherwise = 0 - (bndr_size, tuple_info, args_offsets) + (bndr_size, call_info, args_offsets) | ubx_tuple_frame = let bndr_ty = primRepCmmType platform bndr_reps = filter (not.isVoidRep) (bcIdPrimReps bndr) - (tuple_info, args_offsets) = - layoutTuple profile 0 bndr_ty bndr_reps - in ( wordsToBytes platform (tupleSize tuple_info) - , tuple_info + (call_info, args_offsets) = + layoutNativeCall profile NativeTupleReturn 0 bndr_ty bndr_reps + in ( wordsToBytes platform (nativeCallSize call_info) + , call_info , args_offsets ) | otherwise = ( wordsToBytes platform (idSizeW platform bndr) - , voidTupleInfo + , voidTupleReturnInfo , [] ) @@ -885,17 +889,18 @@ doCase d s p scrut bndr alts | isUnboxedTupleType bndr_ty || isUnboxedSumType bndr_ty = let bndr_ty = primRepCmmType platform . bcIdPrimRep tuple_start = d_bndr - (tuple_info, args_offsets) = - layoutTuple profile - 0 - bndr_ty - bndrs + (call_info, args_offsets) = + layoutNativeCall profile + NativeTupleReturn + 0 + bndr_ty + bndrs stack_bot = d_alts p' = Map.insertList [ (arg, tuple_start - - wordsToBytes platform (tupleSize tuple_info) + + wordsToBytes platform (nativeCallSize call_info) + offset) | (arg, offset) <- args_offsets , not (isVoidRep $ bcIdPrimRep arg)] @@ -981,8 +986,8 @@ doCase d s p scrut bndr alts -- unboxed tuples get two more words, the second is a pointer (tuple_bco) (extra_pointers, extra_slots) - | ubx_tuple_frame && profiling = ([1], 3) -- tuple_info, tuple_BCO, CCCS - | ubx_tuple_frame = ([1], 2) -- tuple_info, tuple_BCO + | ubx_tuple_frame && profiling = ([1], 3) -- call_info, tuple_BCO, CCCS + | ubx_tuple_frame = ([1], 2) -- call_info, tuple_BCO | otherwise = ([], 0) bitmap_size = trunc16W $ fromIntegral extra_slots + @@ -1028,8 +1033,8 @@ doCase d s p scrut bndr alts let args_ptrs = map (\(rep, off) -> (isFollowableArg (toArgRep platform rep), off)) args_offsets - tuple_bco <- emitBc (tupleBCO platform tuple_info args_ptrs) - return (PUSH_ALTS_TUPLE alt_bco' tuple_info tuple_bco + tuple_bco <- emitBc (tupleBCO platform call_info args_ptrs) + return (PUSH_ALTS_TUPLE alt_bco' call_info tuple_bco `consOL` scrut_code) else let push_alts | not ubx_frame @@ -1050,14 +1055,15 @@ doCase d s p scrut bndr alts -- The native calling convention uses registers for tuples, but in the -- bytecode interpreter, all values live on the stack. -layoutTuple :: Profile - -> ByteOff - -> (a -> CmmType) - -> [a] - -> ( TupleInfo -- See Note [GHCi TupleInfo] - , [(a, ByteOff)] -- argument, offset on stack - ) -layoutTuple profile start_off arg_ty reps = +layoutNativeCall :: Profile + -> NativeCallType + -> ByteOff + -> (a -> CmmType) + -> [a] + -> ( NativeCallInfo -- See Note [GHCi TupleInfo] + , [(a, ByteOff)] -- argument, offset on stack + ) +layoutNativeCall profile call_type start_off arg_ty reps = let platform = profilePlatform profile (orig_stk_bytes, pos) = assignArgumentsPos profile 0 @@ -1070,7 +1076,7 @@ layoutTuple profile start_off arg_ty reps = -- sort the register parameters by register and add them to the stack regs_order :: Map.Map GlobalReg Int - regs_order = Map.fromList $ zip (tupleRegsCover platform) [0..] + regs_order = Map.fromList $ zip (allArgRegsCover platform) [0..] reg_order :: GlobalReg -> (Int, GlobalReg) reg_order reg | Just n <- Map.lookup reg regs_order = (n, reg) @@ -1099,10 +1105,11 @@ layoutTuple profile start_off arg_ty reps = get_byte_off _ = panic "GHC.StgToByteCode.layoutTuple get_byte_off" - in ( TupleInfo - { tupleSize = bytesToWords platform (ByteOff new_stk_bytes) - , tupleRegs = regs_set - , tupleNativeStackSize = bytesToWords platform + in ( NativeCallInfo + { nativeCallType = call_type + , nativeCallSize = bytesToWords platform (ByteOff new_stk_bytes) + , nativeCallRegs = regs_set + , nativeCallStackSpillSize = bytesToWords platform (ByteOff orig_stk_bytes) } , sortBy (comparing snd) $ @@ -1127,7 +1134,7 @@ usePlainReturn t ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We have the bytecode instructions RETURN_TUPLE and PUSH_ALTS_TUPLE to return and receive arbitrary unboxed tuples, respectively. These - instructions use the helper data tuple_BCO and tuple_info. + instructions use the helper data tuple_BCO and call_info. The helper data is used to convert tuples between GHCs native calling convention (object code), which uses stack and registers, and the bytecode @@ -1139,7 +1146,7 @@ usePlainReturn t ================= Bytecode that returns a tuple first pushes all the tuple fields followed - by the appropriate tuple_info and tuple_BCO onto the stack. It then + by the appropriate call_info and tuple_BCO onto the stack. It then executes the RETURN_TUPLE instruction, which causes the interpreter to push stg_ret_t_info to the top of the stack. The stack (growing down) then looks as follows: @@ -1150,14 +1157,14 @@ usePlainReturn t tuple_field_2 ... tuple_field_n - tuple_info + call_info tuple_BCO stg_ret_t_info <- Sp If next_frame is bytecode, the interpreter will start executing it. If it's object code, the interpreter jumps back to the scheduler, which in turn jumps to stg_ret_t. stg_ret_t converts the tuple to the native - calling convention using the description in tuple_info, and then jumps + calling convention using the description in call_info, and then jumps to next_frame. @@ -1169,13 +1176,13 @@ usePlainReturn t tuple. The PUSH_ALTS_TUPLE instuction contains three pieces of data: * cont_BCO: the continuation that receives the tuple - * tuple_info: see below + * call_info: see below * tuple_BCO: see below The interpreter pushes these onto the stack when the PUSH_ALTS_TUPLE instruction is executed, followed by stg_ctoi_tN_info, with N depending on the number of stack words used by the tuple in the GHC native calling - convention. N is derived from tuple_info. + convention. N is derived from call_info. For example if we expect a tuple with three words on the stack, the stack looks as follows after PUSH_ALTS_TUPLE: @@ -1186,7 +1193,7 @@ usePlainReturn t cont_free_var_2 ... cont_free_var_n - tuple_info + call_info tuple_BCO cont_BCO stg_ctoi_t3_info <- Sp @@ -1206,20 +1213,20 @@ usePlainReturn t that is already on the stack. - The tuple_info word + The call_info word =================== - The tuple_info word describes the stack and STG register (e.g. R1..R6, - D1..D6) usage for the tuple. tuple_info contains enough information to + The call_info word describes the stack and STG register (e.g. R1..R6, + D1..D6) usage for the tuple. call_info contains enough information to convert the tuple between the stack-only bytecode and stack+registers GHC native calling conventions. - See Note [GHCi tuple layout] for more details of how the data is packed - in a single word. + See Note [GHCi and native call registers] for more details of how the + data is packed in a single word. -} -tupleBCO :: Platform -> TupleInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name +tupleBCO :: Platform -> NativeCallInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name tupleBCO platform info pointers = mkProtoBCO platform invented_name body_code (Left []) 0{-no arity-} bitmap_size bitmap False{-is alts-} @@ -1233,15 +1240,103 @@ tupleBCO platform info pointers = -} invented_name = mkSystemVarName (mkPseudoUniqueE 0) (fsLit "tuple") - -- the first word in the frame is the tuple_info word, + -- the first word in the frame is the call_info word, -- which is not a pointer - bitmap_size = trunc16W $ 1 + tupleSize info + bitmap_size = trunc16W $ 1 + nativeCallSize info bitmap = intsToReverseBitmap platform (fromIntegral bitmap_size) $ map ((+1) . fromIntegral . bytesToWords platform . snd) (filter fst pointers) body_code = mkSlideW 0 1 -- pop frame header `snocOL` RETURN_TUPLE -- and add it again +primCallBCO :: Platform -> NativeCallInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name +primCallBCO platform args_info pointers = + mkProtoBCO platform invented_name body_code (Left []) + 0{-no arity-} bitmap_size bitmap False{-is alts-} + + where + {- + The primcall BCO is never referred to by name, so we can get away + with using a fake name here. We will need to change this if we want + to save some memory by sharing the BCO between places that have + the same tuple shape + -} + invented_name = mkSystemVarName (mkPseudoUniqueE 0) (fsLit "primcall") + + -- the first three words in the frame are the BCO describing the + -- pointers in the frame, the call_info word and the pointer + -- to the Cmm function being called. None of these is a pointer that + -- should be followed by the garbage collector + bitmap_size = trunc16W $ 2 + nativeCallSize args_info + bitmap = intsToReverseBitmap platform (fromIntegral bitmap_size) $ + map ((+2) . fromIntegral . bytesToWords platform . snd) + (filter fst pointers) + -- if the primcall BCO is ever run it's a bug, since the BCO should only + -- be pushed immediately before running the PRIMCALL bytecode instruction, + -- which immediately leaves the interpreter to jump to the stg_primcall_info + -- Cmm function + body_code = unitOL CASEFAIL + +-- ----------------------------------------------------------------------------- +-- Deal with a primitive call to native code. + +generatePrimCall + :: StackDepth + -> Sequel + -> BCEnv + -> CLabelString -- where to call + -> Maybe Unit + -> Type + -> [StgArg] -- args (atoms) + -> BcM BCInstrList +generatePrimCall d s p target _mb_unit _result_ty args + = do + profile <- getProfile + let + platform = profilePlatform profile + + non_void VoidRep = False + non_void _ = True + + nv_args :: [StgArg] + nv_args = filter (non_void . argPrimRep) args + + (args_info, args_offsets) = + layoutNativeCall profile + NativePrimCall + d + (primRepCmmType platform . argPrimRep) + nv_args + + args_ptrs :: [(Bool, ByteOff)] + args_ptrs = + map (\(r, off) -> + (isFollowableArg (toArgRep platform . argPrimRep $ r), off)) + args_offsets + + push_target = PUSH_UBX (LitLabel target Nothing IsFunction) 1 + push_info = PUSH_UBX (mkNativeCallInfoLit platform args_info) 1 + {- + compute size to move payload (without stg_primcall_info header) + + size of arguments plus three words for: + - function pointer to the target + - call_info word + - BCO to describe the stack frame + -} + szb = wordsToBytes platform (nativeCallSize args_info + 3) + go _ pushes [] = return (reverse pushes) + go !dd pushes ((a, off):cs) = do (push, szb) <- pushAtom dd p a + massert (off == dd + szb) + go (dd + szb) (push:pushes) cs + push_args <- go d [] args_offsets + args_bco <- emitBc (primCallBCO platform args_info args_ptrs) + return $ mconcat push_args `appOL` + (push_target `consOL` + push_info `consOL` + PUSH_BCO args_bco `consOL` + (mkSlideB platform szb (d - s) `appOL` unitOL PRIMCALL)) + -- ----------------------------------------------------------------------------- -- Deal with a CCall. @@ -1259,11 +1354,17 @@ generateCCall -> Type -> [StgArg] -- args (atoms) -> BcM BCInstrList -generateCCall d0 s p (CCallSpec target cconv safety) result_ty args_r_to_l +generateCCall d0 s p (CCallSpec target PrimCallConv _) result_ty args + | (StaticTarget _ label mb_unit _) <- target + = generatePrimCall d0 s p label mb_unit result_ty args + | otherwise + = panic "GHC.StgToByteCode.generateCCall: primcall convention only supports static targets" +generateCCall d0 s p (CCallSpec target cconv safety) result_ty args = do profile <- getProfile let + args_r_to_l = reverse args platform = profilePlatform profile -- useful constants addr_size_b :: ByteOff @@ -2007,7 +2108,7 @@ isSupportedCConv :: CCallSpec -> Bool isSupportedCConv (CCallSpec _ cconv _) = case cconv of CCallConv -> True -- we explicitly pattern match on every StdCallConv -> True -- convention to ensure that a warning - PrimCallConv -> False -- is triggered when a new one is added + PrimCallConv -> True -- is triggered when a new one is added JavaScriptCallConv -> False CApiConv -> True ===================================== compiler/GHC/StgToCmm/Foreign.hs ===================================== @@ -15,8 +15,8 @@ module GHC.StgToCmm.Foreign ( emitLoadThreadState, emitSaveRegs, emitRestoreRegs, - emitPushTupleRegs, - emitPopTupleRegs, + emitPushArgRegs, + emitPopArgRegs, loadThreadState, emitOpenNursery, emitCloseNursery, @@ -349,7 +349,7 @@ emitRestoreRegs = do -- bytecode interpreter. -- -- The "live registers" bitmap corresponds to the list of registers given by --- 'tupleRegsCover', with the least significant bit indicating liveness of +-- 'allArgRegsCover', with the least significant bit indicating liveness of -- the first register in the list. -- -- Each register is saved to a stack slot of one or more machine words, even @@ -362,12 +362,12 @@ emitRestoreRegs = do -- if((mask & 2) != 0) { Sp_adj(-1); Sp(0) = R2; } -- if((mask & 1) != 0) { Sp_adj(-1); Sp(0) = R1; } -- --- See Note [GHCi tuple layout] +-- See Note [GHCi and native call registers] -emitPushTupleRegs :: CmmExpr -> FCode () -emitPushTupleRegs regs_live = do +emitPushArgRegs :: CmmExpr -> FCode () +emitPushArgRegs regs_live = do platform <- getPlatform - let regs = zip (tupleRegsCover platform) [0..] + let regs = zip (allArgRegsCover platform) [0..] save_arg (reg, n) = let mask = CmmLit (CmmInt (1 `shiftL` n) (wordWidth platform)) live = cmmAndWord platform regs_live mask @@ -381,11 +381,11 @@ emitPushTupleRegs regs_live = do in mkCmmIfThen cond $ catAGraphs [adj_sp, save_reg] emit . catAGraphs =<< mapM save_arg (reverse regs) --- | Pop a subset of STG registers from the stack (see 'emitPushTupleRegs') -emitPopTupleRegs :: CmmExpr -> FCode () -emitPopTupleRegs regs_live = do +-- | Pop a subset of STG registers from the stack (see 'emitPushArgRegs') +emitPopArgRegs :: CmmExpr -> FCode () +emitPopArgRegs regs_live = do platform <- getPlatform - let regs = zip (tupleRegsCover platform) [0..] + let regs = zip (allArgRegsCover platform) [0..] save_arg (reg, n) = let mask = CmmLit (CmmInt (1 `shiftL` n) (wordWidth platform)) live = cmmAndWord platform regs_live mask ===================================== rts/Disassembler.c ===================================== @@ -83,6 +83,9 @@ disInstr ( StgBCO *bco, int pc ) debugBelch("CCALL marshaller at 0x%" FMT_HexWord "\n", literals[instrs[pc]] ); pc += 1; break; + case bci_PRIMCALL: + debugBelch("PRIMCALL\n"); + break; case bci_STKCHECK: { StgWord stk_words_reqd = BCO_GET_LARGE_ARG + 1; debugBelch("STKCHECK %" FMT_Word "\n", (W_)stk_words_reqd ); ===================================== rts/Interpreter.c ===================================== @@ -2038,6 +2038,12 @@ run_BCO: goto nextInsn; } + case bci_PRIMCALL: { + Sp_subW(1); + SpW(0) = (W_)&stg_primcall_info; + RETURN_TO_SCHEDULER_NO_PAUSE(ThreadRunGHC, ThreadYielding); + } + case bci_CCALL: { void *tok; int stk_offset = BCO_NEXT; ===================================== rts/RtsSymbols.c ===================================== @@ -602,6 +602,7 @@ extern char **environ; SymI_HasDataProto(stg_ret_l_info) \ SymI_HasDataProto(stg_ret_t_info) \ SymI_HasDataProto(stg_ctoi_t) \ + SymI_HasDataProto(stg_primcall_info) \ SymI_HasDataProto(stg_gc_prim_p) \ SymI_HasDataProto(stg_gc_prim_pp) \ SymI_HasDataProto(stg_gc_prim_n) \ ===================================== rts/StgMiscClosures.cmm ===================================== @@ -366,20 +366,10 @@ MK_STG_CTOI_T(61) MK_STG_CTOI_T(62) /* - Note [GHCi tuple layout] - ~~~~~~~~~~~~~~~~~~~~~~~~ - the tuple_info word describes the register and stack usage of the tuple: + Convert a tuple return value to be used in bytecode. - [ ssss ssss rrrr rrrr rrrr rrrr rrrr rrrr ] - - - r: bitmap of live registers, corresponding to the list of registers - returned by GHC.Cmm.CallConv.tupleRegsCover (the least significant - bit corresponds to the first element in the list) - - s: number of words on stack (in addition to registers) - - The order of the live registers in the bitmap is the same as the list - given by GHC.Cmm.CallConv.tupleRegsCover, with the least significant - bit corresponding to the first register in the list. + See Note [GHCi and native call registers] for information on how + values are moved between the stack and registers. */ stg_ctoi_t @@ -402,7 +392,7 @@ stg_ctoi_t Sp = Sp - WDS(tuple_stack); - PUSH_TUPLE_REGS(tuple_info); + PUSH_ARG_REGS(tuple_info); /* jump to the BCO that will finish the return of the tuple */ Sp_adj(-3); @@ -423,13 +413,57 @@ INFO_TABLE_RET( stg_ret_t, RET_BCO ) /* number of words spilled on stack */ tuple_stack = (tuple_info >> 24) & 0xff; - POP_TUPLE_REGS(tuple_info); + POP_ARG_REGS(tuple_info); /* Sp points to the topmost argument now */ jump %ENTRY_CODE(Sp(tuple_stack)) [*]; // NB. all registers live! } + /* + + The stg_primcall frame is used by the bytecode interpreter to call + a Cmm function. The frame contains a call_info word that contains + a bitmap describing the register arguments. + + When the target function is called, Sp points to the topmost stack + argument. + + ... + next_stack_frame + arg_1 + arg_2 + ... + arg_n + target_funptr (pointer to the function we're calling) + call_info (describes the registers containing the arguments) + primcall_BCO (contains bitmap describing pointers in args) + stg_primcall_info <- Sp + + See Note [GHCi and native call registers] for information on the call_info + word and how registers are moved between the stack and registers. + + */ + +INFO_TABLE_RET ( stg_primcall, RET_BCO ) +{ + W_ args_info, prim_fun; + + /* Sp(1) would be the BCO containing the stack description bitmap */ + args_info = Sp(2); + prim_fun = Sp(3); + + Sp_adj(4); + + /* Sp points to the top of the register arguments now, + load them into actual registers */ + POP_ARG_REGS(args_info); + + /* Sp points to the topmost stack argument now */ + + jump prim_fun [*]; // NB. all registers live! +} + /* * Dummy info table pushed on the top of the stack when the interpreter * should apply the BCO on the stack to its arguments, also on the ===================================== rts/include/rts/Bytecodes.h ===================================== @@ -112,6 +112,8 @@ #define bci_TESTLT_W8 85 #define bci_TESTEQ_W8 86 +#define bci_PRIMCALL 87 + /* If you need to go past 255 then you will run into the flags */ /* If you need to go below 0x0100 then you will run into the instructions */ ===================================== rts/include/stg/MiscClosures.h ===================================== @@ -160,6 +160,7 @@ RTS_RET(stg_ctoi_t60); RTS_RET(stg_ctoi_t61); RTS_RET(stg_ctoi_t62); +RTS_RET(stg_primcall); RTS_RET(stg_apply_interp); RTS_RET(stg_dead_thread); ===================================== testsuite/tests/ghci/prog014/prog014.T ===================================== @@ -1,6 +1,5 @@ test('prog014', [extra_files(['Primop.hs', 'dummy.c']), - expect_fail, # bytecode compiler doesn't support foreign import prim extra_run_opts('dummy.o'), pre_cmd('$MAKE -s --no-print-directory prog014')], ghci_script, ['prog014.script']) ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs ===================================== @@ -0,0 +1,279 @@ +{-# LANGUAGE ForeignFunctionInterface, GHCForeignImportPrim, UnliftedFFITypes, MagicHash, UnboxedTuples #-} + +module Main where + +import GHC.Int +import GHC.Word +import GHC.Prim +import GHC.Exts +import GHC.Types +import Unsafe.Coerce +import GHC.IO + +data Box (a :: UnliftedType) = MkBox a + +i2a :: Int -> Any +i2a = unsafeCoerce + +a2i :: Any -> Int +a2i = unsafeCoerce + +main :: IO () +main = do + + let i8s :: [Int8] + i8s = [0, -1, 1, minBound, maxBound] + + i16s :: [Int16] + i16s = [0, -1, 1, minBound, maxBound] + + i32s :: [Int32] + i32s = [0, -1, 1, minBound, maxBound] + + i64s :: [Int64] + i64s = [0, -1, 1, minBound, maxBound] + + ws :: [Word] + ws = [0, 1, 2, maxBound] + + fs :: [Float] + fs = [-0, 0, -1, 1, -2, 2, 1/0, 1e37, -1e-37] + + ds :: [Double] + ds = [-0, 0, -1, 1, -2, 2, 1/0, 1e307, -1e-307] + + ls :: [Word64] + ls = [0, 1, 2, 4294967296, maxBound] + + mi2a :: Maybe Integer -> Any + mi2a = unsafeCoerce + + a2mi :: Any -> Maybe Integer + a2mi = unsafeCoerce + + a0, a1, a2, a3 :: Any + a0 = mi2a Nothing + a1 = mi2a (Just 1) + a2 = mi2a (Just 18446744073709551617) + a3 = mi2a (Just (-18446744073709551617)) + + as :: [Any] + as = [a0, a1, a2, a3] + + + putStrLn "zero arguments" + IO (\st -> case cmm_zero st of (# st' #) -> (# st', () #)) + print =<< IO (\st -> case cmm_zero_w st of (# st', w #) -> (# st', W# w #)) + print =<< IO (\st -> case cmm_zero_d st of (# st', w #) -> (# st', D# w #)) + print =<< IO (\st -> case cmm_zero_f st of (# st', w #) -> (# st', F# w #)) + + -- XXX zero argument functions + + putStrLn "one argument functions" + print [ I8# (cmm_one1_i8 x) | (I8# x) <- i8s ] + print [ I16# (cmm_one1_i16 x) | (I16# x) <- i16s ] + print [ I32# (cmm_one1_i32 x) | (I32# x) <- i32s ] + print [ I64# (cmm_one1_i64 x) | (I64# x) <- i64s ] + print [ case cmm_one1_p x of (# y #) -> a2mi y | x <- as ] + print [ W# (cmm_one1_w x) | (W# x) <- ws ] + print [ F# (cmm_one1_f x) | (F# x) <- fs ] + print [ D# (cmm_one1_d x) | (D# x) <- ds ] + print [ W64# (cmm_one1_l x) | (W64# x) <- ls ] + + print [ case cmm_one2_i8 x of (# y1, y2 #) -> (I8# y1, I8# y2) | (I8# x) <- i8s ] + print [ case cmm_one2_i16 x of (# y1, y2 #) -> (I16# y1, I16# y2) | (I16# x) <- i16s ] + print [ case cmm_one2_i32 x of (# y1, y2 #) -> (I32# y1, I32# y2) | (I32# x) <- i32s ] + print [ case cmm_one2_i64 x of (# y1, y2 #) -> (I64# y1, I64# y2) | (I64# x) <- i64s ] + print [ case cmm_one2_p x of (# y1, y2 #) -> (a2mi y1, a2mi y2) | x <- as ] + print [ case cmm_one2_w x of (# y1, y2 #) -> (W# y1, W# y2) | (W# x) <- ws ] + print [ case cmm_one2_f x of (# y1, y2 #) -> (F# y1, F# y2) | (F# x) <- fs ] + print [ case cmm_one2_d x of (# y1, y2 #) -> (D# y1, D# y2) | (D# x) <- ds ] + print [ case cmm_one2_l x of (# y1, y2 #) -> (W64# y1, W64# y2) | (W64# x) <- ls ] + + putStrLn "two argument functions" + print [ I8# (cmm_two1_i8 x1 x2) | (I8# x1) <- i8s, (I8# x2) <- i8s ] + print [ I16# (cmm_two1_i16 x1 x2) | (I16# x1) <- i16s, (I16# x2) <- i16s ] + print [ I32# (cmm_two1_i32 x1 x2) | (I32# x1) <- i32s, (I32# x2) <- i32s ] + print [ I64# (cmm_two1_i64 x1 x2) | (I64# x1) <- i64s, (I64# x2) <- i64s ] + print [ case cmm_two1_p x1 x2 of (# y #) -> a2mi y | x1 <- as, x2 <- as ] + print [ W# (cmm_two1_w x1 x2) | (W# x1) <- ws, (W# x2) <- ws ] + print [ F# (cmm_two1_f x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_two1_d x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ W64# (cmm_two1_l x1 x2) | (W64# x1) <- ls, (W64# x2) <- ls ] + + print [ I8# (cmm_two2_i8 x1 x2) | (I8# x1) <- i8s, (I8# x2) <- i8s ] + print [ I16# (cmm_two2_i16 x1 x2) | (I16# x1) <- i16s, (I16# x2) <- i16s ] + print [ I32# (cmm_two2_i32 x1 x2) | (I32# x1) <- i32s, (I32# x2) <- i32s ] + print [ I64# (cmm_two2_i64 x1 x2) | (I64# x1) <- i64s, (I64# x2) <- i64s ] + print [ case cmm_two2_p x1 x2 of (# y #) -> a2mi y | x1 <- as, x2 <- as ] + print [ W# (cmm_two2_w x1 x2) | (W# x1) <- ws, (W# x2) <- ws ] + print [ F# (cmm_two2_f x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_two2_d x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ W64# (cmm_two2_l x1 x2) | (W64# x1) <- ls, (W64# x2) <- ls ] + + putStrLn "additional floating point tests" + print [ F# (cmm_floating_1 x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_floating_2 x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ F# (cmm_floating_3 x1 x2) | (F# x1) <- fs, (D# x2) <- ds ] + print [ D# (cmm_floating_4 x1 x2) | (F# x1) <- fs, (D# x2) <- ds ] + print [ case cmm_floating_5 x1 x2 3.0e1# 4.0e2## 5.0e3# 6.0e4## 7.0e5# 8.0e6## of (# y1, y2 #) -> (F# y1, D# y2) + | (F# x1) <- fs, (D# x2) <- ds ] + print [ case cmm_floating_6 x1 x2 3.0e1## 4.0e2# 5.0e3## 6.0e4# 7.0e5## 8.0e6# of (# y1, y2 #) -> (D# y1, F# y2) + | (D# x1) <- ds, (F# x2) <- fs ] + print [ case cmm_floating_7 w1 x1 x2 + 4## 5.0e1# 6.0e2## + 7## 8.0e3# 9.0e4## + 10## 11.0e5# 12.0e6## + 13## 14.0e7# 15.0e8## + 16## 17.0e9# 18.0e10## + 19## 20.0e11# 21.0e12## of (# y1, y2, y3 #) -> (W# y1, F# y2, D# y3) + | (W# w1) <- ws, (F# x1) <- fs, (D# x2) <- ds ] + + putStrLn "various sized tuple returns" + print [ case cmm_tuple_1 x1 x2 3## of (# y1, y2, y3 #) -> (W# y1, W# y2, W# y3) | (W# x1) <- ws, (W# x2) <- ws] + print [ case cmm_tuple_2 x1 x2 3## 4## a0 a1 7.0## 8.0## a2 a3 11.0# 12.0# + of (# y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12 #) -> + (F# y1, F# y2, a2mi y3, a2mi y4, D# y5, D# y6, a2mi y7, a2mi y8, W# y9, W# y10, a2mi y11, a2mi y12) + | x1 <- as, x2 <- as ] + print [ case cmm_tuple_3 x1 x2 a0 3.0## a1 5.0# + of (# y1, y2, y3, y4, y5, y6 #) -> (F# y1, a2mi y2, D# y3, a2mi y4, W# y5, a2mi y6) + | x1 <- as, (W# x2) <- ws ] + print [ case cmm_tuple_4 x1 x2 of (# y1, y2 #) -> (a2mi y1, a2mi y2) | x1 <- as, x2 <- as ] + + putStrLn "arrays" + MkBox marr0 <- IO (\s -> case newArray# 10# a0 s of (# s', a #) -> (# s', MkBox a #)) + MkBox marr1 <- IO (\s -> case newArray# 12# a1 s of (# s', a #) -> (# s', MkBox a #)) + MkBox arr0 <- IO (\s -> case unsafeFreezeArray# marr0 s of (# s', a #) -> (# s', MkBox a #)) + MkBox arr1 <- IO (\s -> case unsafeFreezeArray# marr1 s of (# s', a #) -> (# s', MkBox a #)) + print (I# (cmm_array_1 arr0), I# (cmm_array_1 arr1)) + case cmm_array_2 arr0 arr1 of (# arr2, arr3 #) -> print (I# (cmm_array_1 arr2), I# (cmm_array_1 arr3)) + + putStrLn "many arguments" + print (W# (cmm_many_arguments 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## 65## 66## 67## 68## 69## 70## 71## 72## 73## 74## 75## 76## 77## 78## 79## 80## 81## 82## 83## 84## 85## 86## 87## 88## 89## 90## 91## 92## 93## 94## 95## 96## 97## 98## 99## 100## 101## 102## 103## 104## 105## 106## 107## 108## 109## 110## 111## 112## 113## 114## 115## 116## 117## 118## 119## 120## 121## 122## 123## 124## 125## 126## 127## 128## 129## 130## 131## 132## 133## 134## 135## 136## 137## 138## 139## 140## 141## 142## 143## 144## 145## 146## 147## 148## 149## 150## 151## 152## 153## 154## 155## 156## 157## 158## 159## 160## 161## 162## 163## 164## 165## 166## 167## 168## 169## 170## 171## 172## 173## 174## 175## 176## 177## 178## 179## 180## 181## 182## 183## 184## 185## 186## 187## 188## 189## 190## 191## 192## 193## 194## 195## 196## 197## 198## 199## 200## 201## 202## 203## 204## 205## 206## 207## 208## 209## 210## 211## 212## 213## 214## 215## 216## 217## 218## 219## 220## 221## 222## 223## 224## 225## 226## 227## 228## 229## 230## 231## 232## 233## 234## 235## 236## 237## 238## 239## 240## 241## 242## 243## 244## 245## 246## 247## 248## 249## 250## 251## 252## 253## 254## 255## 256## 257## 258## 259## 260## 261## 262## 263## 264## 265## 266## 267## 268## 269## 270## 271## 272## 273## 274## 275## 276## 277## 278## 279## 280## 281## 282## 283## 284## 285## 286## 287## 288## 289## 290## 291## 292## 293## 294## 295## 296## 297## 298## 299## 300## 301## 302## 303## 304## 305## 306## 307## 308## 309## 310## 311## 312## 313## 314## 315## 316## 317## 318## 319## 320## 321## 322## 323## 324## 325## 326## 327## 328## 329## 330## 331## 332## 333## 334## 335## 336## 337## 338## 339## 340## 341## 342## 343## 344## 345## 346## 347## 348## 349## 350## 351## 352## 353## 354## 355## 356## 357## 358## 359## 360## 361## 362## 363## 364## 365## 366## 367## 368## 369## 370## 371## 372## 373## 374## 375## 376## 377## 378## 379## 380## 381## 382## 383## 384## 385## 386## 387## 388## 389## 390## 391## 392## 393## 394## 395## 396## 397## 398## 399## 400##)) + +-- XXX why don't we accept State# RealWorld -> State# RealWorld ? +foreign import prim cmm_zero :: State# RealWorld -> (# State# RealWorld #) +foreign import prim cmm_zero_w :: State# RealWorld -> (# State# RealWorld, Word# #) +foreign import prim cmm_zero_d :: State# RealWorld -> (# State# RealWorld, Double# #) +foreign import prim cmm_zero_f :: State# RealWorld -> (# State# RealWorld, Float# #) + +-- one argument functions +foreign import prim cmm_one1_i8 :: Int8# -> Int8# +foreign import prim cmm_one1_i16 :: Int16# -> Int16# +foreign import prim cmm_one1_i32 :: Int32# -> Int32# +foreign import prim cmm_one1_i64 :: Int64# -> Int64# +foreign import prim cmm_one1_p :: Any -> (# Any #) +foreign import prim cmm_one1_w :: Word# -> Word# +foreign import prim cmm_one1_f :: Float# -> Float# +foreign import prim cmm_one1_d :: Double# -> Double# +foreign import prim cmm_one1_l :: Word64# -> Word64# + +foreign import prim cmm_one2_i8 :: Int8# -> (# Int8#, Int8# #) +foreign import prim cmm_one2_i16 :: Int16# -> (# Int16#, Int16# #) +foreign import prim cmm_one2_i32 :: Int32# -> (# Int32#, Int32# #) +foreign import prim cmm_one2_i64 :: Int64# -> (# Int64#, Int64# #) +foreign import prim cmm_one2_p :: Any -> (# Any, Any #) +foreign import prim cmm_one2_w :: Word# -> (# Word#, Word# #) +foreign import prim cmm_one2_f :: Float# -> (# Float#, Float# #) +foreign import prim cmm_one2_d :: Double# -> (# Double#, Double# #) +foreign import prim cmm_one2_l :: Word64# -> (# Word64#, Word64# #) + +-- two argument functions +foreign import prim cmm_two1_i8 :: Int8# -> Int8# -> Int8# +foreign import prim cmm_two1_i16 :: Int16# -> Int16# -> Int16# +foreign import prim cmm_two1_i32 :: Int32# -> Int32# -> Int32# +foreign import prim cmm_two1_i64 :: Int64# -> Int64# -> Int64# +foreign import prim cmm_two1_p :: Any -> Any -> (# Any #) +foreign import prim cmm_two1_w :: Word# -> Word# -> Word# +foreign import prim cmm_two1_f :: Float# -> Float# -> Float# +foreign import prim cmm_two1_d :: Double# -> Double# -> Double# +foreign import prim cmm_two1_l :: Word64# -> Word64# -> Word64# + +foreign import prim cmm_two2_i8 :: Int8# -> Int8# -> Int8# +foreign import prim cmm_two2_i16 :: Int16# -> Int16# -> Int16# +foreign import prim cmm_two2_i32 :: Int32# -> Int32# -> Int32# +foreign import prim cmm_two2_i64 :: Int64# -> Int64# -> Int64# +foreign import prim cmm_two2_p :: Any -> Any -> (# Any #) +foreign import prim cmm_two2_w :: Word# -> Word# -> Word# +foreign import prim cmm_two2_f :: Float# -> Float# -> Float# +foreign import prim cmm_two2_d :: Double# -> Double# -> Double# +foreign import prim cmm_two2_l :: Word64# -> Word64# -> Word64# + +{- additional tests for floating point, since D_ and F_ registers + overlap on some platforms -} + +foreign import prim cmm_floating_1 :: Float# -> Float# -> Float# +foreign import prim cmm_floating_2 :: Double# -> Double# -> Double# +foreign import prim cmm_floating_3 :: Float# -> Double# -> Float# +foreign import prim cmm_floating_4 :: Float# -> Double# -> Double# +foreign import prim cmm_floating_5 :: Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> (# Float#, Double# #) +foreign import prim cmm_floating_6 :: Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> (# Double#, Float# #) +foreign import prim cmm_floating_7 :: Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> (# Word#, Float#, Double# #) +-- various sized tuple returns + +foreign import prim cmm_tuple_1 :: Word# -> Word# -> Word# -> (# Word# , Word#, Word# #) +foreign import prim cmm_tuple_2 :: Any -> Any -> Word# -> Word# -> Any -> Any -> Double# -> Double# -> Any -> Any -> Float# -> Float# -> + (# Float#, Float#, Any, Any, Double#, Double#, Any, Any, Word#, Word#, Any, Any #) +foreign import prim cmm_tuple_3 :: Any -> Word# -> Any -> Double# -> Any -> Float# -> + (# Float#, Any, Double#, Any, Word#, Any #) +foreign import prim cmm_tuple_4 :: Any -> Any -> (# Any, Any #) + +-- boxed primitive types + +-- get the length of an array +foreign import prim cmm_array_1 :: Array# Any -> Int# +-- return some arrays +foreign import prim cmm_array_2 :: Array# Any -> Array# Any -> (# Array# Any, Array# Any #) + +foreign import prim cmm_many_arguments :: + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout ===================================== @@ -0,0 +1,60 @@ +zero arguments +123 +1.0 +1.0 +one argument functions +[0,-1,1,-128,127] +[0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,18446744073709551615] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615] +[(0,0),(-1,-1),(1,1),(-128,-128),(127,127)] +[(0,0),(-1,-1),(1,1),(-32768,-32768),(32767,32767)] +[(0,0),(-1,-1),(1,1),(-2147483648,-2147483648),(2147483647,2147483647)] +[(0,0),(-1,-1),(1,1),(-9223372036854775808,-9223372036854775808),(9223372036854775807,9223372036854775807)] +[(Nothing,Nothing),(Just 1,Just 1),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just (-18446744073709551617))] +[(0,0),(1,1),(2,2),(18446744073709551615,18446744073709551615)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e37,1.0e37),(-1.0e-37,-1.0e-37)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e307,1.0e307),(-1.0e-307,-1.0e-307)] +[(0,0),(1,1),(2,2),(4294967296,4294967296),(18446744073709551615,18446744073709551615)] +two argument functions +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-128,-128,-128,-128,-128,127,127,127,127,127] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-32768,-32768,-32768,-32768,-32768,32767,32767,32767,32767,32767] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,2147483647,2147483647,2147483647,2147483647,2147483647] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807] +[Nothing,Nothing,Nothing,Nothing,Just 1,Just 1,Just 1,Just 1,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617)] +[0,0,0,0,1,1,1,1,2,2,2,2,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307] +[0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,4294967296,4294967296,4294967296,4294967296,4294967296,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127] +[0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,18446744073709551615,0,1,2,18446744073709551615,0,1,2,18446744073709551615,0,1,2,18446744073709551615] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615] +additional floating point tests +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e37,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e37,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e37,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e37,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,Infinity,2.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-2.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e307,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e307,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e307,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e307,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,Infinity,2.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-2.0e-307] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e307),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e307),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e307),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e307),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e307),(Infinity,8060400.0),(1.0e37,8060400.0),(1.0e37,8060400.0),(1.0e37,8060399.0),(1.0e37,8060401.0),(1.0e37,8060398.0),(1.0e37,8060402.0),(1.0e37,Infinity),(1.0e37,1.0e307),(1.0e37,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0)] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e37),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e37),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e37),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e37),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e37),(Infinity,8060400.0),(1.0e307,8060400.0),(1.0e307,8060400.0),(1.0e307,8060399.0),(1.0e307,8060401.0),(1.0e307,8060398.0),(1.0e307,8060402.0),(1.0e307,Infinity),(1.0e307,1.0e37),(1.0e307,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0)] +[(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.1181512090599e13),(69,Infinity,2.1181512090601e13),(69,Infinity,2.1181512090598e13),(69,Infinity,2.1181512090602e13),(69,Infinity,Infinity),(69,Infinity,1.0e307),(69,Infinity,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.1181512090599e13),(69,1.0e37,2.1181512090601e13),(69,1.0e37,2.1181512090598e13),(69,1.0e37,2.1181512090602e13),(69,1.0e37,Infinity),(69,1.0e37,1.0e307),(69,1.0e37,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.1181512090599e13),(70,Infinity,2.1181512090601e13),(70,Infinity,2.1181512090598e13),(70,Infinity,2.1181512090602e13),(70,Infinity,Infinity),(70,Infinity,1.0e307),(70,Infinity,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.1181512090599e13),(70,1.0e37,2.1181512090601e13),(70,1.0e37,2.1181512090598e13),(70,1.0e37,2.1181512090602e13),(70,1.0e37,Infinity),(70,1.0e37,1.0e307),(70,1.0e37,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.1181512090599e13),(71,Infinity,2.1181512090601e13),(71,Infinity,2.1181512090598e13),(71,Infinity,2.1181512090602e13),(71,Infinity,Infinity),(71,Infinity,1.0e307),(71,Infinity,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.1181512090599e13),(71,1.0e37,2.1181512090601e13),(71,1.0e37,2.1181512090598e13),(71,1.0e37,2.1181512090602e13),(71,1.0e37,Infinity),(71,1.0e37,1.0e307),(71,1.0e37,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.1181512090599e13),(68,Infinity,2.1181512090601e13),(68,Infinity,2.1181512090598e13),(68,Infinity,2.1181512090602e13),(68,Infinity,Infinity),(68,Infinity,1.0e307),(68,Infinity,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.1181512090599e13),(68,1.0e37,2.1181512090601e13),(68,1.0e37,2.1181512090598e13),(68,1.0e37,2.1181512090602e13),(68,1.0e37,Infinity),(68,1.0e37,1.0e307),(68,1.0e37,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13)] +various sized tuple returns +[(3,0,0),(3,1,0),(3,2,0),(3,18446744073709551615,0),(3,0,1),(3,1,1),(3,2,1),(3,18446744073709551615,1),(3,0,2),(3,1,2),(3,2,2),(3,18446744073709551615,2),(3,0,18446744073709551615),(3,1,18446744073709551615),(3,2,18446744073709551615),(3,18446744073709551615,18446744073709551615)] +[(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just (-18446744073709551617))] +[(5.0,Just 1,3.0,Nothing,0,Nothing),(5.0,Just 1,3.0,Nothing,1,Nothing),(5.0,Just 1,3.0,Nothing,2,Nothing),(5.0,Just 1,3.0,Nothing,18446744073709551615,Nothing),(5.0,Just 1,3.0,Nothing,0,Just 1),(5.0,Just 1,3.0,Nothing,1,Just 1),(5.0,Just 1,3.0,Nothing,2,Just 1),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just 1),(5.0,Just 1,3.0,Nothing,0,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,1,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,2,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,0,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,1,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,2,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just (-18446744073709551617))] +[(Nothing,Nothing),(Just 1,Nothing),(Just 18446744073709551617,Nothing),(Just (-18446744073709551617),Nothing),(Nothing,Just 1),(Just 1,Just 1),(Just 18446744073709551617,Just 1),(Just (-18446744073709551617),Just 1),(Nothing,Just 18446744073709551617),(Just 1,Just 18446744073709551617),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just 18446744073709551617),(Nothing,Just (-18446744073709551617)),(Just 1,Just (-18446744073709551617)),(Just 18446744073709551617,Just (-18446744073709551617)),(Just (-18446744073709551617),Just (-18446744073709551617))] +arrays +(11,13) +(13,11) +many arguments +80200 ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout-ws-32 ===================================== @@ -0,0 +1,60 @@ +zero arguments +123 +1.0 +1.0 +one argument functions +[0,-1,1,-128,127] +[0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,4294967295] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615] +[(0,0),(-1,-1),(1,1),(-128,-128),(127,127)] +[(0,0),(-1,-1),(1,1),(-32768,-32768),(32767,32767)] +[(0,0),(-1,-1),(1,1),(-2147483648,-2147483648),(2147483647,2147483647)] +[(0,0),(-1,-1),(1,1),(-9223372036854775808,-9223372036854775808),(9223372036854775807,9223372036854775807)] +[(Nothing,Nothing),(Just 1,Just 1),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just (-18446744073709551617))] +[(0,0),(1,1),(2,2),(4294967295,4294967295)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e37,1.0e37),(-1.0e-37,-1.0e-37)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e307,1.0e307),(-1.0e-307,-1.0e-307)] +[(0,0),(1,1),(2,2),(4294967296,4294967296),(18446744073709551615,18446744073709551615)] +two argument functions +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-128,-128,-128,-128,-128,127,127,127,127,127] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-32768,-32768,-32768,-32768,-32768,32767,32767,32767,32767,32767] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,2147483647,2147483647,2147483647,2147483647,2147483647] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807] +[Nothing,Nothing,Nothing,Nothing,Just 1,Just 1,Just 1,Just 1,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617)] +[0,0,0,0,1,1,1,1,2,2,2,2,4294967295,4294967295,4294967295,4294967295] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307] +[0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,4294967296,4294967296,4294967296,4294967296,4294967296,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127] +[0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,4294967295,0,1,2,4294967295,0,1,2,4294967295,0,1,2,4294967295] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615] +additional floating point tests +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e37,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e37,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e37,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e37,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,Infinity,2.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-2.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e307,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e307,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e307,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e307,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,Infinity,2.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-2.0e-307] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e307),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e307),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e307),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e307),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e307),(Infinity,8060400.0),(1.0e37,8060400.0),(1.0e37,8060400.0),(1.0e37,8060399.0),(1.0e37,8060401.0),(1.0e37,8060398.0),(1.0e37,8060402.0),(1.0e37,Infinity),(1.0e37,1.0e307),(1.0e37,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0)] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e37),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e37),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e37),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e37),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e37),(Infinity,8060400.0),(1.0e307,8060400.0),(1.0e307,8060400.0),(1.0e307,8060399.0),(1.0e307,8060401.0),(1.0e307,8060398.0),(1.0e307,8060402.0),(1.0e307,Infinity),(1.0e307,1.0e37),(1.0e307,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0)] +[(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.1181512090599e13),(69,Infinity,2.1181512090601e13),(69,Infinity,2.1181512090598e13),(69,Infinity,2.1181512090602e13),(69,Infinity,Infinity),(69,Infinity,1.0e307),(69,Infinity,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.1181512090599e13),(69,1.0e37,2.1181512090601e13),(69,1.0e37,2.1181512090598e13),(69,1.0e37,2.1181512090602e13),(69,1.0e37,Infinity),(69,1.0e37,1.0e307),(69,1.0e37,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.1181512090599e13),(70,Infinity,2.1181512090601e13),(70,Infinity,2.1181512090598e13),(70,Infinity,2.1181512090602e13),(70,Infinity,Infinity),(70,Infinity,1.0e307),(70,Infinity,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.1181512090599e13),(70,1.0e37,2.1181512090601e13),(70,1.0e37,2.1181512090598e13),(70,1.0e37,2.1181512090602e13),(70,1.0e37,Infinity),(70,1.0e37,1.0e307),(70,1.0e37,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.1181512090599e13),(71,Infinity,2.1181512090601e13),(71,Infinity,2.1181512090598e13),(71,Infinity,2.1181512090602e13),(71,Infinity,Infinity),(71,Infinity,1.0e307),(71,Infinity,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.1181512090599e13),(71,1.0e37,2.1181512090601e13),(71,1.0e37,2.1181512090598e13),(71,1.0e37,2.1181512090602e13),(71,1.0e37,Infinity),(71,1.0e37,1.0e307),(71,1.0e37,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.1181512090599e13),(68,Infinity,2.1181512090601e13),(68,Infinity,2.1181512090598e13),(68,Infinity,2.1181512090602e13),(68,Infinity,Infinity),(68,Infinity,1.0e307),(68,Infinity,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.1181512090599e13),(68,1.0e37,2.1181512090601e13),(68,1.0e37,2.1181512090598e13),(68,1.0e37,2.1181512090602e13),(68,1.0e37,Infinity),(68,1.0e37,1.0e307),(68,1.0e37,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13)] +various sized tuple returns +[(3,0,0),(3,1,0),(3,2,0),(3,4294967295,0),(3,0,1),(3,1,1),(3,2,1),(3,4294967295,1),(3,0,2),(3,1,2),(3,2,2),(3,4294967295,2),(3,0,4294967295),(3,1,4294967295),(3,2,4294967295),(3,4294967295,4294967295)] +[(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just (-18446744073709551617))] +[(5.0,Just 1,3.0,Nothing,0,Nothing),(5.0,Just 1,3.0,Nothing,1,Nothing),(5.0,Just 1,3.0,Nothing,2,Nothing),(5.0,Just 1,3.0,Nothing,4294967295,Nothing),(5.0,Just 1,3.0,Nothing,0,Just 1),(5.0,Just 1,3.0,Nothing,1,Just 1),(5.0,Just 1,3.0,Nothing,2,Just 1),(5.0,Just 1,3.0,Nothing,4294967295,Just 1),(5.0,Just 1,3.0,Nothing,0,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,1,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,2,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,4294967295,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,0,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,1,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,2,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,4294967295,Just (-18446744073709551617))] +[(Nothing,Nothing),(Just 1,Nothing),(Just 18446744073709551617,Nothing),(Just (-18446744073709551617),Nothing),(Nothing,Just 1),(Just 1,Just 1),(Just 18446744073709551617,Just 1),(Just (-18446744073709551617),Just 1),(Nothing,Just 18446744073709551617),(Just 1,Just 18446744073709551617),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just 18446744073709551617),(Nothing,Just (-18446744073709551617)),(Just 1,Just (-18446744073709551617)),(Just 18446744073709551617,Just (-18446744073709551617)),(Just (-18446744073709551617),Just (-18446744073709551617))] +arrays +(11,13) +(13,11) +many arguments +80200 ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm ===================================== @@ -0,0 +1,230 @@ +#include "Cmm.h" + +/* zero arguments */ +cmm_zero() { /* ccall puts("cmm_zero"); buffering gets in the way */ return (); } +cmm_zero_w() { return (123::W_); } +cmm_zero_d() { return (1.0::D_); } +cmm_zero_f() { return (1.0::F_); } +cmm_zero_l() { return (123::L_); } + +/* one argument functions */ +cmm_one1_i8(I8 x) { return (x); } +cmm_one1_i16(I16 x) { return (x); } +cmm_one1_i32(I32 x) { return (x); } +cmm_one1_i64(I64 x) { return (x); } +cmm_one1_p(P_ x) { return (x); } +cmm_one1_w(W_ x) { return (x); } +cmm_one1_f(F_ x) { return (x); } +cmm_one1_d(D_ x) { return (x); } +cmm_one1_l(L_ x) { return (x); } + +cmm_one2_i8(I8 x) { return (x,x); } +cmm_one2_i16(I16 x) { return (x,x); } +cmm_one2_i32(I32 x) { return (x,x); } +cmm_one2_i64(I64 x) { return (x,x); } +cmm_one2_p(P_ x) { return (x,x); } +cmm_one2_w(W_ x) { return (x,x); } +cmm_one2_f(F_ x) { return (x,x); } +cmm_one2_d(D_ x) { return (x,x); } +cmm_one2_l(L_ x) { return (x,x); } + + +/* two argument functions */ +cmm_two1_i8(I8 x, I8 y) { return (x); } +cmm_two1_i16(I16 x, I16 y) { return (x); } +cmm_two1_i32(I32 x, I32 y) { return (x); } +cmm_two1_i64(I64 x, I64 y) { return (x); } +cmm_two1_p(P_ x, P_ y) { return (x); } +cmm_two1_w(W_ x, W_ y) { return (x); } +cmm_two1_f(F_ x, F_ y) { return (x); } +cmm_two1_d(D_ x, D_ y) { return (x); } +cmm_two1_l(L_ x, L_ y) { return (x); } + +cmm_two2_i8(I8 x, I8 y) { return (y); } +cmm_two2_i16(I16 x, I16 y) { return (y); } +cmm_two2_i32(I32 x, I32 y) { return (y); } +cmm_two2_i64(I64 x, I64 y) { return (y); } +cmm_two2_p(P_ x, P_ y) { return (y); } +cmm_two2_w(W_ x, W_ y) { return (y); } +cmm_two2_f(F_ x, F_ y) { return (y); } +cmm_two2_d(D_ x, D_ y) { return (y); } +cmm_two2_l(L_ x, L_ y) { return (y); } + +/* additional tests for floating point, since D_ and F_ registers + overlap on some platforms */ +cmm_floating_1(F_ x, F_ y) { F_ z; z = %fadd(x, y); return (z); } +cmm_floating_2(D_ x, D_ y) { D_ z; z = %fadd(x, y); return (z); } +cmm_floating_3(F_ x, D_ y) { return (x); } +cmm_floating_4(F_ x, D_ y) { return (y); } + + +cmm_floating_5(F_ x1, D_ x2, F_ x3, D_ x4, F_ x5, D_ x6, F_ x7, D_ x8) { + F_ y1; + D_ y2; + + y1 = %fadd(x1,x3); + y1 = %fadd(y1,x5); + y1 = %fadd(y1,x7); + + y2 = %fadd(x2,x4); + y2 = %fadd(y2,x6); + y2 = %fadd(y2,x8); + + return (y1, y2); +} + + +cmm_floating_6(D_ x1, F_ x2, D_ x3, F_ x4, D_ x5, F_ x6, D_ x7, F_ x8) { + D_ y1; + F_ y2; + + y1 = %fadd(x1,x3); + y1 = %fadd(y1,x5); + y1 = %fadd(y1,x7); + + y2 = %fadd(x2,x4); + y2 = %fadd(y2,x6); + y2 = %fadd(y2,x8); + + return (y1, y2); +} + + +cmm_floating_7( W_ x1, F_ x2, D_ x3 + , W_ x4, F_ x5, D_ x6 + , W_ x7, F_ x8, D_ x9 + , W_ x10, F_ x11, D_ x12 + , W_ x13, F_ x14, D_ x15 + , W_ x16, F_ x17, D_ x18 + , W_ x19, F_ x20, D_ x21 + ) { + W_ y1; + F_ y2; + D_ y3; + y1 = x1+x4+x7+x10+x13+x16+x19; + + y2 = %fadd(x2,x5); + y2 = %fadd(y2,x8); + y2 = %fadd(y2,x11); + y2 = %fadd(y2,x14); + y2 = %fadd(y2,x17); + y2 = %fadd(y2,x20); + + y3 = %fadd(x3,x6); + y3 = %fadd(y3,x9); + y3 = %fadd(y3,x12); + y3 = %fadd(y3,x15); + y3 = %fadd(y3,x18); + y3 = %fadd(y3,x21); + + return ( y1, y2, y3 ); +} + + +/* various sized tuple returns */ + +cmm_tuple_1(W_ x, W_ y, W_ z) { return (z, y, x); } +cmm_tuple_2(P_ p1, P_ p2, W_ w1, W_ w2, P_ p3, P_ p4, D_ d1, D_ d2, P_ p5, P_ p6, F_ f1, F_ f2) { + return (f2, f1, p6, p5, d2, d1, p4, p3, w2, w1, p2, p1); +} +cmm_tuple_3(P_ p1, W_ w1, P_ p2, D_ d1, P_ p3, F_ f1) { + return (f1, p3, d1, p2, w1, p1); +} +cmm_tuple_4(P_ p1, P_ p2) { return (p2, p1); } + +/* working with arrays */ +cmm_array_1(P_ x) { + W_ size; + size = StgMutArrPtrs_size(x); + return (size); +} + +/* return two arrays */ +cmm_array_2(P_ x, P_ y) { + return (y, x); +} + +/* many arguments */ +cmm_many_arguments(W_ x1, W_ x2, W_ x3, W_ x4, W_ x5, W_ x6, W_ x7, W_ x8, W_ x9, W_ x10, + W_ x11, W_ x12, W_ x13, W_ x14, W_ x15, W_ x16, W_ x17, W_ x18, W_ x19, W_ x20, + W_ x21, W_ x22, W_ x23, W_ x24, W_ x25, W_ x26, W_ x27, W_ x28, W_ x29, W_ x30, + W_ x31, W_ x32, W_ x33, W_ x34, W_ x35, W_ x36, W_ x37, W_ x38, W_ x39, W_ x40, + W_ x41, W_ x42, W_ x43, W_ x44, W_ x45, W_ x46, W_ x47, W_ x48, W_ x49, W_ x50, + W_ x51, W_ x52, W_ x53, W_ x54, W_ x55, W_ x56, W_ x57, W_ x58, W_ x59, W_ x60, + W_ x61, W_ x62, W_ x63, W_ x64, W_ x65, W_ x66, W_ x67, W_ x68, W_ x69, W_ x70, + W_ x71, W_ x72, W_ x73, W_ x74, W_ x75, W_ x76, W_ x77, W_ x78, W_ x79, W_ x80, + W_ x81, W_ x82, W_ x83, W_ x84, W_ x85, W_ x86, W_ x87, W_ x88, W_ x89, W_ x90, + W_ x91, W_ x92, W_ x93, W_ x94, W_ x95, W_ x96, W_ x97, W_ x98, W_ x99, W_ x100, + W_ x101, W_ x102, W_ x103, W_ x104, W_ x105, W_ x106, W_ x107, W_ x108, W_ x109, W_ x110, + W_ x111, W_ x112, W_ x113, W_ x114, W_ x115, W_ x116, W_ x117, W_ x118, W_ x119, W_ x120, + W_ x121, W_ x122, W_ x123, W_ x124, W_ x125, W_ x126, W_ x127, W_ x128, W_ x129, W_ x130, + W_ x131, W_ x132, W_ x133, W_ x134, W_ x135, W_ x136, W_ x137, W_ x138, W_ x139, W_ x140, + W_ x141, W_ x142, W_ x143, W_ x144, W_ x145, W_ x146, W_ x147, W_ x148, W_ x149, W_ x150, + W_ x151, W_ x152, W_ x153, W_ x154, W_ x155, W_ x156, W_ x157, W_ x158, W_ x159, W_ x160, + W_ x161, W_ x162, W_ x163, W_ x164, W_ x165, W_ x166, W_ x167, W_ x168, W_ x169, W_ x170, + W_ x171, W_ x172, W_ x173, W_ x174, W_ x175, W_ x176, W_ x177, W_ x178, W_ x179, W_ x180, + W_ x181, W_ x182, W_ x183, W_ x184, W_ x185, W_ x186, W_ x187, W_ x188, W_ x189, W_ x190, + W_ x191, W_ x192, W_ x193, W_ x194, W_ x195, W_ x196, W_ x197, W_ x198, W_ x199, W_ x200, + W_ x201, W_ x202, W_ x203, W_ x204, W_ x205, W_ x206, W_ x207, W_ x208, W_ x209, W_ x210, + W_ x211, W_ x212, W_ x213, W_ x214, W_ x215, W_ x216, W_ x217, W_ x218, W_ x219, W_ x220, + W_ x221, W_ x222, W_ x223, W_ x224, W_ x225, W_ x226, W_ x227, W_ x228, W_ x229, W_ x230, + W_ x231, W_ x232, W_ x233, W_ x234, W_ x235, W_ x236, W_ x237, W_ x238, W_ x239, W_ x240, + W_ x241, W_ x242, W_ x243, W_ x244, W_ x245, W_ x246, W_ x247, W_ x248, W_ x249, W_ x250, + W_ x251, W_ x252, W_ x253, W_ x254, W_ x255, W_ x256, W_ x257, W_ x258, W_ x259, W_ x260, + W_ x261, W_ x262, W_ x263, W_ x264, W_ x265, W_ x266, W_ x267, W_ x268, W_ x269, W_ x270, + W_ x271, W_ x272, W_ x273, W_ x274, W_ x275, W_ x276, W_ x277, W_ x278, W_ x279, W_ x280, + W_ x281, W_ x282, W_ x283, W_ x284, W_ x285, W_ x286, W_ x287, W_ x288, W_ x289, W_ x290, + W_ x291, W_ x292, W_ x293, W_ x294, W_ x295, W_ x296, W_ x297, W_ x298, W_ x299, W_ x300, + W_ x301, W_ x302, W_ x303, W_ x304, W_ x305, W_ x306, W_ x307, W_ x308, W_ x309, W_ x310, + W_ x311, W_ x312, W_ x313, W_ x314, W_ x315, W_ x316, W_ x317, W_ x318, W_ x319, W_ x320, + W_ x321, W_ x322, W_ x323, W_ x324, W_ x325, W_ x326, W_ x327, W_ x328, W_ x329, W_ x330, + W_ x331, W_ x332, W_ x333, W_ x334, W_ x335, W_ x336, W_ x337, W_ x338, W_ x339, W_ x340, + W_ x341, W_ x342, W_ x343, W_ x344, W_ x345, W_ x346, W_ x347, W_ x348, W_ x349, W_ x350, + W_ x351, W_ x352, W_ x353, W_ x354, W_ x355, W_ x356, W_ x357, W_ x358, W_ x359, W_ x360, + W_ x361, W_ x362, W_ x363, W_ x364, W_ x365, W_ x366, W_ x367, W_ x368, W_ x369, W_ x370, + W_ x371, W_ x372, W_ x373, W_ x374, W_ x375, W_ x376, W_ x377, W_ x378, W_ x379, W_ x380, + W_ x381, W_ x382, W_ x383, W_ x384, W_ x385, W_ x386, W_ x387, W_ x388, W_ x389, W_ x390, + W_ x391, W_ x392, W_ x393, W_ x394, W_ x395, W_ x396, W_ x397, W_ x398, W_ x399, W_ x400) { + W_ y; + y = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + + x21 + x22 + x23 + x24 + x25 + x26 + x27 + x28 + x29 + x30 + + x31 + x32 + x33 + x34 + x35 + x36 + x37 + x38 + x39 + x40 + + x41 + x42 + x43 + x44 + x45 + x46 + x47 + x48 + x49 + x50 + + x51 + x52 + x53 + x54 + x55 + x56 + x57 + x58 + x59 + x60 + + x61 + x62 + x63 + x64 + x65 + x66 + x67 + x68 + x69 + x70 + + x71 + x72 + x73 + x74 + x75 + x76 + x77 + x78 + x79 + x80 + + x81 + x82 + x83 + x84 + x85 + x86 + x87 + x88 + x89 + x90 + + x91 + x92 + x93 + x94 + x95 + x96 + x97 + x98 + x99 + x100 + + x101 + x102 + x103 + x104 + x105 + x106 + x107 + x108 + x109 + x110 + + x111 + x112 + x113 + x114 + x115 + x116 + x117 + x118 + x119 + x120 + + x121 + x122 + x123 + x124 + x125 + x126 + x127 + x128 + x129 + x130 + + x131 + x132 + x133 + x134 + x135 + x136 + x137 + x138 + x139 + x140 + + x141 + x142 + x143 + x144 + x145 + x146 + x147 + x148 + x149 + x150 + + x151 + x152 + x153 + x154 + x155 + x156 + x157 + x158 + x159 + x160 + + x161 + x162 + x163 + x164 + x165 + x166 + x167 + x168 + x169 + x170 + + x171 + x172 + x173 + x174 + x175 + x176 + x177 + x178 + x179 + x180 + + x181 + x182 + x183 + x184 + x185 + x186 + x187 + x188 + x189 + x190 + + x191 + x192 + x193 + x194 + x195 + x196 + x197 + x198 + x199 + x200 + + x201 + x202 + x203 + x204 + x205 + x206 + x207 + x208 + x209 + x210 + + x211 + x212 + x213 + x214 + x215 + x216 + x217 + x218 + x219 + x220 + + x221 + x222 + x223 + x224 + x225 + x226 + x227 + x228 + x229 + x230 + + x231 + x232 + x233 + x234 + x235 + x236 + x237 + x238 + x239 + x240 + + x241 + x242 + x243 + x244 + x245 + x246 + x247 + x248 + x249 + x250 + + x251 + x252 + x253 + x254 + x255 + x256 + x257 + x258 + x259 + x260 + + x261 + x262 + x263 + x264 + x265 + x266 + x267 + x268 + x269 + x270 + + x271 + x272 + x273 + x274 + x275 + x276 + x277 + x278 + x279 + x280 + + x281 + x282 + x283 + x284 + x285 + x286 + x287 + x288 + x289 + x290 + + x291 + x292 + x293 + x294 + x295 + x296 + x297 + x298 + x299 + x300 + + x301 + x302 + x303 + x304 + x305 + x306 + x307 + x308 + x309 + x310 + + x311 + x312 + x313 + x314 + x315 + x316 + x317 + x318 + x319 + x320 + + x321 + x322 + x323 + x324 + x325 + x326 + x327 + x328 + x329 + x330 + + x331 + x332 + x333 + x334 + x335 + x336 + x337 + x338 + x339 + x340 + + x341 + x342 + x343 + x344 + x345 + x346 + x347 + x348 + x349 + x350 + + x351 + x352 + x353 + x354 + x355 + x356 + x357 + x358 + x359 + x360 + + x361 + x362 + x363 + x364 + x365 + x366 + x367 + x368 + x369 + x370 + + x371 + x372 + x373 + x374 + x375 + x376 + x377 + x378 + x379 + x380 + + x381 + x382 + x383 + x384 + x385 + x386 + x387 + x388 + x389 + x390 + + x391 + x392 + x393 + x394 + x395 + x396 + x397 + x398 + x399 + x400; + return (y); +} ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile ===================================== @@ -0,0 +1,4 @@ +.PHONY: GHCiPrimCall +GHCiPrimCall: + '$(TEST_HC)' $(TEST_HC_OPTS) -fPIC -v0 -c GHCiPrimCall_cmm.cmm + -'$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -e main GHCiPrimCall.hs GHCiPrimCall_cmm.o || echo $$? >&2 ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/all.T ===================================== @@ -0,0 +1,2 @@ +test('GHCiPrimCall', [req_interp], makefile_test, ['GHCiPrimCall']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/422d296f25404c0b70d6cc8dec7eac73d3dcc238 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/422d296f25404c0b70d6cc8dec7eac73d3dcc238 You're receiving 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 Jan 10 06:01:24 2023 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Tue, 10 Jan 2023 01:01:24 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] Add PrimCallConv support to GHCi Message-ID: <63bcff34ae1ce_3b1bf9526203325c9@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: daa8d8c1 by Luite Stegeman at 2023-01-10T15:00:50+09:00 Add PrimCallConv support to GHCi This adds support for calling Cmm code from bytecode using the native calling convention, allowing modules that use `foreign import prim` to be loaded and debugged in GHCi. This patch introduces a new `PRIMCALL` bytecode instruction and a helper stack frame `stg_primcall`. The code is based on the existing functionality for dealing with unboxed tuples in bytecode, which has been generalised to handle arbitrary calls. Fixes #22051 - - - - - 21 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Foreign.hs - rts/Disassembler.c - rts/Interpreter.c - rts/RtsSymbols.c - rts/StgMiscClosures.cmm - rts/include/rts/Bytecodes.h - rts/include/stg/MiscClosures.h - testsuite/tests/ghci/prog014/prog014.T - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout-ws-32 - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm - + testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile - + testsuite/tests/ghci/should_run/GHCiPrimCall/all.T Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -12,7 +12,7 @@ module GHC.ByteCode.Asm ( bcoFreeNames, SizedSeq, sizeSS, ssElts, iNTERP_STACK_CHECK_THRESH, - mkTupleInfoLit + mkNativeCallInfoLit ) where import GHC.Prelude @@ -32,7 +32,6 @@ import GHC.Types.Unique.DSet import GHC.Utils.Outputable import GHC.Utils.Panic -import GHC.Utils.Panic.Plain import GHC.Core.TyCon import GHC.Data.FastString @@ -40,7 +39,7 @@ import GHC.Data.SizedSeq import GHC.StgToCmm.Layout ( ArgRep(..) ) import GHC.Cmm.Expr -import GHC.Cmm.CallConv ( tupleRegsCover ) +import GHC.Cmm.CallConv ( allArgRegsCover ) import GHC.Platform import GHC.Platform.Profile @@ -202,7 +201,8 @@ assembleBCO platform (ProtoBCO { protoBCOName = nm (final_insns, final_lits, final_ptrs) <- flip execStateT initial_state $ runAsm platform long_jumps env asm -- precomputed size should be equal to final size - massert (n_insns == sizeSS final_insns) + massertPpr (n_insns == sizeSS final_insns) + (text "bytecode instruction count mismatch") let asm_insns = ssElts final_insns insns_arr = Array.listArray (0, fromIntegral n_insns - 1) asm_insns @@ -351,7 +351,8 @@ largeArg platform w = case platformWordSize platform of fromIntegral (w `shiftR` 32), fromIntegral (w `shiftR` 16), fromIntegral w] - PW4 -> assert (w < fromIntegral (maxBound :: Word32)) $ + PW4 -> assertPpr (w < fromIntegral (maxBound :: Word32)) + (text "largeArg too big:" <+> ppr w) $ [fromIntegral (w `shiftR` 16), fromIntegral w] @@ -388,14 +389,14 @@ assembleI platform i = case i of -> do let ul_bco = assembleBCO platform proto p <- ioptr (liftM BCOPtrBCO ul_bco) emit (push_alts pk) [Op p] - PUSH_ALTS_TUPLE proto tuple_info tuple_proto + PUSH_ALTS_TUPLE proto call_info tuple_proto -> do let ul_bco = assembleBCO platform proto ul_tuple_bco = assembleBCO platform tuple_proto p <- ioptr (liftM BCOPtrBCO ul_bco) p_tup <- ioptr (liftM BCOPtrBCO ul_tuple_bco) info <- int (fromIntegral $ - mkTupleInfoSig platform tuple_info) + mkNativeCallInfoSig platform call_info) emit bci_PUSH_ALTS_T [Op p, Op info, Op p_tup] PUSH_PAD8 -> emit bci_PUSH_PAD8 [] @@ -491,6 +492,7 @@ assembleI platform i = case i of RETURN_TUPLE -> emit bci_RETURN_T [] CCALL off m_addr i -> do np <- addr m_addr emit bci_CCALL [SmallOp off, Op np, SmallOp i] + PRIMCALL -> emit bci_PRIMCALL [] BRK_FUN index uniq cc -> do p1 <- ptr BCOPtrBreakArray q <- int (getKey uniq) np <- addr cc @@ -580,41 +582,44 @@ return_unlifted V64 = error "return_unlifted: vector" maximum number of tuple elements may be larger. Elements can also take multiple words on the stack (for example Double# on a 32 bit platform). - -} -maxTupleNativeStackSize :: WordOff -maxTupleNativeStackSize = 62 +maxTupleReturnNativeStackSize :: WordOff +maxTupleReturnNativeStackSize = 62 {- - Construct the tuple_info word that stg_ctoi_t and stg_ret_t use - to convert a tuple between the native calling convention and the + Construct the call_info word that stg_ctoi_t, stg_ret_t and stg_primcall + use to convert arguments between the native calling convention and the interpreter. - See Note [GHCi tuple layout] for more information. + See Note [GHCi and native call registers] for more information. -} -mkTupleInfoSig :: Platform -> TupleInfo -> Word32 -mkTupleInfoSig platform TupleInfo{..} - | tupleNativeStackSize > maxTupleNativeStackSize - = pprPanic "mkTupleInfoSig: tuple too big for the bytecode compiler" - (ppr tupleNativeStackSize <+> text "stack words." <+> +mkNativeCallInfoSig :: Platform -> NativeCallInfo -> Word32 +mkNativeCallInfoSig platform NativeCallInfo{..} + | nativeCallType == NativeTupleReturn && nativeCallStackSpillSize > maxTupleReturnNativeStackSize + = pprPanic "mkNativeCallInfoSig: tuple too big for the bytecode compiler" + (ppr nativeCallStackSpillSize <+> text "stack words." <+> text "Use -fobject-code to get around this limit" ) | otherwise - = assert (length regs <= 24) {- 24 bits for bitmap -} - assert (tupleNativeStackSize < 255) {- 8 bits for stack size -} - assert (all (`elem` regs) (regSetToList tupleRegs)) {- all regs accounted for -} - foldl' reg_bit 0 (zip regs [0..]) .|. - (fromIntegral tupleNativeStackSize `shiftL` 24) + = assertPpr (length regs <= 24) (text "too many registers for bitmap:" <+> ppr (length regs)) {- 24 bits for register bitmap -} + assertPpr (cont_offset < 255) (text "continuation offset too large:" <+> ppr cont_offset) {- 8 bits for continuation offset (only for NativeTupleReturn) -} + assertPpr (all (`elem` regs) (regSetToList nativeCallRegs)) (text "not all registers accounted for") {- all regs accounted for -} + foldl' reg_bit 0 (zip regs [0..]) .|. (cont_offset `shiftL` 24) where + cont_offset :: Word32 + cont_offset + | nativeCallType == NativeTupleReturn = fromIntegral nativeCallStackSpillSize + | otherwise = 0 -- there is no continuation for primcalls + reg_bit :: Word32 -> (GlobalReg, Int) -> Word32 reg_bit x (r, n) - | r `elemRegSet` tupleRegs = x .|. 1 `shiftL` n - | otherwise = x - regs = tupleRegsCover platform + | r `elemRegSet` nativeCallRegs = x .|. 1 `shiftL` n + | otherwise = x + regs = allArgRegsCover platform -mkTupleInfoLit :: Platform -> TupleInfo -> Literal -mkTupleInfoLit platform tuple_info = - mkLitWord platform . fromIntegral $ mkTupleInfoSig platform tuple_info +mkNativeCallInfoLit :: Platform -> NativeCallInfo -> Literal +mkNativeCallInfoLit platform call_info = + mkLitWord platform . fromIntegral $ mkNativeCallInfoSig platform call_info -- Make lists of host-sized words for literals, so that when the -- words are placed in memory at increasing addresses, the ===================================== compiler/GHC/ByteCode/Instr.hs ===================================== @@ -90,7 +90,7 @@ data BCInstr | PUSH_ALTS (ProtoBCO Name) | PUSH_ALTS_UNLIFTED (ProtoBCO Name) ArgRep | PUSH_ALTS_TUPLE (ProtoBCO Name) -- continuation - !TupleInfo + !NativeCallInfo (ProtoBCO Name) -- tuple return BCO -- Pushing 8, 16 and 32 bits of padding (for constructors). @@ -184,6 +184,8 @@ data BCInstr -- (XXX: inefficient, but I don't know -- what the alignment constraints are.) + | PRIMCALL + -- For doing magic ByteArray passing to foreign calls | SWIZZLE Word16 -- to the ptr N words down the stack, Word16 -- add M (interpreted as a signed 16-bit entity) @@ -269,8 +271,8 @@ instance Outputable BCInstr where ppr (PUSH_ALTS bco) = hang (text "PUSH_ALTS") 2 (ppr bco) ppr (PUSH_ALTS_UNLIFTED bco pk) = hang (text "PUSH_ALTS_UNLIFTED" <+> ppr pk) 2 (ppr bco) - ppr (PUSH_ALTS_TUPLE bco tuple_info tuple_bco) = - hang (text "PUSH_ALTS_TUPLE" <+> ppr tuple_info) + ppr (PUSH_ALTS_TUPLE bco call_info tuple_bco) = + hang (text "PUSH_ALTS_TUPLE" <+> ppr call_info) 2 (ppr tuple_bco $+$ ppr bco) @@ -340,6 +342,7 @@ instance Outputable BCInstr where 0x1 -> text "(interruptible)" 0x2 -> text "(unsafe)" _ -> empty) + ppr PRIMCALL = text "PRIMCALL" ppr (SWIZZLE stkoff n) = text "SWIZZLE " <+> text "stkoff" <+> ppr stkoff <+> text "by" <+> ppr n ppr ENTER = text "ENTER" @@ -382,11 +385,11 @@ bciStackUse (PUSH_ALTS bco) = 2 {- profiling only, restore CCCS -} + bciStackUse (PUSH_ALTS_UNLIFTED bco _) = 2 {- profiling only, restore CCCS -} + 4 + protoBCOStackUse bco bciStackUse (PUSH_ALTS_TUPLE bco info _) = - -- (tuple_bco, tuple_info word, cont_bco, stg_ctoi_t) + -- (tuple_bco, call_info word, cont_bco, stg_ctoi_t) -- tuple - -- (tuple_info, tuple_bco, stg_ret_t) + -- (call_info, tuple_bco, stg_ret_t) 1 {- profiling only -} + - 7 + fromIntegral (tupleSize info) + protoBCOStackUse bco + 7 + fromIntegral (nativeCallSize info) + protoBCOStackUse bco bciStackUse (PUSH_PAD8) = 1 -- overapproximation bciStackUse (PUSH_PAD16) = 1 -- overapproximation bciStackUse (PUSH_PAD32) = 1 -- overapproximation on 64bit arch @@ -443,6 +446,7 @@ bciStackUse RETURN{} = 0 bciStackUse RETURN_UNLIFTED{} = 1 -- pushes stg_ret_X for some X bciStackUse RETURN_TUPLE{} = 1 -- pushes stg_ret_t header bciStackUse CCALL{} = 0 +bciStackUse PRIMCALL{} = 1 -- pushes stg_primcall bciStackUse SWIZZLE{} = 0 bciStackUse BRK_FUN{} = 0 ===================================== compiler/GHC/ByteCode/Types.hs ===================================== @@ -10,7 +10,7 @@ module GHC.ByteCode.Types ( CompiledByteCode(..), seqCompiledByteCode , FFIInfo(..) , RegBitmap(..) - , TupleInfo(..), voidTupleInfo + , NativeCallType(..), NativeCallInfo(..), voidTupleReturnInfo, voidPrimCallInfo , ByteOff(..), WordOff(..) , UnlinkedBCO(..), BCOPtr(..), BCONPtr(..) , ItblEnv, ItblPtr(..) @@ -105,22 +105,32 @@ newtype RegBitmap = RegBitmap { unRegBitmap :: Word32 } See GHC.StgToByteCode.layoutTuple for more details. -} -data TupleInfo = TupleInfo - { tupleSize :: !WordOff -- total size of tuple in words - , tupleRegs :: !GlobalRegSet - , tupleNativeStackSize :: !WordOff {- words spilled on the stack by - GHCs native calling convention -} - } deriving (Show) - -instance Outputable TupleInfo where - ppr TupleInfo{..} = text " ppr tupleSize <+> - text "stack" <+> ppr tupleNativeStackSize <+> - text "regs" <+> - ppr (map (text @SDoc . show) $ regSetToList tupleRegs) <> - char '>' - -voidTupleInfo :: TupleInfo -voidTupleInfo = TupleInfo 0 emptyRegSet 0 + +data NativeCallType = NativePrimCall + | NativeTupleReturn + deriving (Eq) + +data NativeCallInfo = NativeCallInfo + { nativeCallType :: !NativeCallType + , nativeCallSize :: !WordOff -- total size of arguments in words + , nativeCallRegs :: !GlobalRegSet + , nativeCallStackSpillSize :: !WordOff {- words spilled on the stack by + GHCs native calling convention -} + } + +instance Outputable NativeCallInfo where + ppr NativeCallInfo{..} = text " ppr nativeCallSize <+> + text "stack" <+> ppr nativeCallStackSpillSize <+> + text "regs" <+> + ppr (map (text @SDoc . show) $ regSetToList nativeCallRegs) <> + char '>' + + +voidTupleReturnInfo :: NativeCallInfo +voidTupleReturnInfo = NativeCallInfo NativeTupleReturn 0 emptyRegSet 0 + +voidPrimCallInfo :: NativeCallInfo +voidPrimCallInfo = NativeCallInfo NativePrimCall 0 emptyRegSet 0 type ItblEnv = NameEnv (Name, ItblPtr) -- We need the Name in the range so we know which ===================================== compiler/GHC/Cmm/CallConv.hs ===================================== @@ -3,7 +3,7 @@ module GHC.Cmm.CallConv ( assignArgumentsPos, assignStack, realArgRegsCover, - tupleRegsCover + allArgRegsCover ) where import GHC.Prelude @@ -220,12 +220,105 @@ realArgRegsCover platform realLongRegs platform -- we don't save XMM registers if they are not used for parameter passing --- Like realArgRegsCover but always includes the node. This covers the real --- and virtual registers used for unboxed tuples. --- --- Note: if anything changes in how registers for unboxed tuples overlap, --- make sure to also update GHC.StgToByteCode.layoutTuple. -tupleRegsCover :: Platform -> [GlobalReg] -tupleRegsCover platform = +{- + + Note [GHCi and native call registers] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + The GHCi bytecode interpreter does not have access to the STG registers + that the native calling convention uses for passing arguments. It uses + helper stack frames to move values between the stack and registers. + + If only a single register needs to be moved, GHCi uses a specific stack + frame. For example stg_ctoi_R1p saves a heap pointer value from STG register + R1 and stg_ctoi_D1 saves a double precision floating point value from D1. + In the other direction, helpers stg_ret_p and stg_ret_d move a value from + the stack to the R1 and D1 registers, respectively. + + When GHCi needs to move more than one register it cannot use a specific + helper frame. It would simply be impossible to create a helper for all + possible combinations of register values. Instead, there are generic helper + stack frames that use a call_info word that describes the active registers + and the number of stack words used by the arguments of a call. + + These helper stack frames are currently: + + - stg_ret_t: return a tuple to the continuation at the top of + the stack + - stg_ctoi_t: convert a tuple return value to be used in + bytecode + - stg_primcall: call a function + + + The call_info word contains a bitmap of the active registers + for the call and and a stack offset. The layout is as follows: + + - bit 0-23: Bitmap of active registers for the call, the + order corresponds to the list returned by + allArgRegsCover. For example if bit 0 (the least + significant bit) is set, the first register in the + allArgRegsCover list is active. Bit 1 for the + second register in the list and so on. + + - bit 24-31: Unsigned byte indicating the stack offset + of the continuation in words. For tuple returns + this is the number of words returned on the + stack. For primcalls this field is unused, since + we don't jump to a continuation. + + The upper 32 bits on 64 bit platforms are currently unused. + + If a register is smaller than a word on the stack (for example a + single precision float on a 64 bit system), then the stack slot + is padded to a whole word. + + Example: + + If a call has three arguments passed registers and + additional two words of arguments on the stack, then + three bits in the bitmap in bits 0-23 would be set. And + Bit 24-31 would be 00000010 (two in binary). + + The values on the stack before a call to POP_ARG_REGS would + be as follows: + + ... + stack_arg_1 + stack_arg_2 + register_arg_3 + register_arg_2 + register_arg_1 <- Sp + + A call to POP_ARG_REGS(call_info) would move register_arg_1 + to the register corresponding to the lowest set bit in the + call_info word. register_arg_2 would be moved to the register + corresponding to the second lowest set bit, and so on. + + After POP_ARG_REGS(call_info), the stack pointer Sp points + to the topmost stack argument, so the stack looks as follows: + + ... + stack_arg_1 + stack_arg_2 <- Sp + + At this point all the arguments are in place and we are ready + to jump to the native function. + + On x86_64, the double precision (Dn) and single precision + floating (Fn) point registers overlap, e.g. D1 uses the same + physical register as F1. On this platform, the list returned + by allArgRegsCover contains only entries for the double + precision registers. If an argument is passed in register + Fn, the bit corresponding to Dn should be set. + + Note: if anything changes in how registers for native calls overlap, + make sure to also update GHC.StgToByteCode.layoutNativeCall + -} + +-- Like realArgRegsCover but always includes the node. This covers all real +-- and virtual registers actually used for passing arguments. + +allArgRegsCover :: Platform -> [GlobalReg] +allArgRegsCover platform = nub (VanillaReg 1 VGcPtr : realArgRegsCover platform) ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -1233,8 +1233,8 @@ stmtMacros = listToUFM [ ( fsLit "SAVE_REGS", \[] -> emitSaveRegs ), ( fsLit "RESTORE_REGS", \[] -> emitRestoreRegs ), - ( fsLit "PUSH_TUPLE_REGS", \[live_regs] -> emitPushTupleRegs live_regs ), - ( fsLit "POP_TUPLE_REGS", \[live_regs] -> emitPopTupleRegs live_regs ), + ( fsLit "PUSH_ARG_REGS", \[live_regs] -> emitPushArgRegs live_regs ), + ( fsLit "POP_ARG_REGS", \[live_regs] -> emitPopArgRegs live_regs ), ( fsLit "LDV_ENTER", \[e] -> ldvEnter e ), ( fsLit "LDV_RECORD_CREATE", \[e] -> ldvRecordCreate e ), ===================================== compiler/GHC/Cmm/Reg.hs ===================================== @@ -223,7 +223,7 @@ instance Eq GlobalReg where _r1 == _r2 = False -- NOTE: this Ord instance affects the tuple layout in GHCi, see --- Note [GHCi tuple layout] +-- Note [GHCi and native call registers] instance Ord GlobalReg where compare (VanillaReg i _) (VanillaReg j _) = compare i j -- Ignore type when seeking clashes ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -58,7 +58,7 @@ import GHC.Data.FastString import GHC.Utils.Panic import GHC.Utils.Panic.Plain import GHC.Utils.Exception (evaluate) -import GHC.StgToCmm.Closure ( NonVoid(..), fromNonVoid, nonVoidIds ) +import GHC.StgToCmm.Closure ( NonVoid(..), fromNonVoid, nonVoidIds, argPrimRep ) import GHC.StgToCmm.Layout import GHC.Runtime.Heap.Layout hiding (WordOff, ByteOff, wordsToBytes) import GHC.Data.Bitmap @@ -464,10 +464,10 @@ returnUnliftedReps d s szb reps = do [rep] -> return (unitOL $ RETURN_UNLIFTED (toArgRep platform rep)) -- otherwise use RETURN_TUPLE with a tuple descriptor nv_reps -> do - let (tuple_info, args_offsets) = layoutTuple profile 0 (primRepCmmType platform) nv_reps + let (call_info, args_offsets) = layoutNativeCall profile NativeTupleReturn 0 (primRepCmmType platform) nv_reps args_ptrs = map (\(rep, off) -> (isFollowableArg (toArgRep platform rep), off)) args_offsets - tuple_bco <- emitBc (tupleBCO platform tuple_info args_ptrs) - return $ PUSH_UBX (mkTupleInfoLit platform tuple_info) 1 `consOL` + tuple_bco <- emitBc (tupleBCO platform call_info args_ptrs) + return $ PUSH_UBX (mkNativeCallInfoLit platform call_info) 1 `consOL` PUSH_BCO tuple_bco `consOL` unitOL RETURN_TUPLE return ( mkSlideB platform szb (d - s) -- clear to sequel @@ -484,7 +484,11 @@ returnUnboxedTuple d s p es = do profile <- getProfile let platform = profilePlatform profile arg_ty e = primRepCmmType platform (atomPrimRep e) - (tuple_info, tuple_components) = layoutTuple profile d arg_ty es + (call_info, tuple_components) = layoutNativeCall profile + NativeTupleReturn + d + arg_ty + es go _ pushes [] = return (reverse pushes) go !dd pushes ((a, off):cs) = do (push, szb) <- pushAtom dd p a massert (off == dd + szb) @@ -492,7 +496,7 @@ returnUnboxedTuple d s p es = do pushes <- go d [] tuple_components ret <- returnUnliftedReps d s - (wordsToBytes platform $ tupleSize tuple_info) + (wordsToBytes platform $ nativeCallSize call_info) (map atomPrimRep es) return (mconcat pushes `appOL` ret) @@ -648,14 +652,14 @@ schemeT d s p app -- Case 1 schemeT d s p (StgOpApp (StgFCallOp (CCall ccall_spec) _ty) args result_ty) = if isSupportedCConv ccall_spec - then generateCCall d s p ccall_spec result_ty (reverse args) + then generateCCall d s p ccall_spec result_ty args else unsupportedCConvException schemeT d s p (StgOpApp (StgPrimOp op) args _ty) = doTailCall d s p (primOpId op) (reverse args) -schemeT _d _s _p (StgOpApp StgPrimCallOp{} _args _ty) - = unsupportedCConvException +schemeT d s p (StgOpApp (StgPrimCallOp (PrimCall label unit)) args result_ty) + = generatePrimCall d s p label (Just unit) result_ty args -- Case 2: Unboxed tuple schemeT d s p (StgConApp con _cn args _tys) @@ -840,18 +844,18 @@ doCase d s p scrut bndr alts | ubx_frame = wordSize platform | otherwise = 0 - (bndr_size, tuple_info, args_offsets) + (bndr_size, call_info, args_offsets) | ubx_tuple_frame = let bndr_ty = primRepCmmType platform bndr_reps = filter (not.isVoidRep) (bcIdPrimReps bndr) - (tuple_info, args_offsets) = - layoutTuple profile 0 bndr_ty bndr_reps - in ( wordsToBytes platform (tupleSize tuple_info) - , tuple_info + (call_info, args_offsets) = + layoutNativeCall profile NativeTupleReturn 0 bndr_ty bndr_reps + in ( wordsToBytes platform (nativeCallSize call_info) + , call_info , args_offsets ) | otherwise = ( wordsToBytes platform (idSizeW platform bndr) - , voidTupleInfo + , voidTupleReturnInfo , [] ) @@ -885,17 +889,18 @@ doCase d s p scrut bndr alts | isUnboxedTupleType bndr_ty || isUnboxedSumType bndr_ty = let bndr_ty = primRepCmmType platform . bcIdPrimRep tuple_start = d_bndr - (tuple_info, args_offsets) = - layoutTuple profile - 0 - bndr_ty - bndrs + (call_info, args_offsets) = + layoutNativeCall profile + NativeTupleReturn + 0 + bndr_ty + bndrs stack_bot = d_alts p' = Map.insertList [ (arg, tuple_start - - wordsToBytes platform (tupleSize tuple_info) + + wordsToBytes platform (nativeCallSize call_info) + offset) | (arg, offset) <- args_offsets , not (isVoidRep $ bcIdPrimRep arg)] @@ -981,8 +986,8 @@ doCase d s p scrut bndr alts -- unboxed tuples get two more words, the second is a pointer (tuple_bco) (extra_pointers, extra_slots) - | ubx_tuple_frame && profiling = ([1], 3) -- tuple_info, tuple_BCO, CCCS - | ubx_tuple_frame = ([1], 2) -- tuple_info, tuple_BCO + | ubx_tuple_frame && profiling = ([1], 3) -- call_info, tuple_BCO, CCCS + | ubx_tuple_frame = ([1], 2) -- call_info, tuple_BCO | otherwise = ([], 0) bitmap_size = trunc16W $ fromIntegral extra_slots + @@ -1028,8 +1033,8 @@ doCase d s p scrut bndr alts let args_ptrs = map (\(rep, off) -> (isFollowableArg (toArgRep platform rep), off)) args_offsets - tuple_bco <- emitBc (tupleBCO platform tuple_info args_ptrs) - return (PUSH_ALTS_TUPLE alt_bco' tuple_info tuple_bco + tuple_bco <- emitBc (tupleBCO platform call_info args_ptrs) + return (PUSH_ALTS_TUPLE alt_bco' call_info tuple_bco `consOL` scrut_code) else let push_alts | not ubx_frame @@ -1050,14 +1055,15 @@ doCase d s p scrut bndr alts -- The native calling convention uses registers for tuples, but in the -- bytecode interpreter, all values live on the stack. -layoutTuple :: Profile - -> ByteOff - -> (a -> CmmType) - -> [a] - -> ( TupleInfo -- See Note [GHCi TupleInfo] - , [(a, ByteOff)] -- argument, offset on stack - ) -layoutTuple profile start_off arg_ty reps = +layoutNativeCall :: Profile + -> NativeCallType + -> ByteOff + -> (a -> CmmType) + -> [a] + -> ( NativeCallInfo -- See Note [GHCi TupleInfo] + , [(a, ByteOff)] -- argument, offset on stack + ) +layoutNativeCall profile call_type start_off arg_ty reps = let platform = profilePlatform profile (orig_stk_bytes, pos) = assignArgumentsPos profile 0 @@ -1070,7 +1076,7 @@ layoutTuple profile start_off arg_ty reps = -- sort the register parameters by register and add them to the stack regs_order :: Map.Map GlobalReg Int - regs_order = Map.fromList $ zip (tupleRegsCover platform) [0..] + regs_order = Map.fromList $ zip (allArgRegsCover platform) [0..] reg_order :: GlobalReg -> (Int, GlobalReg) reg_order reg | Just n <- Map.lookup reg regs_order = (n, reg) @@ -1099,10 +1105,11 @@ layoutTuple profile start_off arg_ty reps = get_byte_off _ = panic "GHC.StgToByteCode.layoutTuple get_byte_off" - in ( TupleInfo - { tupleSize = bytesToWords platform (ByteOff new_stk_bytes) - , tupleRegs = regs_set - , tupleNativeStackSize = bytesToWords platform + in ( NativeCallInfo + { nativeCallType = call_type + , nativeCallSize = bytesToWords platform (ByteOff new_stk_bytes) + , nativeCallRegs = regs_set + , nativeCallStackSpillSize = bytesToWords platform (ByteOff orig_stk_bytes) } , sortBy (comparing snd) $ @@ -1127,7 +1134,7 @@ usePlainReturn t ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We have the bytecode instructions RETURN_TUPLE and PUSH_ALTS_TUPLE to return and receive arbitrary unboxed tuples, respectively. These - instructions use the helper data tuple_BCO and tuple_info. + instructions use the helper data tuple_BCO and call_info. The helper data is used to convert tuples between GHCs native calling convention (object code), which uses stack and registers, and the bytecode @@ -1139,7 +1146,7 @@ usePlainReturn t ================= Bytecode that returns a tuple first pushes all the tuple fields followed - by the appropriate tuple_info and tuple_BCO onto the stack. It then + by the appropriate call_info and tuple_BCO onto the stack. It then executes the RETURN_TUPLE instruction, which causes the interpreter to push stg_ret_t_info to the top of the stack. The stack (growing down) then looks as follows: @@ -1150,14 +1157,14 @@ usePlainReturn t tuple_field_2 ... tuple_field_n - tuple_info + call_info tuple_BCO stg_ret_t_info <- Sp If next_frame is bytecode, the interpreter will start executing it. If it's object code, the interpreter jumps back to the scheduler, which in turn jumps to stg_ret_t. stg_ret_t converts the tuple to the native - calling convention using the description in tuple_info, and then jumps + calling convention using the description in call_info, and then jumps to next_frame. @@ -1169,13 +1176,13 @@ usePlainReturn t tuple. The PUSH_ALTS_TUPLE instuction contains three pieces of data: * cont_BCO: the continuation that receives the tuple - * tuple_info: see below + * call_info: see below * tuple_BCO: see below The interpreter pushes these onto the stack when the PUSH_ALTS_TUPLE instruction is executed, followed by stg_ctoi_tN_info, with N depending on the number of stack words used by the tuple in the GHC native calling - convention. N is derived from tuple_info. + convention. N is derived from call_info. For example if we expect a tuple with three words on the stack, the stack looks as follows after PUSH_ALTS_TUPLE: @@ -1186,7 +1193,7 @@ usePlainReturn t cont_free_var_2 ... cont_free_var_n - tuple_info + call_info tuple_BCO cont_BCO stg_ctoi_t3_info <- Sp @@ -1206,20 +1213,20 @@ usePlainReturn t that is already on the stack. - The tuple_info word + The call_info word =================== - The tuple_info word describes the stack and STG register (e.g. R1..R6, - D1..D6) usage for the tuple. tuple_info contains enough information to + The call_info word describes the stack and STG register (e.g. R1..R6, + D1..D6) usage for the tuple. call_info contains enough information to convert the tuple between the stack-only bytecode and stack+registers GHC native calling conventions. - See Note [GHCi tuple layout] for more details of how the data is packed - in a single word. + See Note [GHCi and native call registers] for more details of how the + data is packed in a single word. -} -tupleBCO :: Platform -> TupleInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name +tupleBCO :: Platform -> NativeCallInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name tupleBCO platform info pointers = mkProtoBCO platform invented_name body_code (Left []) 0{-no arity-} bitmap_size bitmap False{-is alts-} @@ -1233,15 +1240,103 @@ tupleBCO platform info pointers = -} invented_name = mkSystemVarName (mkPseudoUniqueE 0) (fsLit "tuple") - -- the first word in the frame is the tuple_info word, + -- the first word in the frame is the call_info word, -- which is not a pointer - bitmap_size = trunc16W $ 1 + tupleSize info + bitmap_size = trunc16W $ 1 + nativeCallSize info bitmap = intsToReverseBitmap platform (fromIntegral bitmap_size) $ map ((+1) . fromIntegral . bytesToWords platform . snd) (filter fst pointers) body_code = mkSlideW 0 1 -- pop frame header `snocOL` RETURN_TUPLE -- and add it again +primCallBCO :: Platform -> NativeCallInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name +primCallBCO platform args_info pointers = + mkProtoBCO platform invented_name body_code (Left []) + 0{-no arity-} bitmap_size bitmap False{-is alts-} + + where + {- + The primcall BCO is never referred to by name, so we can get away + with using a fake name here. We will need to change this if we want + to save some memory by sharing the BCO between places that have + the same tuple shape + -} + invented_name = mkSystemVarName (mkPseudoUniqueE 0) (fsLit "primcall") + + -- the first three words in the frame are the BCO describing the + -- pointers in the frame, the call_info word and the pointer + -- to the Cmm function being called. None of these is a pointer that + -- should be followed by the garbage collector + bitmap_size = trunc16W $ 2 + nativeCallSize args_info + bitmap = intsToReverseBitmap platform (fromIntegral bitmap_size) $ + map ((+2) . fromIntegral . bytesToWords platform . snd) + (filter fst pointers) + -- if the primcall BCO is ever run it's a bug, since the BCO should only + -- be pushed immediately before running the PRIMCALL bytecode instruction, + -- which immediately leaves the interpreter to jump to the stg_primcall_info + -- Cmm function + body_code = unitOL CASEFAIL + +-- ----------------------------------------------------------------------------- +-- Deal with a primitive call to native code. + +generatePrimCall + :: StackDepth + -> Sequel + -> BCEnv + -> CLabelString -- where to call + -> Maybe Unit + -> Type + -> [StgArg] -- args (atoms) + -> BcM BCInstrList +generatePrimCall d s p target _mb_unit _result_ty args + = do + profile <- getProfile + let + platform = profilePlatform profile + + non_void VoidRep = False + non_void _ = True + + nv_args :: [StgArg] + nv_args = filter (non_void . argPrimRep) args + + (args_info, args_offsets) = + layoutNativeCall profile + NativePrimCall + d + (primRepCmmType platform . argPrimRep) + nv_args + + args_ptrs :: [(Bool, ByteOff)] + args_ptrs = + map (\(r, off) -> + (isFollowableArg (toArgRep platform . argPrimRep $ r), off)) + args_offsets + + push_target = PUSH_UBX (LitLabel target Nothing IsFunction) 1 + push_info = PUSH_UBX (mkNativeCallInfoLit platform args_info) 1 + {- + compute size to move payload (without stg_primcall_info header) + + size of arguments plus three words for: + - function pointer to the target + - call_info word + - BCO to describe the stack frame + -} + szb = wordsToBytes platform (nativeCallSize args_info + 3) + go _ pushes [] = return (reverse pushes) + go !dd pushes ((a, off):cs) = do (push, szb) <- pushAtom dd p a + massert (off == dd + szb) + go (dd + szb) (push:pushes) cs + push_args <- go d [] args_offsets + args_bco <- emitBc (primCallBCO platform args_info args_ptrs) + return $ mconcat push_args `appOL` + (push_target `consOL` + push_info `consOL` + PUSH_BCO args_bco `consOL` + (mkSlideB platform szb (d - s) `appOL` unitOL PRIMCALL)) + -- ----------------------------------------------------------------------------- -- Deal with a CCall. @@ -1259,11 +1354,17 @@ generateCCall -> Type -> [StgArg] -- args (atoms) -> BcM BCInstrList -generateCCall d0 s p (CCallSpec target cconv safety) result_ty args_r_to_l +generateCCall d0 s p (CCallSpec target PrimCallConv _) result_ty args + | (StaticTarget _ label mb_unit _) <- target + = generatePrimCall d0 s p label mb_unit result_ty args + | otherwise + = panic "GHC.StgToByteCode.generateCCall: primcall convention only supports static targets" +generateCCall d0 s p (CCallSpec target cconv safety) result_ty args = do profile <- getProfile let + args_r_to_l = reverse args platform = profilePlatform profile -- useful constants addr_size_b :: ByteOff @@ -2007,7 +2108,7 @@ isSupportedCConv :: CCallSpec -> Bool isSupportedCConv (CCallSpec _ cconv _) = case cconv of CCallConv -> True -- we explicitly pattern match on every StdCallConv -> True -- convention to ensure that a warning - PrimCallConv -> False -- is triggered when a new one is added + PrimCallConv -> True -- is triggered when a new one is added JavaScriptCallConv -> False CApiConv -> True ===================================== compiler/GHC/StgToCmm/Foreign.hs ===================================== @@ -15,8 +15,8 @@ module GHC.StgToCmm.Foreign ( emitLoadThreadState, emitSaveRegs, emitRestoreRegs, - emitPushTupleRegs, - emitPopTupleRegs, + emitPushArgRegs, + emitPopArgRegs, loadThreadState, emitOpenNursery, emitCloseNursery, @@ -349,7 +349,7 @@ emitRestoreRegs = do -- bytecode interpreter. -- -- The "live registers" bitmap corresponds to the list of registers given by --- 'tupleRegsCover', with the least significant bit indicating liveness of +-- 'allArgRegsCover', with the least significant bit indicating liveness of -- the first register in the list. -- -- Each register is saved to a stack slot of one or more machine words, even @@ -362,12 +362,12 @@ emitRestoreRegs = do -- if((mask & 2) != 0) { Sp_adj(-1); Sp(0) = R2; } -- if((mask & 1) != 0) { Sp_adj(-1); Sp(0) = R1; } -- --- See Note [GHCi tuple layout] +-- See Note [GHCi and native call registers] -emitPushTupleRegs :: CmmExpr -> FCode () -emitPushTupleRegs regs_live = do +emitPushArgRegs :: CmmExpr -> FCode () +emitPushArgRegs regs_live = do platform <- getPlatform - let regs = zip (tupleRegsCover platform) [0..] + let regs = zip (allArgRegsCover platform) [0..] save_arg (reg, n) = let mask = CmmLit (CmmInt (1 `shiftL` n) (wordWidth platform)) live = cmmAndWord platform regs_live mask @@ -381,11 +381,11 @@ emitPushTupleRegs regs_live = do in mkCmmIfThen cond $ catAGraphs [adj_sp, save_reg] emit . catAGraphs =<< mapM save_arg (reverse regs) --- | Pop a subset of STG registers from the stack (see 'emitPushTupleRegs') -emitPopTupleRegs :: CmmExpr -> FCode () -emitPopTupleRegs regs_live = do +-- | Pop a subset of STG registers from the stack (see 'emitPushArgRegs') +emitPopArgRegs :: CmmExpr -> FCode () +emitPopArgRegs regs_live = do platform <- getPlatform - let regs = zip (tupleRegsCover platform) [0..] + let regs = zip (allArgRegsCover platform) [0..] save_arg (reg, n) = let mask = CmmLit (CmmInt (1 `shiftL` n) (wordWidth platform)) live = cmmAndWord platform regs_live mask ===================================== rts/Disassembler.c ===================================== @@ -83,6 +83,9 @@ disInstr ( StgBCO *bco, int pc ) debugBelch("CCALL marshaller at 0x%" FMT_HexWord "\n", literals[instrs[pc]] ); pc += 1; break; + case bci_PRIMCALL: + debugBelch("PRIMCALL\n"); + break; case bci_STKCHECK: { StgWord stk_words_reqd = BCO_GET_LARGE_ARG + 1; debugBelch("STKCHECK %" FMT_Word "\n", (W_)stk_words_reqd ); ===================================== rts/Interpreter.c ===================================== @@ -2038,6 +2038,12 @@ run_BCO: goto nextInsn; } + case bci_PRIMCALL: { + Sp_subW(1); + SpW(0) = (W_)&stg_primcall_info; + RETURN_TO_SCHEDULER_NO_PAUSE(ThreadRunGHC, ThreadYielding); + } + case bci_CCALL: { void *tok; int stk_offset = BCO_NEXT; ===================================== rts/RtsSymbols.c ===================================== @@ -602,6 +602,7 @@ extern char **environ; SymI_HasDataProto(stg_ret_l_info) \ SymI_HasDataProto(stg_ret_t_info) \ SymI_HasDataProto(stg_ctoi_t) \ + SymI_HasDataProto(stg_primcall_info) \ SymI_HasDataProto(stg_gc_prim_p) \ SymI_HasDataProto(stg_gc_prim_pp) \ SymI_HasDataProto(stg_gc_prim_n) \ ===================================== rts/StgMiscClosures.cmm ===================================== @@ -366,20 +366,10 @@ MK_STG_CTOI_T(61) MK_STG_CTOI_T(62) /* - Note [GHCi tuple layout] - ~~~~~~~~~~~~~~~~~~~~~~~~ - the tuple_info word describes the register and stack usage of the tuple: + Convert a tuple return value to be used in bytecode. - [ ssss ssss rrrr rrrr rrrr rrrr rrrr rrrr ] - - - r: bitmap of live registers, corresponding to the list of registers - returned by GHC.Cmm.CallConv.tupleRegsCover (the least significant - bit corresponds to the first element in the list) - - s: number of words on stack (in addition to registers) - - The order of the live registers in the bitmap is the same as the list - given by GHC.Cmm.CallConv.tupleRegsCover, with the least significant - bit corresponding to the first register in the list. + See Note [GHCi and native call registers] for information on how + values are moved between the stack and registers. */ stg_ctoi_t @@ -402,7 +392,7 @@ stg_ctoi_t Sp = Sp - WDS(tuple_stack); - PUSH_TUPLE_REGS(tuple_info); + PUSH_ARG_REGS(tuple_info); /* jump to the BCO that will finish the return of the tuple */ Sp_adj(-3); @@ -423,13 +413,57 @@ INFO_TABLE_RET( stg_ret_t, RET_BCO ) /* number of words spilled on stack */ tuple_stack = (tuple_info >> 24) & 0xff; - POP_TUPLE_REGS(tuple_info); + POP_ARG_REGS(tuple_info); /* Sp points to the topmost argument now */ jump %ENTRY_CODE(Sp(tuple_stack)) [*]; // NB. all registers live! } + /* + + The stg_primcall frame is used by the bytecode interpreter to call + a Cmm function. The frame contains a call_info word that contains + a bitmap describing the register arguments. + + When the target function is called, Sp points to the topmost stack + argument. + + ... + next_stack_frame + arg_1 + arg_2 + ... + arg_n + target_funptr (pointer to the function we're calling) + call_info (describes the registers containing the arguments) + primcall_BCO (contains bitmap describing pointers in args) + stg_primcall_info <- Sp + + See Note [GHCi and native call registers] for information on the call_info + word and how registers are moved between the stack and registers. + + */ + +INFO_TABLE_RET ( stg_primcall, RET_BCO ) +{ + W_ args_info, prim_fun; + + /* Sp(1) would be the BCO containing the stack description bitmap */ + args_info = Sp(2); + prim_fun = Sp(3); + + Sp_adj(4); + + /* Sp points to the top of the register arguments now, + load them into actual registers */ + POP_ARG_REGS(args_info); + + /* Sp points to the topmost stack argument now */ + + jump prim_fun [*]; // NB. all registers live! +} + /* * Dummy info table pushed on the top of the stack when the interpreter * should apply the BCO on the stack to its arguments, also on the ===================================== rts/include/rts/Bytecodes.h ===================================== @@ -112,6 +112,8 @@ #define bci_TESTLT_W8 85 #define bci_TESTEQ_W8 86 +#define bci_PRIMCALL 87 + /* If you need to go past 255 then you will run into the flags */ /* If you need to go below 0x0100 then you will run into the instructions */ ===================================== rts/include/stg/MiscClosures.h ===================================== @@ -160,6 +160,7 @@ RTS_RET(stg_ctoi_t60); RTS_RET(stg_ctoi_t61); RTS_RET(stg_ctoi_t62); +RTS_RET(stg_primcall); RTS_RET(stg_apply_interp); RTS_RET(stg_dead_thread); ===================================== testsuite/tests/ghci/prog014/prog014.T ===================================== @@ -1,6 +1,5 @@ test('prog014', [extra_files(['Primop.hs', 'dummy.c']), - expect_fail, # bytecode compiler doesn't support foreign import prim extra_run_opts('dummy.o'), pre_cmd('$MAKE -s --no-print-directory prog014')], ghci_script, ['prog014.script']) ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs ===================================== @@ -0,0 +1,279 @@ +{-# LANGUAGE ForeignFunctionInterface, GHCForeignImportPrim, UnliftedFFITypes, MagicHash, UnboxedTuples #-} + +module Main where + +import GHC.Int +import GHC.Word +import GHC.Prim +import GHC.Exts +import GHC.Types +import Unsafe.Coerce +import GHC.IO + +data Box (a :: UnliftedType) = MkBox a + +i2a :: Int -> Any +i2a = unsafeCoerce + +a2i :: Any -> Int +a2i = unsafeCoerce + +main :: IO () +main = do + + let i8s :: [Int8] + i8s = [0, -1, 1, minBound, maxBound] + + i16s :: [Int16] + i16s = [0, -1, 1, minBound, maxBound] + + i32s :: [Int32] + i32s = [0, -1, 1, minBound, maxBound] + + i64s :: [Int64] + i64s = [0, -1, 1, minBound, maxBound] + + ws :: [Word] + ws = [0, 1, 2, maxBound] + + fs :: [Float] + fs = [-0, 0, -1, 1, -2, 2, 1/0, 1e37, -1e-37] + + ds :: [Double] + ds = [-0, 0, -1, 1, -2, 2, 1/0, 1e307, -1e-307] + + ls :: [Word64] + ls = [0, 1, 2, 4294967296, maxBound] + + mi2a :: Maybe Integer -> Any + mi2a = unsafeCoerce + + a2mi :: Any -> Maybe Integer + a2mi = unsafeCoerce + + a0, a1, a2, a3 :: Any + a0 = mi2a Nothing + a1 = mi2a (Just 1) + a2 = mi2a (Just 18446744073709551617) + a3 = mi2a (Just (-18446744073709551617)) + + as :: [Any] + as = [a0, a1, a2, a3] + + + putStrLn "zero arguments" + IO (\st -> case cmm_zero st of (# st' #) -> (# st', () #)) + print =<< IO (\st -> case cmm_zero_w st of (# st', w #) -> (# st', W# w #)) + print =<< IO (\st -> case cmm_zero_d st of (# st', w #) -> (# st', D# w #)) + print =<< IO (\st -> case cmm_zero_f st of (# st', w #) -> (# st', F# w #)) + + -- XXX zero argument functions + + putStrLn "one argument functions" + print [ I8# (cmm_one1_i8 x) | (I8# x) <- i8s ] + print [ I16# (cmm_one1_i16 x) | (I16# x) <- i16s ] + print [ I32# (cmm_one1_i32 x) | (I32# x) <- i32s ] + print [ I64# (cmm_one1_i64 x) | (I64# x) <- i64s ] + print [ case cmm_one1_p x of (# y #) -> a2mi y | x <- as ] + print [ W# (cmm_one1_w x) | (W# x) <- ws ] + print [ F# (cmm_one1_f x) | (F# x) <- fs ] + print [ D# (cmm_one1_d x) | (D# x) <- ds ] + print [ W64# (cmm_one1_l x) | (W64# x) <- ls ] + + print [ case cmm_one2_i8 x of (# y1, y2 #) -> (I8# y1, I8# y2) | (I8# x) <- i8s ] + print [ case cmm_one2_i16 x of (# y1, y2 #) -> (I16# y1, I16# y2) | (I16# x) <- i16s ] + print [ case cmm_one2_i32 x of (# y1, y2 #) -> (I32# y1, I32# y2) | (I32# x) <- i32s ] + print [ case cmm_one2_i64 x of (# y1, y2 #) -> (I64# y1, I64# y2) | (I64# x) <- i64s ] + print [ case cmm_one2_p x of (# y1, y2 #) -> (a2mi y1, a2mi y2) | x <- as ] + print [ case cmm_one2_w x of (# y1, y2 #) -> (W# y1, W# y2) | (W# x) <- ws ] + print [ case cmm_one2_f x of (# y1, y2 #) -> (F# y1, F# y2) | (F# x) <- fs ] + print [ case cmm_one2_d x of (# y1, y2 #) -> (D# y1, D# y2) | (D# x) <- ds ] + print [ case cmm_one2_l x of (# y1, y2 #) -> (W64# y1, W64# y2) | (W64# x) <- ls ] + + putStrLn "two argument functions" + print [ I8# (cmm_two1_i8 x1 x2) | (I8# x1) <- i8s, (I8# x2) <- i8s ] + print [ I16# (cmm_two1_i16 x1 x2) | (I16# x1) <- i16s, (I16# x2) <- i16s ] + print [ I32# (cmm_two1_i32 x1 x2) | (I32# x1) <- i32s, (I32# x2) <- i32s ] + print [ I64# (cmm_two1_i64 x1 x2) | (I64# x1) <- i64s, (I64# x2) <- i64s ] + print [ case cmm_two1_p x1 x2 of (# y #) -> a2mi y | x1 <- as, x2 <- as ] + print [ W# (cmm_two1_w x1 x2) | (W# x1) <- ws, (W# x2) <- ws ] + print [ F# (cmm_two1_f x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_two1_d x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ W64# (cmm_two1_l x1 x2) | (W64# x1) <- ls, (W64# x2) <- ls ] + + print [ I8# (cmm_two2_i8 x1 x2) | (I8# x1) <- i8s, (I8# x2) <- i8s ] + print [ I16# (cmm_two2_i16 x1 x2) | (I16# x1) <- i16s, (I16# x2) <- i16s ] + print [ I32# (cmm_two2_i32 x1 x2) | (I32# x1) <- i32s, (I32# x2) <- i32s ] + print [ I64# (cmm_two2_i64 x1 x2) | (I64# x1) <- i64s, (I64# x2) <- i64s ] + print [ case cmm_two2_p x1 x2 of (# y #) -> a2mi y | x1 <- as, x2 <- as ] + print [ W# (cmm_two2_w x1 x2) | (W# x1) <- ws, (W# x2) <- ws ] + print [ F# (cmm_two2_f x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_two2_d x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ W64# (cmm_two2_l x1 x2) | (W64# x1) <- ls, (W64# x2) <- ls ] + + putStrLn "additional floating point tests" + print [ F# (cmm_floating_1 x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_floating_2 x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ F# (cmm_floating_3 x1 x2) | (F# x1) <- fs, (D# x2) <- ds ] + print [ D# (cmm_floating_4 x1 x2) | (F# x1) <- fs, (D# x2) <- ds ] + print [ case cmm_floating_5 x1 x2 3.0e1# 4.0e2## 5.0e3# 6.0e4## 7.0e5# 8.0e6## of (# y1, y2 #) -> (F# y1, D# y2) + | (F# x1) <- fs, (D# x2) <- ds ] + print [ case cmm_floating_6 x1 x2 3.0e1## 4.0e2# 5.0e3## 6.0e4# 7.0e5## 8.0e6# of (# y1, y2 #) -> (D# y1, F# y2) + | (D# x1) <- ds, (F# x2) <- fs ] + print [ case cmm_floating_7 w1 x1 x2 + 4## 5.0e1# 6.0e2## + 7## 8.0e3# 9.0e4## + 10## 11.0e5# 12.0e6## + 13## 14.0e7# 15.0e8## + 16## 17.0e9# 18.0e10## + 19## 20.0e11# 21.0e12## of (# y1, y2, y3 #) -> (W# y1, F# y2, D# y3) + | (W# w1) <- ws, (F# x1) <- fs, (D# x2) <- ds ] + + putStrLn "various sized tuple returns" + print [ case cmm_tuple_1 x1 x2 3## of (# y1, y2, y3 #) -> (W# y1, W# y2, W# y3) | (W# x1) <- ws, (W# x2) <- ws] + print [ case cmm_tuple_2 x1 x2 3## 4## a0 a1 7.0## 8.0## a2 a3 11.0# 12.0# + of (# y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12 #) -> + (F# y1, F# y2, a2mi y3, a2mi y4, D# y5, D# y6, a2mi y7, a2mi y8, W# y9, W# y10, a2mi y11, a2mi y12) + | x1 <- as, x2 <- as ] + print [ case cmm_tuple_3 x1 x2 a0 3.0## a1 5.0# + of (# y1, y2, y3, y4, y5, y6 #) -> (F# y1, a2mi y2, D# y3, a2mi y4, W# y5, a2mi y6) + | x1 <- as, (W# x2) <- ws ] + print [ case cmm_tuple_4 x1 x2 of (# y1, y2 #) -> (a2mi y1, a2mi y2) | x1 <- as, x2 <- as ] + + putStrLn "arrays" + MkBox marr0 <- IO (\s -> case newArray# 10# a0 s of (# s', a #) -> (# s', MkBox a #)) + MkBox marr1 <- IO (\s -> case newArray# 12# a1 s of (# s', a #) -> (# s', MkBox a #)) + MkBox arr0 <- IO (\s -> case unsafeFreezeArray# marr0 s of (# s', a #) -> (# s', MkBox a #)) + MkBox arr1 <- IO (\s -> case unsafeFreezeArray# marr1 s of (# s', a #) -> (# s', MkBox a #)) + print (I# (cmm_array_1 arr0), I# (cmm_array_1 arr1)) + case cmm_array_2 arr0 arr1 of (# arr2, arr3 #) -> print (I# (cmm_array_1 arr2), I# (cmm_array_1 arr3)) + + putStrLn "many arguments" + print (W# (cmm_many_arguments 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## 65## 66## 67## 68## 69## 70## 71## 72## 73## 74## 75## 76## 77## 78## 79## 80## 81## 82## 83## 84## 85## 86## 87## 88## 89## 90## 91## 92## 93## 94## 95## 96## 97## 98## 99## 100## 101## 102## 103## 104## 105## 106## 107## 108## 109## 110## 111## 112## 113## 114## 115## 116## 117## 118## 119## 120## 121## 122## 123## 124## 125## 126## 127## 128## 129## 130## 131## 132## 133## 134## 135## 136## 137## 138## 139## 140## 141## 142## 143## 144## 145## 146## 147## 148## 149## 150## 151## 152## 153## 154## 155## 156## 157## 158## 159## 160## 161## 162## 163## 164## 165## 166## 167## 168## 169## 170## 171## 172## 173## 174## 175## 176## 177## 178## 179## 180## 181## 182## 183## 184## 185## 186## 187## 188## 189## 190## 191## 192## 193## 194## 195## 196## 197## 198## 199## 200## 201## 202## 203## 204## 205## 206## 207## 208## 209## 210## 211## 212## 213## 214## 215## 216## 217## 218## 219## 220## 221## 222## 223## 224## 225## 226## 227## 228## 229## 230## 231## 232## 233## 234## 235## 236## 237## 238## 239## 240## 241## 242## 243## 244## 245## 246## 247## 248## 249## 250## 251## 252## 253## 254## 255## 256## 257## 258## 259## 260## 261## 262## 263## 264## 265## 266## 267## 268## 269## 270## 271## 272## 273## 274## 275## 276## 277## 278## 279## 280## 281## 282## 283## 284## 285## 286## 287## 288## 289## 290## 291## 292## 293## 294## 295## 296## 297## 298## 299## 300## 301## 302## 303## 304## 305## 306## 307## 308## 309## 310## 311## 312## 313## 314## 315## 316## 317## 318## 319## 320## 321## 322## 323## 324## 325## 326## 327## 328## 329## 330## 331## 332## 333## 334## 335## 336## 337## 338## 339## 340## 341## 342## 343## 344## 345## 346## 347## 348## 349## 350## 351## 352## 353## 354## 355## 356## 357## 358## 359## 360## 361## 362## 363## 364## 365## 366## 367## 368## 369## 370## 371## 372## 373## 374## 375## 376## 377## 378## 379## 380## 381## 382## 383## 384## 385## 386## 387## 388## 389## 390## 391## 392## 393## 394## 395## 396## 397## 398## 399## 400##)) + +-- XXX why don't we accept State# RealWorld -> State# RealWorld ? +foreign import prim cmm_zero :: State# RealWorld -> (# State# RealWorld #) +foreign import prim cmm_zero_w :: State# RealWorld -> (# State# RealWorld, Word# #) +foreign import prim cmm_zero_d :: State# RealWorld -> (# State# RealWorld, Double# #) +foreign import prim cmm_zero_f :: State# RealWorld -> (# State# RealWorld, Float# #) + +-- one argument functions +foreign import prim cmm_one1_i8 :: Int8# -> Int8# +foreign import prim cmm_one1_i16 :: Int16# -> Int16# +foreign import prim cmm_one1_i32 :: Int32# -> Int32# +foreign import prim cmm_one1_i64 :: Int64# -> Int64# +foreign import prim cmm_one1_p :: Any -> (# Any #) +foreign import prim cmm_one1_w :: Word# -> Word# +foreign import prim cmm_one1_f :: Float# -> Float# +foreign import prim cmm_one1_d :: Double# -> Double# +foreign import prim cmm_one1_l :: Word64# -> Word64# + +foreign import prim cmm_one2_i8 :: Int8# -> (# Int8#, Int8# #) +foreign import prim cmm_one2_i16 :: Int16# -> (# Int16#, Int16# #) +foreign import prim cmm_one2_i32 :: Int32# -> (# Int32#, Int32# #) +foreign import prim cmm_one2_i64 :: Int64# -> (# Int64#, Int64# #) +foreign import prim cmm_one2_p :: Any -> (# Any, Any #) +foreign import prim cmm_one2_w :: Word# -> (# Word#, Word# #) +foreign import prim cmm_one2_f :: Float# -> (# Float#, Float# #) +foreign import prim cmm_one2_d :: Double# -> (# Double#, Double# #) +foreign import prim cmm_one2_l :: Word64# -> (# Word64#, Word64# #) + +-- two argument functions +foreign import prim cmm_two1_i8 :: Int8# -> Int8# -> Int8# +foreign import prim cmm_two1_i16 :: Int16# -> Int16# -> Int16# +foreign import prim cmm_two1_i32 :: Int32# -> Int32# -> Int32# +foreign import prim cmm_two1_i64 :: Int64# -> Int64# -> Int64# +foreign import prim cmm_two1_p :: Any -> Any -> (# Any #) +foreign import prim cmm_two1_w :: Word# -> Word# -> Word# +foreign import prim cmm_two1_f :: Float# -> Float# -> Float# +foreign import prim cmm_two1_d :: Double# -> Double# -> Double# +foreign import prim cmm_two1_l :: Word64# -> Word64# -> Word64# + +foreign import prim cmm_two2_i8 :: Int8# -> Int8# -> Int8# +foreign import prim cmm_two2_i16 :: Int16# -> Int16# -> Int16# +foreign import prim cmm_two2_i32 :: Int32# -> Int32# -> Int32# +foreign import prim cmm_two2_i64 :: Int64# -> Int64# -> Int64# +foreign import prim cmm_two2_p :: Any -> Any -> (# Any #) +foreign import prim cmm_two2_w :: Word# -> Word# -> Word# +foreign import prim cmm_two2_f :: Float# -> Float# -> Float# +foreign import prim cmm_two2_d :: Double# -> Double# -> Double# +foreign import prim cmm_two2_l :: Word64# -> Word64# -> Word64# + +{- additional tests for floating point, since D_ and F_ registers + overlap on some platforms -} + +foreign import prim cmm_floating_1 :: Float# -> Float# -> Float# +foreign import prim cmm_floating_2 :: Double# -> Double# -> Double# +foreign import prim cmm_floating_3 :: Float# -> Double# -> Float# +foreign import prim cmm_floating_4 :: Float# -> Double# -> Double# +foreign import prim cmm_floating_5 :: Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> (# Float#, Double# #) +foreign import prim cmm_floating_6 :: Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> (# Double#, Float# #) +foreign import prim cmm_floating_7 :: Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> (# Word#, Float#, Double# #) +-- various sized tuple returns + +foreign import prim cmm_tuple_1 :: Word# -> Word# -> Word# -> (# Word# , Word#, Word# #) +foreign import prim cmm_tuple_2 :: Any -> Any -> Word# -> Word# -> Any -> Any -> Double# -> Double# -> Any -> Any -> Float# -> Float# -> + (# Float#, Float#, Any, Any, Double#, Double#, Any, Any, Word#, Word#, Any, Any #) +foreign import prim cmm_tuple_3 :: Any -> Word# -> Any -> Double# -> Any -> Float# -> + (# Float#, Any, Double#, Any, Word#, Any #) +foreign import prim cmm_tuple_4 :: Any -> Any -> (# Any, Any #) + +-- boxed primitive types + +-- get the length of an array +foreign import prim cmm_array_1 :: Array# Any -> Int# +-- return some arrays +foreign import prim cmm_array_2 :: Array# Any -> Array# Any -> (# Array# Any, Array# Any #) + +foreign import prim cmm_many_arguments :: + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout ===================================== @@ -0,0 +1,60 @@ +zero arguments +123 +1.0 +1.0 +one argument functions +[0,-1,1,-128,127] +[0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,18446744073709551615] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615] +[(0,0),(-1,-1),(1,1),(-128,-128),(127,127)] +[(0,0),(-1,-1),(1,1),(-32768,-32768),(32767,32767)] +[(0,0),(-1,-1),(1,1),(-2147483648,-2147483648),(2147483647,2147483647)] +[(0,0),(-1,-1),(1,1),(-9223372036854775808,-9223372036854775808),(9223372036854775807,9223372036854775807)] +[(Nothing,Nothing),(Just 1,Just 1),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just (-18446744073709551617))] +[(0,0),(1,1),(2,2),(18446744073709551615,18446744073709551615)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e37,1.0e37),(-1.0e-37,-1.0e-37)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e307,1.0e307),(-1.0e-307,-1.0e-307)] +[(0,0),(1,1),(2,2),(4294967296,4294967296),(18446744073709551615,18446744073709551615)] +two argument functions +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-128,-128,-128,-128,-128,127,127,127,127,127] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-32768,-32768,-32768,-32768,-32768,32767,32767,32767,32767,32767] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,2147483647,2147483647,2147483647,2147483647,2147483647] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807] +[Nothing,Nothing,Nothing,Nothing,Just 1,Just 1,Just 1,Just 1,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617)] +[0,0,0,0,1,1,1,1,2,2,2,2,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307] +[0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,4294967296,4294967296,4294967296,4294967296,4294967296,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127] +[0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,18446744073709551615,0,1,2,18446744073709551615,0,1,2,18446744073709551615,0,1,2,18446744073709551615] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615] +additional floating point tests +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e37,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e37,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e37,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e37,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,Infinity,2.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-2.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e307,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e307,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e307,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e307,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,Infinity,2.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-2.0e-307] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e307),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e307),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e307),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e307),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e307),(Infinity,8060400.0),(1.0e37,8060400.0),(1.0e37,8060400.0),(1.0e37,8060399.0),(1.0e37,8060401.0),(1.0e37,8060398.0),(1.0e37,8060402.0),(1.0e37,Infinity),(1.0e37,1.0e307),(1.0e37,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0)] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e37),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e37),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e37),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e37),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e37),(Infinity,8060400.0),(1.0e307,8060400.0),(1.0e307,8060400.0),(1.0e307,8060399.0),(1.0e307,8060401.0),(1.0e307,8060398.0),(1.0e307,8060402.0),(1.0e307,Infinity),(1.0e307,1.0e37),(1.0e307,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0)] +[(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.1181512090599e13),(69,Infinity,2.1181512090601e13),(69,Infinity,2.1181512090598e13),(69,Infinity,2.1181512090602e13),(69,Infinity,Infinity),(69,Infinity,1.0e307),(69,Infinity,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.1181512090599e13),(69,1.0e37,2.1181512090601e13),(69,1.0e37,2.1181512090598e13),(69,1.0e37,2.1181512090602e13),(69,1.0e37,Infinity),(69,1.0e37,1.0e307),(69,1.0e37,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.1181512090599e13),(70,Infinity,2.1181512090601e13),(70,Infinity,2.1181512090598e13),(70,Infinity,2.1181512090602e13),(70,Infinity,Infinity),(70,Infinity,1.0e307),(70,Infinity,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.1181512090599e13),(70,1.0e37,2.1181512090601e13),(70,1.0e37,2.1181512090598e13),(70,1.0e37,2.1181512090602e13),(70,1.0e37,Infinity),(70,1.0e37,1.0e307),(70,1.0e37,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.1181512090599e13),(71,Infinity,2.1181512090601e13),(71,Infinity,2.1181512090598e13),(71,Infinity,2.1181512090602e13),(71,Infinity,Infinity),(71,Infinity,1.0e307),(71,Infinity,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.1181512090599e13),(71,1.0e37,2.1181512090601e13),(71,1.0e37,2.1181512090598e13),(71,1.0e37,2.1181512090602e13),(71,1.0e37,Infinity),(71,1.0e37,1.0e307),(71,1.0e37,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.1181512090599e13),(68,Infinity,2.1181512090601e13),(68,Infinity,2.1181512090598e13),(68,Infinity,2.1181512090602e13),(68,Infinity,Infinity),(68,Infinity,1.0e307),(68,Infinity,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.1181512090599e13),(68,1.0e37,2.1181512090601e13),(68,1.0e37,2.1181512090598e13),(68,1.0e37,2.1181512090602e13),(68,1.0e37,Infinity),(68,1.0e37,1.0e307),(68,1.0e37,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13)] +various sized tuple returns +[(3,0,0),(3,1,0),(3,2,0),(3,18446744073709551615,0),(3,0,1),(3,1,1),(3,2,1),(3,18446744073709551615,1),(3,0,2),(3,1,2),(3,2,2),(3,18446744073709551615,2),(3,0,18446744073709551615),(3,1,18446744073709551615),(3,2,18446744073709551615),(3,18446744073709551615,18446744073709551615)] +[(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just (-18446744073709551617))] +[(5.0,Just 1,3.0,Nothing,0,Nothing),(5.0,Just 1,3.0,Nothing,1,Nothing),(5.0,Just 1,3.0,Nothing,2,Nothing),(5.0,Just 1,3.0,Nothing,18446744073709551615,Nothing),(5.0,Just 1,3.0,Nothing,0,Just 1),(5.0,Just 1,3.0,Nothing,1,Just 1),(5.0,Just 1,3.0,Nothing,2,Just 1),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just 1),(5.0,Just 1,3.0,Nothing,0,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,1,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,2,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,0,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,1,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,2,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just (-18446744073709551617))] +[(Nothing,Nothing),(Just 1,Nothing),(Just 18446744073709551617,Nothing),(Just (-18446744073709551617),Nothing),(Nothing,Just 1),(Just 1,Just 1),(Just 18446744073709551617,Just 1),(Just (-18446744073709551617),Just 1),(Nothing,Just 18446744073709551617),(Just 1,Just 18446744073709551617),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just 18446744073709551617),(Nothing,Just (-18446744073709551617)),(Just 1,Just (-18446744073709551617)),(Just 18446744073709551617,Just (-18446744073709551617)),(Just (-18446744073709551617),Just (-18446744073709551617))] +arrays +(11,13) +(13,11) +many arguments +80200 ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout-ws-32 ===================================== @@ -0,0 +1,60 @@ +zero arguments +123 +1.0 +1.0 +one argument functions +[0,-1,1,-128,127] +[0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,4294967295] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615] +[(0,0),(-1,-1),(1,1),(-128,-128),(127,127)] +[(0,0),(-1,-1),(1,1),(-32768,-32768),(32767,32767)] +[(0,0),(-1,-1),(1,1),(-2147483648,-2147483648),(2147483647,2147483647)] +[(0,0),(-1,-1),(1,1),(-9223372036854775808,-9223372036854775808),(9223372036854775807,9223372036854775807)] +[(Nothing,Nothing),(Just 1,Just 1),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just (-18446744073709551617))] +[(0,0),(1,1),(2,2),(4294967295,4294967295)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e37,1.0e37),(-1.0e-37,-1.0e-37)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e307,1.0e307),(-1.0e-307,-1.0e-307)] +[(0,0),(1,1),(2,2),(4294967296,4294967296),(18446744073709551615,18446744073709551615)] +two argument functions +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-128,-128,-128,-128,-128,127,127,127,127,127] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-32768,-32768,-32768,-32768,-32768,32767,32767,32767,32767,32767] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,2147483647,2147483647,2147483647,2147483647,2147483647] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807] +[Nothing,Nothing,Nothing,Nothing,Just 1,Just 1,Just 1,Just 1,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617)] +[0,0,0,0,1,1,1,1,2,2,2,2,4294967295,4294967295,4294967295,4294967295] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307] +[0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,4294967296,4294967296,4294967296,4294967296,4294967296,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127] +[0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,4294967295,0,1,2,4294967295,0,1,2,4294967295,0,1,2,4294967295] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615] +additional floating point tests +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e37,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e37,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e37,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e37,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,Infinity,2.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-2.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e307,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e307,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e307,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e307,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,Infinity,2.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-2.0e-307] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e307),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e307),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e307),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e307),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e307),(Infinity,8060400.0),(1.0e37,8060400.0),(1.0e37,8060400.0),(1.0e37,8060399.0),(1.0e37,8060401.0),(1.0e37,8060398.0),(1.0e37,8060402.0),(1.0e37,Infinity),(1.0e37,1.0e307),(1.0e37,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0)] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e37),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e37),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e37),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e37),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e37),(Infinity,8060400.0),(1.0e307,8060400.0),(1.0e307,8060400.0),(1.0e307,8060399.0),(1.0e307,8060401.0),(1.0e307,8060398.0),(1.0e307,8060402.0),(1.0e307,Infinity),(1.0e307,1.0e37),(1.0e307,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0)] +[(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.1181512090599e13),(69,Infinity,2.1181512090601e13),(69,Infinity,2.1181512090598e13),(69,Infinity,2.1181512090602e13),(69,Infinity,Infinity),(69,Infinity,1.0e307),(69,Infinity,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.1181512090599e13),(69,1.0e37,2.1181512090601e13),(69,1.0e37,2.1181512090598e13),(69,1.0e37,2.1181512090602e13),(69,1.0e37,Infinity),(69,1.0e37,1.0e307),(69,1.0e37,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.1181512090599e13),(70,Infinity,2.1181512090601e13),(70,Infinity,2.1181512090598e13),(70,Infinity,2.1181512090602e13),(70,Infinity,Infinity),(70,Infinity,1.0e307),(70,Infinity,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.1181512090599e13),(70,1.0e37,2.1181512090601e13),(70,1.0e37,2.1181512090598e13),(70,1.0e37,2.1181512090602e13),(70,1.0e37,Infinity),(70,1.0e37,1.0e307),(70,1.0e37,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.1181512090599e13),(71,Infinity,2.1181512090601e13),(71,Infinity,2.1181512090598e13),(71,Infinity,2.1181512090602e13),(71,Infinity,Infinity),(71,Infinity,1.0e307),(71,Infinity,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.1181512090599e13),(71,1.0e37,2.1181512090601e13),(71,1.0e37,2.1181512090598e13),(71,1.0e37,2.1181512090602e13),(71,1.0e37,Infinity),(71,1.0e37,1.0e307),(71,1.0e37,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.1181512090599e13),(68,Infinity,2.1181512090601e13),(68,Infinity,2.1181512090598e13),(68,Infinity,2.1181512090602e13),(68,Infinity,Infinity),(68,Infinity,1.0e307),(68,Infinity,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.1181512090599e13),(68,1.0e37,2.1181512090601e13),(68,1.0e37,2.1181512090598e13),(68,1.0e37,2.1181512090602e13),(68,1.0e37,Infinity),(68,1.0e37,1.0e307),(68,1.0e37,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13)] +various sized tuple returns +[(3,0,0),(3,1,0),(3,2,0),(3,4294967295,0),(3,0,1),(3,1,1),(3,2,1),(3,4294967295,1),(3,0,2),(3,1,2),(3,2,2),(3,4294967295,2),(3,0,4294967295),(3,1,4294967295),(3,2,4294967295),(3,4294967295,4294967295)] +[(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just (-18446744073709551617))] +[(5.0,Just 1,3.0,Nothing,0,Nothing),(5.0,Just 1,3.0,Nothing,1,Nothing),(5.0,Just 1,3.0,Nothing,2,Nothing),(5.0,Just 1,3.0,Nothing,4294967295,Nothing),(5.0,Just 1,3.0,Nothing,0,Just 1),(5.0,Just 1,3.0,Nothing,1,Just 1),(5.0,Just 1,3.0,Nothing,2,Just 1),(5.0,Just 1,3.0,Nothing,4294967295,Just 1),(5.0,Just 1,3.0,Nothing,0,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,1,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,2,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,4294967295,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,0,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,1,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,2,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,4294967295,Just (-18446744073709551617))] +[(Nothing,Nothing),(Just 1,Nothing),(Just 18446744073709551617,Nothing),(Just (-18446744073709551617),Nothing),(Nothing,Just 1),(Just 1,Just 1),(Just 18446744073709551617,Just 1),(Just (-18446744073709551617),Just 1),(Nothing,Just 18446744073709551617),(Just 1,Just 18446744073709551617),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just 18446744073709551617),(Nothing,Just (-18446744073709551617)),(Just 1,Just (-18446744073709551617)),(Just 18446744073709551617,Just (-18446744073709551617)),(Just (-18446744073709551617),Just (-18446744073709551617))] +arrays +(11,13) +(13,11) +many arguments +80200 ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm ===================================== @@ -0,0 +1,230 @@ +#include "Cmm.h" + +/* zero arguments */ +cmm_zero() { /* ccall puts("cmm_zero"); buffering gets in the way */ return (); } +cmm_zero_w() { return (123::W_); } +cmm_zero_d() { return (1.0::D_); } +cmm_zero_f() { return (1.0::F_); } +cmm_zero_l() { return (123::L_); } + +/* one argument functions */ +cmm_one1_i8(I8 x) { return (x); } +cmm_one1_i16(I16 x) { return (x); } +cmm_one1_i32(I32 x) { return (x); } +cmm_one1_i64(I64 x) { return (x); } +cmm_one1_p(P_ x) { return (x); } +cmm_one1_w(W_ x) { return (x); } +cmm_one1_f(F_ x) { return (x); } +cmm_one1_d(D_ x) { return (x); } +cmm_one1_l(L_ x) { return (x); } + +cmm_one2_i8(I8 x) { return (x,x); } +cmm_one2_i16(I16 x) { return (x,x); } +cmm_one2_i32(I32 x) { return (x,x); } +cmm_one2_i64(I64 x) { return (x,x); } +cmm_one2_p(P_ x) { return (x,x); } +cmm_one2_w(W_ x) { return (x,x); } +cmm_one2_f(F_ x) { return (x,x); } +cmm_one2_d(D_ x) { return (x,x); } +cmm_one2_l(L_ x) { return (x,x); } + + +/* two argument functions */ +cmm_two1_i8(I8 x, I8 y) { return (x); } +cmm_two1_i16(I16 x, I16 y) { return (x); } +cmm_two1_i32(I32 x, I32 y) { return (x); } +cmm_two1_i64(I64 x, I64 y) { return (x); } +cmm_two1_p(P_ x, P_ y) { return (x); } +cmm_two1_w(W_ x, W_ y) { return (x); } +cmm_two1_f(F_ x, F_ y) { return (x); } +cmm_two1_d(D_ x, D_ y) { return (x); } +cmm_two1_l(L_ x, L_ y) { return (x); } + +cmm_two2_i8(I8 x, I8 y) { return (y); } +cmm_two2_i16(I16 x, I16 y) { return (y); } +cmm_two2_i32(I32 x, I32 y) { return (y); } +cmm_two2_i64(I64 x, I64 y) { return (y); } +cmm_two2_p(P_ x, P_ y) { return (y); } +cmm_two2_w(W_ x, W_ y) { return (y); } +cmm_two2_f(F_ x, F_ y) { return (y); } +cmm_two2_d(D_ x, D_ y) { return (y); } +cmm_two2_l(L_ x, L_ y) { return (y); } + +/* additional tests for floating point, since D_ and F_ registers + overlap on some platforms */ +cmm_floating_1(F_ x, F_ y) { F_ z; z = %fadd(x, y); return (z); } +cmm_floating_2(D_ x, D_ y) { D_ z; z = %fadd(x, y); return (z); } +cmm_floating_3(F_ x, D_ y) { return (x); } +cmm_floating_4(F_ x, D_ y) { return (y); } + + +cmm_floating_5(F_ x1, D_ x2, F_ x3, D_ x4, F_ x5, D_ x6, F_ x7, D_ x8) { + F_ y1; + D_ y2; + + y1 = %fadd(x1,x3); + y1 = %fadd(y1,x5); + y1 = %fadd(y1,x7); + + y2 = %fadd(x2,x4); + y2 = %fadd(y2,x6); + y2 = %fadd(y2,x8); + + return (y1, y2); +} + + +cmm_floating_6(D_ x1, F_ x2, D_ x3, F_ x4, D_ x5, F_ x6, D_ x7, F_ x8) { + D_ y1; + F_ y2; + + y1 = %fadd(x1,x3); + y1 = %fadd(y1,x5); + y1 = %fadd(y1,x7); + + y2 = %fadd(x2,x4); + y2 = %fadd(y2,x6); + y2 = %fadd(y2,x8); + + return (y1, y2); +} + + +cmm_floating_7( W_ x1, F_ x2, D_ x3 + , W_ x4, F_ x5, D_ x6 + , W_ x7, F_ x8, D_ x9 + , W_ x10, F_ x11, D_ x12 + , W_ x13, F_ x14, D_ x15 + , W_ x16, F_ x17, D_ x18 + , W_ x19, F_ x20, D_ x21 + ) { + W_ y1; + F_ y2; + D_ y3; + y1 = x1+x4+x7+x10+x13+x16+x19; + + y2 = %fadd(x2,x5); + y2 = %fadd(y2,x8); + y2 = %fadd(y2,x11); + y2 = %fadd(y2,x14); + y2 = %fadd(y2,x17); + y2 = %fadd(y2,x20); + + y3 = %fadd(x3,x6); + y3 = %fadd(y3,x9); + y3 = %fadd(y3,x12); + y3 = %fadd(y3,x15); + y3 = %fadd(y3,x18); + y3 = %fadd(y3,x21); + + return ( y1, y2, y3 ); +} + + +/* various sized tuple returns */ + +cmm_tuple_1(W_ x, W_ y, W_ z) { return (z, y, x); } +cmm_tuple_2(P_ p1, P_ p2, W_ w1, W_ w2, P_ p3, P_ p4, D_ d1, D_ d2, P_ p5, P_ p6, F_ f1, F_ f2) { + return (f2, f1, p6, p5, d2, d1, p4, p3, w2, w1, p2, p1); +} +cmm_tuple_3(P_ p1, W_ w1, P_ p2, D_ d1, P_ p3, F_ f1) { + return (f1, p3, d1, p2, w1, p1); +} +cmm_tuple_4(P_ p1, P_ p2) { return (p2, p1); } + +/* working with arrays */ +cmm_array_1(P_ x) { + W_ size; + size = StgMutArrPtrs_size(x); + return (size); +} + +/* return two arrays */ +cmm_array_2(P_ x, P_ y) { + return (y, x); +} + +/* many arguments */ +cmm_many_arguments(W_ x1, W_ x2, W_ x3, W_ x4, W_ x5, W_ x6, W_ x7, W_ x8, W_ x9, W_ x10, + W_ x11, W_ x12, W_ x13, W_ x14, W_ x15, W_ x16, W_ x17, W_ x18, W_ x19, W_ x20, + W_ x21, W_ x22, W_ x23, W_ x24, W_ x25, W_ x26, W_ x27, W_ x28, W_ x29, W_ x30, + W_ x31, W_ x32, W_ x33, W_ x34, W_ x35, W_ x36, W_ x37, W_ x38, W_ x39, W_ x40, + W_ x41, W_ x42, W_ x43, W_ x44, W_ x45, W_ x46, W_ x47, W_ x48, W_ x49, W_ x50, + W_ x51, W_ x52, W_ x53, W_ x54, W_ x55, W_ x56, W_ x57, W_ x58, W_ x59, W_ x60, + W_ x61, W_ x62, W_ x63, W_ x64, W_ x65, W_ x66, W_ x67, W_ x68, W_ x69, W_ x70, + W_ x71, W_ x72, W_ x73, W_ x74, W_ x75, W_ x76, W_ x77, W_ x78, W_ x79, W_ x80, + W_ x81, W_ x82, W_ x83, W_ x84, W_ x85, W_ x86, W_ x87, W_ x88, W_ x89, W_ x90, + W_ x91, W_ x92, W_ x93, W_ x94, W_ x95, W_ x96, W_ x97, W_ x98, W_ x99, W_ x100, + W_ x101, W_ x102, W_ x103, W_ x104, W_ x105, W_ x106, W_ x107, W_ x108, W_ x109, W_ x110, + W_ x111, W_ x112, W_ x113, W_ x114, W_ x115, W_ x116, W_ x117, W_ x118, W_ x119, W_ x120, + W_ x121, W_ x122, W_ x123, W_ x124, W_ x125, W_ x126, W_ x127, W_ x128, W_ x129, W_ x130, + W_ x131, W_ x132, W_ x133, W_ x134, W_ x135, W_ x136, W_ x137, W_ x138, W_ x139, W_ x140, + W_ x141, W_ x142, W_ x143, W_ x144, W_ x145, W_ x146, W_ x147, W_ x148, W_ x149, W_ x150, + W_ x151, W_ x152, W_ x153, W_ x154, W_ x155, W_ x156, W_ x157, W_ x158, W_ x159, W_ x160, + W_ x161, W_ x162, W_ x163, W_ x164, W_ x165, W_ x166, W_ x167, W_ x168, W_ x169, W_ x170, + W_ x171, W_ x172, W_ x173, W_ x174, W_ x175, W_ x176, W_ x177, W_ x178, W_ x179, W_ x180, + W_ x181, W_ x182, W_ x183, W_ x184, W_ x185, W_ x186, W_ x187, W_ x188, W_ x189, W_ x190, + W_ x191, W_ x192, W_ x193, W_ x194, W_ x195, W_ x196, W_ x197, W_ x198, W_ x199, W_ x200, + W_ x201, W_ x202, W_ x203, W_ x204, W_ x205, W_ x206, W_ x207, W_ x208, W_ x209, W_ x210, + W_ x211, W_ x212, W_ x213, W_ x214, W_ x215, W_ x216, W_ x217, W_ x218, W_ x219, W_ x220, + W_ x221, W_ x222, W_ x223, W_ x224, W_ x225, W_ x226, W_ x227, W_ x228, W_ x229, W_ x230, + W_ x231, W_ x232, W_ x233, W_ x234, W_ x235, W_ x236, W_ x237, W_ x238, W_ x239, W_ x240, + W_ x241, W_ x242, W_ x243, W_ x244, W_ x245, W_ x246, W_ x247, W_ x248, W_ x249, W_ x250, + W_ x251, W_ x252, W_ x253, W_ x254, W_ x255, W_ x256, W_ x257, W_ x258, W_ x259, W_ x260, + W_ x261, W_ x262, W_ x263, W_ x264, W_ x265, W_ x266, W_ x267, W_ x268, W_ x269, W_ x270, + W_ x271, W_ x272, W_ x273, W_ x274, W_ x275, W_ x276, W_ x277, W_ x278, W_ x279, W_ x280, + W_ x281, W_ x282, W_ x283, W_ x284, W_ x285, W_ x286, W_ x287, W_ x288, W_ x289, W_ x290, + W_ x291, W_ x292, W_ x293, W_ x294, W_ x295, W_ x296, W_ x297, W_ x298, W_ x299, W_ x300, + W_ x301, W_ x302, W_ x303, W_ x304, W_ x305, W_ x306, W_ x307, W_ x308, W_ x309, W_ x310, + W_ x311, W_ x312, W_ x313, W_ x314, W_ x315, W_ x316, W_ x317, W_ x318, W_ x319, W_ x320, + W_ x321, W_ x322, W_ x323, W_ x324, W_ x325, W_ x326, W_ x327, W_ x328, W_ x329, W_ x330, + W_ x331, W_ x332, W_ x333, W_ x334, W_ x335, W_ x336, W_ x337, W_ x338, W_ x339, W_ x340, + W_ x341, W_ x342, W_ x343, W_ x344, W_ x345, W_ x346, W_ x347, W_ x348, W_ x349, W_ x350, + W_ x351, W_ x352, W_ x353, W_ x354, W_ x355, W_ x356, W_ x357, W_ x358, W_ x359, W_ x360, + W_ x361, W_ x362, W_ x363, W_ x364, W_ x365, W_ x366, W_ x367, W_ x368, W_ x369, W_ x370, + W_ x371, W_ x372, W_ x373, W_ x374, W_ x375, W_ x376, W_ x377, W_ x378, W_ x379, W_ x380, + W_ x381, W_ x382, W_ x383, W_ x384, W_ x385, W_ x386, W_ x387, W_ x388, W_ x389, W_ x390, + W_ x391, W_ x392, W_ x393, W_ x394, W_ x395, W_ x396, W_ x397, W_ x398, W_ x399, W_ x400) { + W_ y; + y = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + + x21 + x22 + x23 + x24 + x25 + x26 + x27 + x28 + x29 + x30 + + x31 + x32 + x33 + x34 + x35 + x36 + x37 + x38 + x39 + x40 + + x41 + x42 + x43 + x44 + x45 + x46 + x47 + x48 + x49 + x50 + + x51 + x52 + x53 + x54 + x55 + x56 + x57 + x58 + x59 + x60 + + x61 + x62 + x63 + x64 + x65 + x66 + x67 + x68 + x69 + x70 + + x71 + x72 + x73 + x74 + x75 + x76 + x77 + x78 + x79 + x80 + + x81 + x82 + x83 + x84 + x85 + x86 + x87 + x88 + x89 + x90 + + x91 + x92 + x93 + x94 + x95 + x96 + x97 + x98 + x99 + x100 + + x101 + x102 + x103 + x104 + x105 + x106 + x107 + x108 + x109 + x110 + + x111 + x112 + x113 + x114 + x115 + x116 + x117 + x118 + x119 + x120 + + x121 + x122 + x123 + x124 + x125 + x126 + x127 + x128 + x129 + x130 + + x131 + x132 + x133 + x134 + x135 + x136 + x137 + x138 + x139 + x140 + + x141 + x142 + x143 + x144 + x145 + x146 + x147 + x148 + x149 + x150 + + x151 + x152 + x153 + x154 + x155 + x156 + x157 + x158 + x159 + x160 + + x161 + x162 + x163 + x164 + x165 + x166 + x167 + x168 + x169 + x170 + + x171 + x172 + x173 + x174 + x175 + x176 + x177 + x178 + x179 + x180 + + x181 + x182 + x183 + x184 + x185 + x186 + x187 + x188 + x189 + x190 + + x191 + x192 + x193 + x194 + x195 + x196 + x197 + x198 + x199 + x200 + + x201 + x202 + x203 + x204 + x205 + x206 + x207 + x208 + x209 + x210 + + x211 + x212 + x213 + x214 + x215 + x216 + x217 + x218 + x219 + x220 + + x221 + x222 + x223 + x224 + x225 + x226 + x227 + x228 + x229 + x230 + + x231 + x232 + x233 + x234 + x235 + x236 + x237 + x238 + x239 + x240 + + x241 + x242 + x243 + x244 + x245 + x246 + x247 + x248 + x249 + x250 + + x251 + x252 + x253 + x254 + x255 + x256 + x257 + x258 + x259 + x260 + + x261 + x262 + x263 + x264 + x265 + x266 + x267 + x268 + x269 + x270 + + x271 + x272 + x273 + x274 + x275 + x276 + x277 + x278 + x279 + x280 + + x281 + x282 + x283 + x284 + x285 + x286 + x287 + x288 + x289 + x290 + + x291 + x292 + x293 + x294 + x295 + x296 + x297 + x298 + x299 + x300 + + x301 + x302 + x303 + x304 + x305 + x306 + x307 + x308 + x309 + x310 + + x311 + x312 + x313 + x314 + x315 + x316 + x317 + x318 + x319 + x320 + + x321 + x322 + x323 + x324 + x325 + x326 + x327 + x328 + x329 + x330 + + x331 + x332 + x333 + x334 + x335 + x336 + x337 + x338 + x339 + x340 + + x341 + x342 + x343 + x344 + x345 + x346 + x347 + x348 + x349 + x350 + + x351 + x352 + x353 + x354 + x355 + x356 + x357 + x358 + x359 + x360 + + x361 + x362 + x363 + x364 + x365 + x366 + x367 + x368 + x369 + x370 + + x371 + x372 + x373 + x374 + x375 + x376 + x377 + x378 + x379 + x380 + + x381 + x382 + x383 + x384 + x385 + x386 + x387 + x388 + x389 + x390 + + x391 + x392 + x393 + x394 + x395 + x396 + x397 + x398 + x399 + x400; + return (y); +} ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile ===================================== @@ -0,0 +1,4 @@ +.PHONY: GHCiPrimCall +GHCiPrimCall: + '$(TEST_HC)' $(TEST_HC_OPTS) -fPIC -v0 -c GHCiPrimCall_cmm.cmm + -'$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -e main GHCiPrimCall.hs GHCiPrimCall_cmm.o || echo $$? >&2 ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/all.T ===================================== @@ -0,0 +1,2 @@ +test('GHCiPrimCall', [req_interp], makefile_test, ['GHCiPrimCall']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/daa8d8c1fc01029322f030498c5f66e6d7d4b25c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/daa8d8c1fc01029322f030498c5f66e6d7d4b25c You're receiving 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 Jan 10 06:27:06 2023 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Tue, 10 Jan 2023 01:27:06 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] Add PrimCallConv support to GHCi Message-ID: <63bd053a72a76_3b1bf959e70340396@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 4807d580 by Luite Stegeman at 2023-01-10T15:26:29+09:00 Add PrimCallConv support to GHCi This adds support for calling Cmm code from bytecode using the native calling convention, allowing modules that use `foreign import prim` to be loaded and debugged in GHCi. This patch introduces a new `PRIMCALL` bytecode instruction and a helper stack frame `stg_primcall`. The code is based on the existing functionality for dealing with unboxed tuples in bytecode, which has been generalised to handle arbitrary calls. Fixes #22051 - - - - - 21 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Foreign.hs - rts/Disassembler.c - rts/Interpreter.c - rts/RtsSymbols.c - rts/StgMiscClosures.cmm - rts/include/rts/Bytecodes.h - rts/include/stg/MiscClosures.h - testsuite/tests/ghci/prog014/prog014.T - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout-ws-32 - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm - + testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile - + testsuite/tests/ghci/should_run/GHCiPrimCall/all.T Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -12,7 +12,7 @@ module GHC.ByteCode.Asm ( bcoFreeNames, SizedSeq, sizeSS, ssElts, iNTERP_STACK_CHECK_THRESH, - mkTupleInfoLit + mkNativeCallInfoLit ) where import GHC.Prelude @@ -32,7 +32,6 @@ import GHC.Types.Unique.DSet import GHC.Utils.Outputable import GHC.Utils.Panic -import GHC.Utils.Panic.Plain import GHC.Core.TyCon import GHC.Data.FastString @@ -40,7 +39,7 @@ import GHC.Data.SizedSeq import GHC.StgToCmm.Layout ( ArgRep(..) ) import GHC.Cmm.Expr -import GHC.Cmm.CallConv ( tupleRegsCover ) +import GHC.Cmm.CallConv ( allArgRegsCover ) import GHC.Platform import GHC.Platform.Profile @@ -202,7 +201,8 @@ assembleBCO platform (ProtoBCO { protoBCOName = nm (final_insns, final_lits, final_ptrs) <- flip execStateT initial_state $ runAsm platform long_jumps env asm -- precomputed size should be equal to final size - massert (n_insns == sizeSS final_insns) + massertPpr (n_insns == sizeSS final_insns) + (text "bytecode instruction count mismatch") let asm_insns = ssElts final_insns insns_arr = Array.listArray (0, fromIntegral n_insns - 1) asm_insns @@ -351,7 +351,8 @@ largeArg platform w = case platformWordSize platform of fromIntegral (w `shiftR` 32), fromIntegral (w `shiftR` 16), fromIntegral w] - PW4 -> assert (w < fromIntegral (maxBound :: Word32)) $ + PW4 -> assertPpr (w < fromIntegral (maxBound :: Word32)) + (text "largeArg too big:" <+> ppr w) $ [fromIntegral (w `shiftR` 16), fromIntegral w] @@ -388,14 +389,14 @@ assembleI platform i = case i of -> do let ul_bco = assembleBCO platform proto p <- ioptr (liftM BCOPtrBCO ul_bco) emit (push_alts pk) [Op p] - PUSH_ALTS_TUPLE proto tuple_info tuple_proto + PUSH_ALTS_TUPLE proto call_info tuple_proto -> do let ul_bco = assembleBCO platform proto ul_tuple_bco = assembleBCO platform tuple_proto p <- ioptr (liftM BCOPtrBCO ul_bco) p_tup <- ioptr (liftM BCOPtrBCO ul_tuple_bco) info <- int (fromIntegral $ - mkTupleInfoSig platform tuple_info) + mkNativeCallInfoSig platform call_info) emit bci_PUSH_ALTS_T [Op p, Op info, Op p_tup] PUSH_PAD8 -> emit bci_PUSH_PAD8 [] @@ -491,6 +492,7 @@ assembleI platform i = case i of RETURN_TUPLE -> emit bci_RETURN_T [] CCALL off m_addr i -> do np <- addr m_addr emit bci_CCALL [SmallOp off, Op np, SmallOp i] + PRIMCALL -> emit bci_PRIMCALL [] BRK_FUN index uniq cc -> do p1 <- ptr BCOPtrBreakArray q <- int (getKey uniq) np <- addr cc @@ -580,41 +582,44 @@ return_unlifted V64 = error "return_unlifted: vector" maximum number of tuple elements may be larger. Elements can also take multiple words on the stack (for example Double# on a 32 bit platform). - -} -maxTupleNativeStackSize :: WordOff -maxTupleNativeStackSize = 62 +maxTupleReturnNativeStackSize :: WordOff +maxTupleReturnNativeStackSize = 62 {- - Construct the tuple_info word that stg_ctoi_t and stg_ret_t use - to convert a tuple between the native calling convention and the + Construct the call_info word that stg_ctoi_t, stg_ret_t and stg_primcall + use to convert arguments between the native calling convention and the interpreter. - See Note [GHCi tuple layout] for more information. + See Note [GHCi and native call registers] for more information. -} -mkTupleInfoSig :: Platform -> TupleInfo -> Word32 -mkTupleInfoSig platform TupleInfo{..} - | tupleNativeStackSize > maxTupleNativeStackSize - = pprPanic "mkTupleInfoSig: tuple too big for the bytecode compiler" - (ppr tupleNativeStackSize <+> text "stack words." <+> +mkNativeCallInfoSig :: Platform -> NativeCallInfo -> Word32 +mkNativeCallInfoSig platform NativeCallInfo{..} + | nativeCallType == NativeTupleReturn && nativeCallStackSpillSize > maxTupleReturnNativeStackSize + = pprPanic "mkNativeCallInfoSig: tuple too big for the bytecode compiler" + (ppr nativeCallStackSpillSize <+> text "stack words." <+> text "Use -fobject-code to get around this limit" ) | otherwise - = assert (length regs <= 24) {- 24 bits for bitmap -} - assert (tupleNativeStackSize < 255) {- 8 bits for stack size -} - assert (all (`elem` regs) (regSetToList tupleRegs)) {- all regs accounted for -} - foldl' reg_bit 0 (zip regs [0..]) .|. - (fromIntegral tupleNativeStackSize `shiftL` 24) + = assertPpr (length regs <= 24) (text "too many registers for bitmap:" <+> ppr (length regs)) {- 24 bits for register bitmap -} + assertPpr (cont_offset < 255) (text "continuation offset too large:" <+> ppr cont_offset) {- 8 bits for continuation offset (only for NativeTupleReturn) -} + assertPpr (all (`elem` regs) (regSetToList nativeCallRegs)) (text "not all registers accounted for") {- all regs accounted for -} + foldl' reg_bit 0 (zip regs [0..]) .|. (cont_offset `shiftL` 24) where + cont_offset :: Word32 + cont_offset + | nativeCallType == NativeTupleReturn = fromIntegral nativeCallStackSpillSize + | otherwise = 0 -- there is no continuation for primcalls + reg_bit :: Word32 -> (GlobalReg, Int) -> Word32 reg_bit x (r, n) - | r `elemRegSet` tupleRegs = x .|. 1 `shiftL` n - | otherwise = x - regs = tupleRegsCover platform + | r `elemRegSet` nativeCallRegs = x .|. 1 `shiftL` n + | otherwise = x + regs = allArgRegsCover platform -mkTupleInfoLit :: Platform -> TupleInfo -> Literal -mkTupleInfoLit platform tuple_info = - mkLitWord platform . fromIntegral $ mkTupleInfoSig platform tuple_info +mkNativeCallInfoLit :: Platform -> NativeCallInfo -> Literal +mkNativeCallInfoLit platform call_info = + mkLitWord platform . fromIntegral $ mkNativeCallInfoSig platform call_info -- Make lists of host-sized words for literals, so that when the -- words are placed in memory at increasing addresses, the ===================================== compiler/GHC/ByteCode/Instr.hs ===================================== @@ -90,7 +90,7 @@ data BCInstr | PUSH_ALTS (ProtoBCO Name) | PUSH_ALTS_UNLIFTED (ProtoBCO Name) ArgRep | PUSH_ALTS_TUPLE (ProtoBCO Name) -- continuation - !TupleInfo + !NativeCallInfo (ProtoBCO Name) -- tuple return BCO -- Pushing 8, 16 and 32 bits of padding (for constructors). @@ -184,6 +184,8 @@ data BCInstr -- (XXX: inefficient, but I don't know -- what the alignment constraints are.) + | PRIMCALL + -- For doing magic ByteArray passing to foreign calls | SWIZZLE Word16 -- to the ptr N words down the stack, Word16 -- add M (interpreted as a signed 16-bit entity) @@ -269,8 +271,8 @@ instance Outputable BCInstr where ppr (PUSH_ALTS bco) = hang (text "PUSH_ALTS") 2 (ppr bco) ppr (PUSH_ALTS_UNLIFTED bco pk) = hang (text "PUSH_ALTS_UNLIFTED" <+> ppr pk) 2 (ppr bco) - ppr (PUSH_ALTS_TUPLE bco tuple_info tuple_bco) = - hang (text "PUSH_ALTS_TUPLE" <+> ppr tuple_info) + ppr (PUSH_ALTS_TUPLE bco call_info tuple_bco) = + hang (text "PUSH_ALTS_TUPLE" <+> ppr call_info) 2 (ppr tuple_bco $+$ ppr bco) @@ -340,6 +342,7 @@ instance Outputable BCInstr where 0x1 -> text "(interruptible)" 0x2 -> text "(unsafe)" _ -> empty) + ppr PRIMCALL = text "PRIMCALL" ppr (SWIZZLE stkoff n) = text "SWIZZLE " <+> text "stkoff" <+> ppr stkoff <+> text "by" <+> ppr n ppr ENTER = text "ENTER" @@ -382,11 +385,11 @@ bciStackUse (PUSH_ALTS bco) = 2 {- profiling only, restore CCCS -} + bciStackUse (PUSH_ALTS_UNLIFTED bco _) = 2 {- profiling only, restore CCCS -} + 4 + protoBCOStackUse bco bciStackUse (PUSH_ALTS_TUPLE bco info _) = - -- (tuple_bco, tuple_info word, cont_bco, stg_ctoi_t) + -- (tuple_bco, call_info word, cont_bco, stg_ctoi_t) -- tuple - -- (tuple_info, tuple_bco, stg_ret_t) + -- (call_info, tuple_bco, stg_ret_t) 1 {- profiling only -} + - 7 + fromIntegral (tupleSize info) + protoBCOStackUse bco + 7 + fromIntegral (nativeCallSize info) + protoBCOStackUse bco bciStackUse (PUSH_PAD8) = 1 -- overapproximation bciStackUse (PUSH_PAD16) = 1 -- overapproximation bciStackUse (PUSH_PAD32) = 1 -- overapproximation on 64bit arch @@ -443,6 +446,7 @@ bciStackUse RETURN{} = 0 bciStackUse RETURN_UNLIFTED{} = 1 -- pushes stg_ret_X for some X bciStackUse RETURN_TUPLE{} = 1 -- pushes stg_ret_t header bciStackUse CCALL{} = 0 +bciStackUse PRIMCALL{} = 1 -- pushes stg_primcall bciStackUse SWIZZLE{} = 0 bciStackUse BRK_FUN{} = 0 ===================================== compiler/GHC/ByteCode/Types.hs ===================================== @@ -10,7 +10,7 @@ module GHC.ByteCode.Types ( CompiledByteCode(..), seqCompiledByteCode , FFIInfo(..) , RegBitmap(..) - , TupleInfo(..), voidTupleInfo + , NativeCallType(..), NativeCallInfo(..), voidTupleReturnInfo, voidPrimCallInfo , ByteOff(..), WordOff(..) , UnlinkedBCO(..), BCOPtr(..), BCONPtr(..) , ItblEnv, ItblPtr(..) @@ -105,22 +105,32 @@ newtype RegBitmap = RegBitmap { unRegBitmap :: Word32 } See GHC.StgToByteCode.layoutTuple for more details. -} -data TupleInfo = TupleInfo - { tupleSize :: !WordOff -- total size of tuple in words - , tupleRegs :: !GlobalRegSet - , tupleNativeStackSize :: !WordOff {- words spilled on the stack by - GHCs native calling convention -} - } deriving (Show) - -instance Outputable TupleInfo where - ppr TupleInfo{..} = text " ppr tupleSize <+> - text "stack" <+> ppr tupleNativeStackSize <+> - text "regs" <+> - ppr (map (text @SDoc . show) $ regSetToList tupleRegs) <> - char '>' - -voidTupleInfo :: TupleInfo -voidTupleInfo = TupleInfo 0 emptyRegSet 0 + +data NativeCallType = NativePrimCall + | NativeTupleReturn + deriving (Eq) + +data NativeCallInfo = NativeCallInfo + { nativeCallType :: !NativeCallType + , nativeCallSize :: !WordOff -- total size of arguments in words + , nativeCallRegs :: !GlobalRegSet + , nativeCallStackSpillSize :: !WordOff {- words spilled on the stack by + GHCs native calling convention -} + } + +instance Outputable NativeCallInfo where + ppr NativeCallInfo{..} = text " ppr nativeCallSize <+> + text "stack" <+> ppr nativeCallStackSpillSize <+> + text "regs" <+> + ppr (map (text @SDoc . show) $ regSetToList nativeCallRegs) <> + char '>' + + +voidTupleReturnInfo :: NativeCallInfo +voidTupleReturnInfo = NativeCallInfo NativeTupleReturn 0 emptyRegSet 0 + +voidPrimCallInfo :: NativeCallInfo +voidPrimCallInfo = NativeCallInfo NativePrimCall 0 emptyRegSet 0 type ItblEnv = NameEnv (Name, ItblPtr) -- We need the Name in the range so we know which ===================================== compiler/GHC/Cmm/CallConv.hs ===================================== @@ -3,7 +3,7 @@ module GHC.Cmm.CallConv ( assignArgumentsPos, assignStack, realArgRegsCover, - tupleRegsCover + allArgRegsCover ) where import GHC.Prelude @@ -220,12 +220,109 @@ realArgRegsCover platform realLongRegs platform -- we don't save XMM registers if they are not used for parameter passing --- Like realArgRegsCover but always includes the node. This covers the real --- and virtual registers used for unboxed tuples. --- --- Note: if anything changes in how registers for unboxed tuples overlap, --- make sure to also update GHC.StgToByteCode.layoutTuple. -tupleRegsCover :: Platform -> [GlobalReg] -tupleRegsCover platform = +{- + + Note [GHCi and native call registers] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + The GHCi bytecode interpreter does not have access to the STG registers + that the native calling convention uses for passing arguments. It uses + helper stack frames to move values between the stack and registers. + + If only a single register needs to be moved, GHCi uses a specific stack + frame. For example stg_ctoi_R1p saves a heap pointer value from STG register + R1 and stg_ctoi_D1 saves a double precision floating point value from D1. + In the other direction, helpers stg_ret_p and stg_ret_d move a value from + the stack to the R1 and D1 registers, respectively. + + When GHCi needs to move more than one register it cannot use a specific + helper frame. It would simply be impossible to create a helper for all + possible combinations of register values. Instead, there are generic helper + stack frames that use a call_info word that describes the active registers + and the number of stack words used by the arguments of a call. + + These helper stack frames are currently: + + - stg_ret_t: return a tuple to the continuation at the top of + the stack + - stg_ctoi_t: convert a tuple return value to be used in + bytecode + - stg_primcall: call a function + + + The call_info word contains a bitmap of the active registers + for the call and and a stack offset. The layout is as follows: + + - bit 0-23: Bitmap of active registers for the call, the + order corresponds to the list returned by + allArgRegsCover. For example if bit 0 (the least + significant bit) is set, the first register in the + allArgRegsCover list is active. Bit 1 for the + second register in the list and so on. + + - bit 24-31: Unsigned byte indicating the stack offset + of the continuation in words. For tuple returns + this is the number of words returned on the + stack. For primcalls this field is unused, since + we don't jump to a continuation. + + The upper 32 bits on 64 bit platforms are currently unused. + + If a register is smaller than a word on the stack (for example a + single precision float on a 64 bit system), then the stack slot + is padded to a whole word. + + Example: + + If a tuple is returned in three registers and an additional two + words on the stack, then three bits in the register bitmap + (bits 0-23) would be set. And bit 24-31 would be + 00000010 (two in binary). + + The values on the stack before a call to POP_ARG_REGS would + be as follows: + + ... + continuation + stack_arg_1 + stack_arg_2 + register_arg_3 + register_arg_2 + register_arg_1 <- Sp + + A call to POP_ARG_REGS(call_info) would move register_arg_1 + to the register corresponding to the lowest set bit in the + call_info word. register_arg_2 would be moved to the register + corresponding to the second lowest set bit, and so on. + + After POP_ARG_REGS(call_info), the stack pointer Sp points + to the topmost stack argument, so the stack looks as follows: + + ... + continuation + stack_arg_1 + stack_arg_2 <- Sp + + At this point all the arguments are in place and we are ready + to jump to the continuation, the location (offset from Sp) of + which is found by inspecting the value of bits 24-31. In this + case the offset is two words. + + On x86_64, the double precision (Dn) and single precision + floating (Fn) point registers overlap, e.g. D1 uses the same + physical register as F1. On this platform, the list returned + by allArgRegsCover contains only entries for the double + precision registers. If an argument is passed in register + Fn, the bit corresponding to Dn should be set. + + Note: if anything changes in how registers for native calls overlap, + make sure to also update GHC.StgToByteCode.layoutNativeCall + -} + +-- Like realArgRegsCover but always includes the node. This covers all real +-- and virtual registers actually used for passing arguments. + +allArgRegsCover :: Platform -> [GlobalReg] +allArgRegsCover platform = nub (VanillaReg 1 VGcPtr : realArgRegsCover platform) ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -1233,8 +1233,8 @@ stmtMacros = listToUFM [ ( fsLit "SAVE_REGS", \[] -> emitSaveRegs ), ( fsLit "RESTORE_REGS", \[] -> emitRestoreRegs ), - ( fsLit "PUSH_TUPLE_REGS", \[live_regs] -> emitPushTupleRegs live_regs ), - ( fsLit "POP_TUPLE_REGS", \[live_regs] -> emitPopTupleRegs live_regs ), + ( fsLit "PUSH_ARG_REGS", \[live_regs] -> emitPushArgRegs live_regs ), + ( fsLit "POP_ARG_REGS", \[live_regs] -> emitPopArgRegs live_regs ), ( fsLit "LDV_ENTER", \[e] -> ldvEnter e ), ( fsLit "LDV_RECORD_CREATE", \[e] -> ldvRecordCreate e ), ===================================== compiler/GHC/Cmm/Reg.hs ===================================== @@ -223,7 +223,7 @@ instance Eq GlobalReg where _r1 == _r2 = False -- NOTE: this Ord instance affects the tuple layout in GHCi, see --- Note [GHCi tuple layout] +-- Note [GHCi and native call registers] instance Ord GlobalReg where compare (VanillaReg i _) (VanillaReg j _) = compare i j -- Ignore type when seeking clashes ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -58,7 +58,7 @@ import GHC.Data.FastString import GHC.Utils.Panic import GHC.Utils.Panic.Plain import GHC.Utils.Exception (evaluate) -import GHC.StgToCmm.Closure ( NonVoid(..), fromNonVoid, nonVoidIds ) +import GHC.StgToCmm.Closure ( NonVoid(..), fromNonVoid, nonVoidIds, argPrimRep ) import GHC.StgToCmm.Layout import GHC.Runtime.Heap.Layout hiding (WordOff, ByteOff, wordsToBytes) import GHC.Data.Bitmap @@ -464,10 +464,10 @@ returnUnliftedReps d s szb reps = do [rep] -> return (unitOL $ RETURN_UNLIFTED (toArgRep platform rep)) -- otherwise use RETURN_TUPLE with a tuple descriptor nv_reps -> do - let (tuple_info, args_offsets) = layoutTuple profile 0 (primRepCmmType platform) nv_reps + let (call_info, args_offsets) = layoutNativeCall profile NativeTupleReturn 0 (primRepCmmType platform) nv_reps args_ptrs = map (\(rep, off) -> (isFollowableArg (toArgRep platform rep), off)) args_offsets - tuple_bco <- emitBc (tupleBCO platform tuple_info args_ptrs) - return $ PUSH_UBX (mkTupleInfoLit platform tuple_info) 1 `consOL` + tuple_bco <- emitBc (tupleBCO platform call_info args_ptrs) + return $ PUSH_UBX (mkNativeCallInfoLit platform call_info) 1 `consOL` PUSH_BCO tuple_bco `consOL` unitOL RETURN_TUPLE return ( mkSlideB platform szb (d - s) -- clear to sequel @@ -484,7 +484,11 @@ returnUnboxedTuple d s p es = do profile <- getProfile let platform = profilePlatform profile arg_ty e = primRepCmmType platform (atomPrimRep e) - (tuple_info, tuple_components) = layoutTuple profile d arg_ty es + (call_info, tuple_components) = layoutNativeCall profile + NativeTupleReturn + d + arg_ty + es go _ pushes [] = return (reverse pushes) go !dd pushes ((a, off):cs) = do (push, szb) <- pushAtom dd p a massert (off == dd + szb) @@ -492,7 +496,7 @@ returnUnboxedTuple d s p es = do pushes <- go d [] tuple_components ret <- returnUnliftedReps d s - (wordsToBytes platform $ tupleSize tuple_info) + (wordsToBytes platform $ nativeCallSize call_info) (map atomPrimRep es) return (mconcat pushes `appOL` ret) @@ -648,14 +652,14 @@ schemeT d s p app -- Case 1 schemeT d s p (StgOpApp (StgFCallOp (CCall ccall_spec) _ty) args result_ty) = if isSupportedCConv ccall_spec - then generateCCall d s p ccall_spec result_ty (reverse args) + then generateCCall d s p ccall_spec result_ty args else unsupportedCConvException schemeT d s p (StgOpApp (StgPrimOp op) args _ty) = doTailCall d s p (primOpId op) (reverse args) -schemeT _d _s _p (StgOpApp StgPrimCallOp{} _args _ty) - = unsupportedCConvException +schemeT d s p (StgOpApp (StgPrimCallOp (PrimCall label unit)) args result_ty) + = generatePrimCall d s p label (Just unit) result_ty args -- Case 2: Unboxed tuple schemeT d s p (StgConApp con _cn args _tys) @@ -840,18 +844,18 @@ doCase d s p scrut bndr alts | ubx_frame = wordSize platform | otherwise = 0 - (bndr_size, tuple_info, args_offsets) + (bndr_size, call_info, args_offsets) | ubx_tuple_frame = let bndr_ty = primRepCmmType platform bndr_reps = filter (not.isVoidRep) (bcIdPrimReps bndr) - (tuple_info, args_offsets) = - layoutTuple profile 0 bndr_ty bndr_reps - in ( wordsToBytes platform (tupleSize tuple_info) - , tuple_info + (call_info, args_offsets) = + layoutNativeCall profile NativeTupleReturn 0 bndr_ty bndr_reps + in ( wordsToBytes platform (nativeCallSize call_info) + , call_info , args_offsets ) | otherwise = ( wordsToBytes platform (idSizeW platform bndr) - , voidTupleInfo + , voidTupleReturnInfo , [] ) @@ -885,17 +889,18 @@ doCase d s p scrut bndr alts | isUnboxedTupleType bndr_ty || isUnboxedSumType bndr_ty = let bndr_ty = primRepCmmType platform . bcIdPrimRep tuple_start = d_bndr - (tuple_info, args_offsets) = - layoutTuple profile - 0 - bndr_ty - bndrs + (call_info, args_offsets) = + layoutNativeCall profile + NativeTupleReturn + 0 + bndr_ty + bndrs stack_bot = d_alts p' = Map.insertList [ (arg, tuple_start - - wordsToBytes platform (tupleSize tuple_info) + + wordsToBytes platform (nativeCallSize call_info) + offset) | (arg, offset) <- args_offsets , not (isVoidRep $ bcIdPrimRep arg)] @@ -981,8 +986,8 @@ doCase d s p scrut bndr alts -- unboxed tuples get two more words, the second is a pointer (tuple_bco) (extra_pointers, extra_slots) - | ubx_tuple_frame && profiling = ([1], 3) -- tuple_info, tuple_BCO, CCCS - | ubx_tuple_frame = ([1], 2) -- tuple_info, tuple_BCO + | ubx_tuple_frame && profiling = ([1], 3) -- call_info, tuple_BCO, CCCS + | ubx_tuple_frame = ([1], 2) -- call_info, tuple_BCO | otherwise = ([], 0) bitmap_size = trunc16W $ fromIntegral extra_slots + @@ -1028,8 +1033,8 @@ doCase d s p scrut bndr alts let args_ptrs = map (\(rep, off) -> (isFollowableArg (toArgRep platform rep), off)) args_offsets - tuple_bco <- emitBc (tupleBCO platform tuple_info args_ptrs) - return (PUSH_ALTS_TUPLE alt_bco' tuple_info tuple_bco + tuple_bco <- emitBc (tupleBCO platform call_info args_ptrs) + return (PUSH_ALTS_TUPLE alt_bco' call_info tuple_bco `consOL` scrut_code) else let push_alts | not ubx_frame @@ -1050,14 +1055,15 @@ doCase d s p scrut bndr alts -- The native calling convention uses registers for tuples, but in the -- bytecode interpreter, all values live on the stack. -layoutTuple :: Profile - -> ByteOff - -> (a -> CmmType) - -> [a] - -> ( TupleInfo -- See Note [GHCi TupleInfo] - , [(a, ByteOff)] -- argument, offset on stack - ) -layoutTuple profile start_off arg_ty reps = +layoutNativeCall :: Profile + -> NativeCallType + -> ByteOff + -> (a -> CmmType) + -> [a] + -> ( NativeCallInfo -- See Note [GHCi TupleInfo] + , [(a, ByteOff)] -- argument, offset on stack + ) +layoutNativeCall profile call_type start_off arg_ty reps = let platform = profilePlatform profile (orig_stk_bytes, pos) = assignArgumentsPos profile 0 @@ -1070,7 +1076,7 @@ layoutTuple profile start_off arg_ty reps = -- sort the register parameters by register and add them to the stack regs_order :: Map.Map GlobalReg Int - regs_order = Map.fromList $ zip (tupleRegsCover platform) [0..] + regs_order = Map.fromList $ zip (allArgRegsCover platform) [0..] reg_order :: GlobalReg -> (Int, GlobalReg) reg_order reg | Just n <- Map.lookup reg regs_order = (n, reg) @@ -1099,10 +1105,11 @@ layoutTuple profile start_off arg_ty reps = get_byte_off _ = panic "GHC.StgToByteCode.layoutTuple get_byte_off" - in ( TupleInfo - { tupleSize = bytesToWords platform (ByteOff new_stk_bytes) - , tupleRegs = regs_set - , tupleNativeStackSize = bytesToWords platform + in ( NativeCallInfo + { nativeCallType = call_type + , nativeCallSize = bytesToWords platform (ByteOff new_stk_bytes) + , nativeCallRegs = regs_set + , nativeCallStackSpillSize = bytesToWords platform (ByteOff orig_stk_bytes) } , sortBy (comparing snd) $ @@ -1127,7 +1134,7 @@ usePlainReturn t ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We have the bytecode instructions RETURN_TUPLE and PUSH_ALTS_TUPLE to return and receive arbitrary unboxed tuples, respectively. These - instructions use the helper data tuple_BCO and tuple_info. + instructions use the helper data tuple_BCO and call_info. The helper data is used to convert tuples between GHCs native calling convention (object code), which uses stack and registers, and the bytecode @@ -1139,7 +1146,7 @@ usePlainReturn t ================= Bytecode that returns a tuple first pushes all the tuple fields followed - by the appropriate tuple_info and tuple_BCO onto the stack. It then + by the appropriate call_info and tuple_BCO onto the stack. It then executes the RETURN_TUPLE instruction, which causes the interpreter to push stg_ret_t_info to the top of the stack. The stack (growing down) then looks as follows: @@ -1150,14 +1157,14 @@ usePlainReturn t tuple_field_2 ... tuple_field_n - tuple_info + call_info tuple_BCO stg_ret_t_info <- Sp If next_frame is bytecode, the interpreter will start executing it. If it's object code, the interpreter jumps back to the scheduler, which in turn jumps to stg_ret_t. stg_ret_t converts the tuple to the native - calling convention using the description in tuple_info, and then jumps + calling convention using the description in call_info, and then jumps to next_frame. @@ -1169,13 +1176,13 @@ usePlainReturn t tuple. The PUSH_ALTS_TUPLE instuction contains three pieces of data: * cont_BCO: the continuation that receives the tuple - * tuple_info: see below + * call_info: see below * tuple_BCO: see below The interpreter pushes these onto the stack when the PUSH_ALTS_TUPLE instruction is executed, followed by stg_ctoi_tN_info, with N depending on the number of stack words used by the tuple in the GHC native calling - convention. N is derived from tuple_info. + convention. N is derived from call_info. For example if we expect a tuple with three words on the stack, the stack looks as follows after PUSH_ALTS_TUPLE: @@ -1186,7 +1193,7 @@ usePlainReturn t cont_free_var_2 ... cont_free_var_n - tuple_info + call_info tuple_BCO cont_BCO stg_ctoi_t3_info <- Sp @@ -1206,20 +1213,20 @@ usePlainReturn t that is already on the stack. - The tuple_info word + The call_info word =================== - The tuple_info word describes the stack and STG register (e.g. R1..R6, - D1..D6) usage for the tuple. tuple_info contains enough information to + The call_info word describes the stack and STG register (e.g. R1..R6, + D1..D6) usage for the tuple. call_info contains enough information to convert the tuple between the stack-only bytecode and stack+registers GHC native calling conventions. - See Note [GHCi tuple layout] for more details of how the data is packed - in a single word. + See Note [GHCi and native call registers] for more details of how the + data is packed in a single word. -} -tupleBCO :: Platform -> TupleInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name +tupleBCO :: Platform -> NativeCallInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name tupleBCO platform info pointers = mkProtoBCO platform invented_name body_code (Left []) 0{-no arity-} bitmap_size bitmap False{-is alts-} @@ -1233,15 +1240,103 @@ tupleBCO platform info pointers = -} invented_name = mkSystemVarName (mkPseudoUniqueE 0) (fsLit "tuple") - -- the first word in the frame is the tuple_info word, + -- the first word in the frame is the call_info word, -- which is not a pointer - bitmap_size = trunc16W $ 1 + tupleSize info + bitmap_size = trunc16W $ 1 + nativeCallSize info bitmap = intsToReverseBitmap platform (fromIntegral bitmap_size) $ map ((+1) . fromIntegral . bytesToWords platform . snd) (filter fst pointers) body_code = mkSlideW 0 1 -- pop frame header `snocOL` RETURN_TUPLE -- and add it again +primCallBCO :: Platform -> NativeCallInfo -> [(Bool, ByteOff)] -> [FFIInfo] -> ProtoBCO Name +primCallBCO platform args_info pointers = + mkProtoBCO platform invented_name body_code (Left []) + 0{-no arity-} bitmap_size bitmap False{-is alts-} + + where + {- + The primcall BCO is never referred to by name, so we can get away + with using a fake name here. We will need to change this if we want + to save some memory by sharing the BCO between places that have + the same tuple shape + -} + invented_name = mkSystemVarName (mkPseudoUniqueE 0) (fsLit "primcall") + + -- the first three words in the frame are the BCO describing the + -- pointers in the frame, the call_info word and the pointer + -- to the Cmm function being called. None of these is a pointer that + -- should be followed by the garbage collector + bitmap_size = trunc16W $ 2 + nativeCallSize args_info + bitmap = intsToReverseBitmap platform (fromIntegral bitmap_size) $ + map ((+2) . fromIntegral . bytesToWords platform . snd) + (filter fst pointers) + -- if the primcall BCO is ever run it's a bug, since the BCO should only + -- be pushed immediately before running the PRIMCALL bytecode instruction, + -- which immediately leaves the interpreter to jump to the stg_primcall_info + -- Cmm function + body_code = unitOL CASEFAIL + +-- ----------------------------------------------------------------------------- +-- Deal with a primitive call to native code. + +generatePrimCall + :: StackDepth + -> Sequel + -> BCEnv + -> CLabelString -- where to call + -> Maybe Unit + -> Type + -> [StgArg] -- args (atoms) + -> BcM BCInstrList +generatePrimCall d s p target _mb_unit _result_ty args + = do + profile <- getProfile + let + platform = profilePlatform profile + + non_void VoidRep = False + non_void _ = True + + nv_args :: [StgArg] + nv_args = filter (non_void . argPrimRep) args + + (args_info, args_offsets) = + layoutNativeCall profile + NativePrimCall + d + (primRepCmmType platform . argPrimRep) + nv_args + + args_ptrs :: [(Bool, ByteOff)] + args_ptrs = + map (\(r, off) -> + (isFollowableArg (toArgRep platform . argPrimRep $ r), off)) + args_offsets + + push_target = PUSH_UBX (LitLabel target Nothing IsFunction) 1 + push_info = PUSH_UBX (mkNativeCallInfoLit platform args_info) 1 + {- + compute size to move payload (without stg_primcall_info header) + + size of arguments plus three words for: + - function pointer to the target + - call_info word + - BCO to describe the stack frame + -} + szb = wordsToBytes platform (nativeCallSize args_info + 3) + go _ pushes [] = return (reverse pushes) + go !dd pushes ((a, off):cs) = do (push, szb) <- pushAtom dd p a + massert (off == dd + szb) + go (dd + szb) (push:pushes) cs + push_args <- go d [] args_offsets + args_bco <- emitBc (primCallBCO platform args_info args_ptrs) + return $ mconcat push_args `appOL` + (push_target `consOL` + push_info `consOL` + PUSH_BCO args_bco `consOL` + (mkSlideB platform szb (d - s) `appOL` unitOL PRIMCALL)) + -- ----------------------------------------------------------------------------- -- Deal with a CCall. @@ -1259,11 +1354,17 @@ generateCCall -> Type -> [StgArg] -- args (atoms) -> BcM BCInstrList -generateCCall d0 s p (CCallSpec target cconv safety) result_ty args_r_to_l +generateCCall d0 s p (CCallSpec target PrimCallConv _) result_ty args + | (StaticTarget _ label mb_unit _) <- target + = generatePrimCall d0 s p label mb_unit result_ty args + | otherwise + = panic "GHC.StgToByteCode.generateCCall: primcall convention only supports static targets" +generateCCall d0 s p (CCallSpec target cconv safety) result_ty args = do profile <- getProfile let + args_r_to_l = reverse args platform = profilePlatform profile -- useful constants addr_size_b :: ByteOff @@ -2007,7 +2108,7 @@ isSupportedCConv :: CCallSpec -> Bool isSupportedCConv (CCallSpec _ cconv _) = case cconv of CCallConv -> True -- we explicitly pattern match on every StdCallConv -> True -- convention to ensure that a warning - PrimCallConv -> False -- is triggered when a new one is added + PrimCallConv -> True -- is triggered when a new one is added JavaScriptCallConv -> False CApiConv -> True ===================================== compiler/GHC/StgToCmm/Foreign.hs ===================================== @@ -15,8 +15,8 @@ module GHC.StgToCmm.Foreign ( emitLoadThreadState, emitSaveRegs, emitRestoreRegs, - emitPushTupleRegs, - emitPopTupleRegs, + emitPushArgRegs, + emitPopArgRegs, loadThreadState, emitOpenNursery, emitCloseNursery, @@ -349,7 +349,7 @@ emitRestoreRegs = do -- bytecode interpreter. -- -- The "live registers" bitmap corresponds to the list of registers given by --- 'tupleRegsCover', with the least significant bit indicating liveness of +-- 'allArgRegsCover', with the least significant bit indicating liveness of -- the first register in the list. -- -- Each register is saved to a stack slot of one or more machine words, even @@ -362,12 +362,12 @@ emitRestoreRegs = do -- if((mask & 2) != 0) { Sp_adj(-1); Sp(0) = R2; } -- if((mask & 1) != 0) { Sp_adj(-1); Sp(0) = R1; } -- --- See Note [GHCi tuple layout] +-- See Note [GHCi and native call registers] -emitPushTupleRegs :: CmmExpr -> FCode () -emitPushTupleRegs regs_live = do +emitPushArgRegs :: CmmExpr -> FCode () +emitPushArgRegs regs_live = do platform <- getPlatform - let regs = zip (tupleRegsCover platform) [0..] + let regs = zip (allArgRegsCover platform) [0..] save_arg (reg, n) = let mask = CmmLit (CmmInt (1 `shiftL` n) (wordWidth platform)) live = cmmAndWord platform regs_live mask @@ -381,11 +381,11 @@ emitPushTupleRegs regs_live = do in mkCmmIfThen cond $ catAGraphs [adj_sp, save_reg] emit . catAGraphs =<< mapM save_arg (reverse regs) --- | Pop a subset of STG registers from the stack (see 'emitPushTupleRegs') -emitPopTupleRegs :: CmmExpr -> FCode () -emitPopTupleRegs regs_live = do +-- | Pop a subset of STG registers from the stack (see 'emitPushArgRegs') +emitPopArgRegs :: CmmExpr -> FCode () +emitPopArgRegs regs_live = do platform <- getPlatform - let regs = zip (tupleRegsCover platform) [0..] + let regs = zip (allArgRegsCover platform) [0..] save_arg (reg, n) = let mask = CmmLit (CmmInt (1 `shiftL` n) (wordWidth platform)) live = cmmAndWord platform regs_live mask ===================================== rts/Disassembler.c ===================================== @@ -83,6 +83,9 @@ disInstr ( StgBCO *bco, int pc ) debugBelch("CCALL marshaller at 0x%" FMT_HexWord "\n", literals[instrs[pc]] ); pc += 1; break; + case bci_PRIMCALL: + debugBelch("PRIMCALL\n"); + break; case bci_STKCHECK: { StgWord stk_words_reqd = BCO_GET_LARGE_ARG + 1; debugBelch("STKCHECK %" FMT_Word "\n", (W_)stk_words_reqd ); ===================================== rts/Interpreter.c ===================================== @@ -2038,6 +2038,12 @@ run_BCO: goto nextInsn; } + case bci_PRIMCALL: { + Sp_subW(1); + SpW(0) = (W_)&stg_primcall_info; + RETURN_TO_SCHEDULER_NO_PAUSE(ThreadRunGHC, ThreadYielding); + } + case bci_CCALL: { void *tok; int stk_offset = BCO_NEXT; ===================================== rts/RtsSymbols.c ===================================== @@ -602,6 +602,7 @@ extern char **environ; SymI_HasDataProto(stg_ret_l_info) \ SymI_HasDataProto(stg_ret_t_info) \ SymI_HasDataProto(stg_ctoi_t) \ + SymI_HasDataProto(stg_primcall_info) \ SymI_HasDataProto(stg_gc_prim_p) \ SymI_HasDataProto(stg_gc_prim_pp) \ SymI_HasDataProto(stg_gc_prim_n) \ ===================================== rts/StgMiscClosures.cmm ===================================== @@ -366,20 +366,10 @@ MK_STG_CTOI_T(61) MK_STG_CTOI_T(62) /* - Note [GHCi tuple layout] - ~~~~~~~~~~~~~~~~~~~~~~~~ - the tuple_info word describes the register and stack usage of the tuple: + Convert a tuple return value to be used in bytecode. - [ ssss ssss rrrr rrrr rrrr rrrr rrrr rrrr ] - - - r: bitmap of live registers, corresponding to the list of registers - returned by GHC.Cmm.CallConv.tupleRegsCover (the least significant - bit corresponds to the first element in the list) - - s: number of words on stack (in addition to registers) - - The order of the live registers in the bitmap is the same as the list - given by GHC.Cmm.CallConv.tupleRegsCover, with the least significant - bit corresponding to the first register in the list. + See Note [GHCi and native call registers] for information on how + values are moved between the stack and registers. */ stg_ctoi_t @@ -402,7 +392,7 @@ stg_ctoi_t Sp = Sp - WDS(tuple_stack); - PUSH_TUPLE_REGS(tuple_info); + PUSH_ARG_REGS(tuple_info); /* jump to the BCO that will finish the return of the tuple */ Sp_adj(-3); @@ -423,13 +413,57 @@ INFO_TABLE_RET( stg_ret_t, RET_BCO ) /* number of words spilled on stack */ tuple_stack = (tuple_info >> 24) & 0xff; - POP_TUPLE_REGS(tuple_info); + POP_ARG_REGS(tuple_info); /* Sp points to the topmost argument now */ jump %ENTRY_CODE(Sp(tuple_stack)) [*]; // NB. all registers live! } + /* + + The stg_primcall frame is used by the bytecode interpreter to call + a Cmm function. The frame contains a call_info word that contains + a bitmap describing the register arguments. + + When the target function is called, Sp points to the topmost stack + argument. + + ... + next_stack_frame + arg_1 + arg_2 + ... + arg_n + target_funptr (pointer to the function we're calling) + call_info (describes the registers containing the arguments) + primcall_BCO (contains bitmap describing pointers in args) + stg_primcall_info <- Sp + + See Note [GHCi and native call registers] for information on the call_info + word and how registers are moved between the stack and registers. + + */ + +INFO_TABLE_RET ( stg_primcall, RET_BCO ) +{ + W_ args_info, prim_fun; + + /* Sp(1) would be the BCO containing the stack description bitmap */ + args_info = Sp(2); + prim_fun = Sp(3); + + Sp_adj(4); + + /* Sp points to the top of the register arguments now, + load them into actual registers */ + POP_ARG_REGS(args_info); + + /* Sp points to the topmost stack argument now */ + + jump prim_fun [*]; // NB. all registers live! +} + /* * Dummy info table pushed on the top of the stack when the interpreter * should apply the BCO on the stack to its arguments, also on the ===================================== rts/include/rts/Bytecodes.h ===================================== @@ -112,6 +112,8 @@ #define bci_TESTLT_W8 85 #define bci_TESTEQ_W8 86 +#define bci_PRIMCALL 87 + /* If you need to go past 255 then you will run into the flags */ /* If you need to go below 0x0100 then you will run into the instructions */ ===================================== rts/include/stg/MiscClosures.h ===================================== @@ -160,6 +160,7 @@ RTS_RET(stg_ctoi_t60); RTS_RET(stg_ctoi_t61); RTS_RET(stg_ctoi_t62); +RTS_RET(stg_primcall); RTS_RET(stg_apply_interp); RTS_RET(stg_dead_thread); ===================================== testsuite/tests/ghci/prog014/prog014.T ===================================== @@ -1,6 +1,5 @@ test('prog014', [extra_files(['Primop.hs', 'dummy.c']), - expect_fail, # bytecode compiler doesn't support foreign import prim extra_run_opts('dummy.o'), pre_cmd('$MAKE -s --no-print-directory prog014')], ghci_script, ['prog014.script']) ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs ===================================== @@ -0,0 +1,279 @@ +{-# LANGUAGE ForeignFunctionInterface, GHCForeignImportPrim, UnliftedFFITypes, MagicHash, UnboxedTuples #-} + +module Main where + +import GHC.Int +import GHC.Word +import GHC.Prim +import GHC.Exts +import GHC.Types +import Unsafe.Coerce +import GHC.IO + +data Box (a :: UnliftedType) = MkBox a + +i2a :: Int -> Any +i2a = unsafeCoerce + +a2i :: Any -> Int +a2i = unsafeCoerce + +main :: IO () +main = do + + let i8s :: [Int8] + i8s = [0, -1, 1, minBound, maxBound] + + i16s :: [Int16] + i16s = [0, -1, 1, minBound, maxBound] + + i32s :: [Int32] + i32s = [0, -1, 1, minBound, maxBound] + + i64s :: [Int64] + i64s = [0, -1, 1, minBound, maxBound] + + ws :: [Word] + ws = [0, 1, 2, maxBound] + + fs :: [Float] + fs = [-0, 0, -1, 1, -2, 2, 1/0, 1e37, -1e-37] + + ds :: [Double] + ds = [-0, 0, -1, 1, -2, 2, 1/0, 1e307, -1e-307] + + ls :: [Word64] + ls = [0, 1, 2, 4294967296, maxBound] + + mi2a :: Maybe Integer -> Any + mi2a = unsafeCoerce + + a2mi :: Any -> Maybe Integer + a2mi = unsafeCoerce + + a0, a1, a2, a3 :: Any + a0 = mi2a Nothing + a1 = mi2a (Just 1) + a2 = mi2a (Just 18446744073709551617) + a3 = mi2a (Just (-18446744073709551617)) + + as :: [Any] + as = [a0, a1, a2, a3] + + + putStrLn "zero arguments" + IO (\st -> case cmm_zero st of (# st' #) -> (# st', () #)) + print =<< IO (\st -> case cmm_zero_w st of (# st', w #) -> (# st', W# w #)) + print =<< IO (\st -> case cmm_zero_d st of (# st', w #) -> (# st', D# w #)) + print =<< IO (\st -> case cmm_zero_f st of (# st', w #) -> (# st', F# w #)) + + -- XXX zero argument functions + + putStrLn "one argument functions" + print [ I8# (cmm_one1_i8 x) | (I8# x) <- i8s ] + print [ I16# (cmm_one1_i16 x) | (I16# x) <- i16s ] + print [ I32# (cmm_one1_i32 x) | (I32# x) <- i32s ] + print [ I64# (cmm_one1_i64 x) | (I64# x) <- i64s ] + print [ case cmm_one1_p x of (# y #) -> a2mi y | x <- as ] + print [ W# (cmm_one1_w x) | (W# x) <- ws ] + print [ F# (cmm_one1_f x) | (F# x) <- fs ] + print [ D# (cmm_one1_d x) | (D# x) <- ds ] + print [ W64# (cmm_one1_l x) | (W64# x) <- ls ] + + print [ case cmm_one2_i8 x of (# y1, y2 #) -> (I8# y1, I8# y2) | (I8# x) <- i8s ] + print [ case cmm_one2_i16 x of (# y1, y2 #) -> (I16# y1, I16# y2) | (I16# x) <- i16s ] + print [ case cmm_one2_i32 x of (# y1, y2 #) -> (I32# y1, I32# y2) | (I32# x) <- i32s ] + print [ case cmm_one2_i64 x of (# y1, y2 #) -> (I64# y1, I64# y2) | (I64# x) <- i64s ] + print [ case cmm_one2_p x of (# y1, y2 #) -> (a2mi y1, a2mi y2) | x <- as ] + print [ case cmm_one2_w x of (# y1, y2 #) -> (W# y1, W# y2) | (W# x) <- ws ] + print [ case cmm_one2_f x of (# y1, y2 #) -> (F# y1, F# y2) | (F# x) <- fs ] + print [ case cmm_one2_d x of (# y1, y2 #) -> (D# y1, D# y2) | (D# x) <- ds ] + print [ case cmm_one2_l x of (# y1, y2 #) -> (W64# y1, W64# y2) | (W64# x) <- ls ] + + putStrLn "two argument functions" + print [ I8# (cmm_two1_i8 x1 x2) | (I8# x1) <- i8s, (I8# x2) <- i8s ] + print [ I16# (cmm_two1_i16 x1 x2) | (I16# x1) <- i16s, (I16# x2) <- i16s ] + print [ I32# (cmm_two1_i32 x1 x2) | (I32# x1) <- i32s, (I32# x2) <- i32s ] + print [ I64# (cmm_two1_i64 x1 x2) | (I64# x1) <- i64s, (I64# x2) <- i64s ] + print [ case cmm_two1_p x1 x2 of (# y #) -> a2mi y | x1 <- as, x2 <- as ] + print [ W# (cmm_two1_w x1 x2) | (W# x1) <- ws, (W# x2) <- ws ] + print [ F# (cmm_two1_f x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_two1_d x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ W64# (cmm_two1_l x1 x2) | (W64# x1) <- ls, (W64# x2) <- ls ] + + print [ I8# (cmm_two2_i8 x1 x2) | (I8# x1) <- i8s, (I8# x2) <- i8s ] + print [ I16# (cmm_two2_i16 x1 x2) | (I16# x1) <- i16s, (I16# x2) <- i16s ] + print [ I32# (cmm_two2_i32 x1 x2) | (I32# x1) <- i32s, (I32# x2) <- i32s ] + print [ I64# (cmm_two2_i64 x1 x2) | (I64# x1) <- i64s, (I64# x2) <- i64s ] + print [ case cmm_two2_p x1 x2 of (# y #) -> a2mi y | x1 <- as, x2 <- as ] + print [ W# (cmm_two2_w x1 x2) | (W# x1) <- ws, (W# x2) <- ws ] + print [ F# (cmm_two2_f x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_two2_d x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ W64# (cmm_two2_l x1 x2) | (W64# x1) <- ls, (W64# x2) <- ls ] + + putStrLn "additional floating point tests" + print [ F# (cmm_floating_1 x1 x2) | (F# x1) <- fs, (F# x2) <- fs ] + print [ D# (cmm_floating_2 x1 x2) | (D# x1) <- ds, (D# x2) <- ds ] + print [ F# (cmm_floating_3 x1 x2) | (F# x1) <- fs, (D# x2) <- ds ] + print [ D# (cmm_floating_4 x1 x2) | (F# x1) <- fs, (D# x2) <- ds ] + print [ case cmm_floating_5 x1 x2 3.0e1# 4.0e2## 5.0e3# 6.0e4## 7.0e5# 8.0e6## of (# y1, y2 #) -> (F# y1, D# y2) + | (F# x1) <- fs, (D# x2) <- ds ] + print [ case cmm_floating_6 x1 x2 3.0e1## 4.0e2# 5.0e3## 6.0e4# 7.0e5## 8.0e6# of (# y1, y2 #) -> (D# y1, F# y2) + | (D# x1) <- ds, (F# x2) <- fs ] + print [ case cmm_floating_7 w1 x1 x2 + 4## 5.0e1# 6.0e2## + 7## 8.0e3# 9.0e4## + 10## 11.0e5# 12.0e6## + 13## 14.0e7# 15.0e8## + 16## 17.0e9# 18.0e10## + 19## 20.0e11# 21.0e12## of (# y1, y2, y3 #) -> (W# y1, F# y2, D# y3) + | (W# w1) <- ws, (F# x1) <- fs, (D# x2) <- ds ] + + putStrLn "various sized tuple returns" + print [ case cmm_tuple_1 x1 x2 3## of (# y1, y2, y3 #) -> (W# y1, W# y2, W# y3) | (W# x1) <- ws, (W# x2) <- ws] + print [ case cmm_tuple_2 x1 x2 3## 4## a0 a1 7.0## 8.0## a2 a3 11.0# 12.0# + of (# y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12 #) -> + (F# y1, F# y2, a2mi y3, a2mi y4, D# y5, D# y6, a2mi y7, a2mi y8, W# y9, W# y10, a2mi y11, a2mi y12) + | x1 <- as, x2 <- as ] + print [ case cmm_tuple_3 x1 x2 a0 3.0## a1 5.0# + of (# y1, y2, y3, y4, y5, y6 #) -> (F# y1, a2mi y2, D# y3, a2mi y4, W# y5, a2mi y6) + | x1 <- as, (W# x2) <- ws ] + print [ case cmm_tuple_4 x1 x2 of (# y1, y2 #) -> (a2mi y1, a2mi y2) | x1 <- as, x2 <- as ] + + putStrLn "arrays" + MkBox marr0 <- IO (\s -> case newArray# 10# a0 s of (# s', a #) -> (# s', MkBox a #)) + MkBox marr1 <- IO (\s -> case newArray# 12# a1 s of (# s', a #) -> (# s', MkBox a #)) + MkBox arr0 <- IO (\s -> case unsafeFreezeArray# marr0 s of (# s', a #) -> (# s', MkBox a #)) + MkBox arr1 <- IO (\s -> case unsafeFreezeArray# marr1 s of (# s', a #) -> (# s', MkBox a #)) + print (I# (cmm_array_1 arr0), I# (cmm_array_1 arr1)) + case cmm_array_2 arr0 arr1 of (# arr2, arr3 #) -> print (I# (cmm_array_1 arr2), I# (cmm_array_1 arr3)) + + putStrLn "many arguments" + print (W# (cmm_many_arguments 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## 65## 66## 67## 68## 69## 70## 71## 72## 73## 74## 75## 76## 77## 78## 79## 80## 81## 82## 83## 84## 85## 86## 87## 88## 89## 90## 91## 92## 93## 94## 95## 96## 97## 98## 99## 100## 101## 102## 103## 104## 105## 106## 107## 108## 109## 110## 111## 112## 113## 114## 115## 116## 117## 118## 119## 120## 121## 122## 123## 124## 125## 126## 127## 128## 129## 130## 131## 132## 133## 134## 135## 136## 137## 138## 139## 140## 141## 142## 143## 144## 145## 146## 147## 148## 149## 150## 151## 152## 153## 154## 155## 156## 157## 158## 159## 160## 161## 162## 163## 164## 165## 166## 167## 168## 169## 170## 171## 172## 173## 174## 175## 176## 177## 178## 179## 180## 181## 182## 183## 184## 185## 186## 187## 188## 189## 190## 191## 192## 193## 194## 195## 196## 197## 198## 199## 200## 201## 202## 203## 204## 205## 206## 207## 208## 209## 210## 211## 212## 213## 214## 215## 216## 217## 218## 219## 220## 221## 222## 223## 224## 225## 226## 227## 228## 229## 230## 231## 232## 233## 234## 235## 236## 237## 238## 239## 240## 241## 242## 243## 244## 245## 246## 247## 248## 249## 250## 251## 252## 253## 254## 255## 256## 257## 258## 259## 260## 261## 262## 263## 264## 265## 266## 267## 268## 269## 270## 271## 272## 273## 274## 275## 276## 277## 278## 279## 280## 281## 282## 283## 284## 285## 286## 287## 288## 289## 290## 291## 292## 293## 294## 295## 296## 297## 298## 299## 300## 301## 302## 303## 304## 305## 306## 307## 308## 309## 310## 311## 312## 313## 314## 315## 316## 317## 318## 319## 320## 321## 322## 323## 324## 325## 326## 327## 328## 329## 330## 331## 332## 333## 334## 335## 336## 337## 338## 339## 340## 341## 342## 343## 344## 345## 346## 347## 348## 349## 350## 351## 352## 353## 354## 355## 356## 357## 358## 359## 360## 361## 362## 363## 364## 365## 366## 367## 368## 369## 370## 371## 372## 373## 374## 375## 376## 377## 378## 379## 380## 381## 382## 383## 384## 385## 386## 387## 388## 389## 390## 391## 392## 393## 394## 395## 396## 397## 398## 399## 400##)) + +-- XXX why don't we accept State# RealWorld -> State# RealWorld ? +foreign import prim cmm_zero :: State# RealWorld -> (# State# RealWorld #) +foreign import prim cmm_zero_w :: State# RealWorld -> (# State# RealWorld, Word# #) +foreign import prim cmm_zero_d :: State# RealWorld -> (# State# RealWorld, Double# #) +foreign import prim cmm_zero_f :: State# RealWorld -> (# State# RealWorld, Float# #) + +-- one argument functions +foreign import prim cmm_one1_i8 :: Int8# -> Int8# +foreign import prim cmm_one1_i16 :: Int16# -> Int16# +foreign import prim cmm_one1_i32 :: Int32# -> Int32# +foreign import prim cmm_one1_i64 :: Int64# -> Int64# +foreign import prim cmm_one1_p :: Any -> (# Any #) +foreign import prim cmm_one1_w :: Word# -> Word# +foreign import prim cmm_one1_f :: Float# -> Float# +foreign import prim cmm_one1_d :: Double# -> Double# +foreign import prim cmm_one1_l :: Word64# -> Word64# + +foreign import prim cmm_one2_i8 :: Int8# -> (# Int8#, Int8# #) +foreign import prim cmm_one2_i16 :: Int16# -> (# Int16#, Int16# #) +foreign import prim cmm_one2_i32 :: Int32# -> (# Int32#, Int32# #) +foreign import prim cmm_one2_i64 :: Int64# -> (# Int64#, Int64# #) +foreign import prim cmm_one2_p :: Any -> (# Any, Any #) +foreign import prim cmm_one2_w :: Word# -> (# Word#, Word# #) +foreign import prim cmm_one2_f :: Float# -> (# Float#, Float# #) +foreign import prim cmm_one2_d :: Double# -> (# Double#, Double# #) +foreign import prim cmm_one2_l :: Word64# -> (# Word64#, Word64# #) + +-- two argument functions +foreign import prim cmm_two1_i8 :: Int8# -> Int8# -> Int8# +foreign import prim cmm_two1_i16 :: Int16# -> Int16# -> Int16# +foreign import prim cmm_two1_i32 :: Int32# -> Int32# -> Int32# +foreign import prim cmm_two1_i64 :: Int64# -> Int64# -> Int64# +foreign import prim cmm_two1_p :: Any -> Any -> (# Any #) +foreign import prim cmm_two1_w :: Word# -> Word# -> Word# +foreign import prim cmm_two1_f :: Float# -> Float# -> Float# +foreign import prim cmm_two1_d :: Double# -> Double# -> Double# +foreign import prim cmm_two1_l :: Word64# -> Word64# -> Word64# + +foreign import prim cmm_two2_i8 :: Int8# -> Int8# -> Int8# +foreign import prim cmm_two2_i16 :: Int16# -> Int16# -> Int16# +foreign import prim cmm_two2_i32 :: Int32# -> Int32# -> Int32# +foreign import prim cmm_two2_i64 :: Int64# -> Int64# -> Int64# +foreign import prim cmm_two2_p :: Any -> Any -> (# Any #) +foreign import prim cmm_two2_w :: Word# -> Word# -> Word# +foreign import prim cmm_two2_f :: Float# -> Float# -> Float# +foreign import prim cmm_two2_d :: Double# -> Double# -> Double# +foreign import prim cmm_two2_l :: Word64# -> Word64# -> Word64# + +{- additional tests for floating point, since D_ and F_ registers + overlap on some platforms -} + +foreign import prim cmm_floating_1 :: Float# -> Float# -> Float# +foreign import prim cmm_floating_2 :: Double# -> Double# -> Double# +foreign import prim cmm_floating_3 :: Float# -> Double# -> Float# +foreign import prim cmm_floating_4 :: Float# -> Double# -> Double# +foreign import prim cmm_floating_5 :: Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> (# Float#, Double# #) +foreign import prim cmm_floating_6 :: Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> Double# -> Float# -> (# Double#, Float# #) +foreign import prim cmm_floating_7 :: Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> Word# -> Float# -> Double# -> (# Word#, Float#, Double# #) +-- various sized tuple returns + +foreign import prim cmm_tuple_1 :: Word# -> Word# -> Word# -> (# Word# , Word#, Word# #) +foreign import prim cmm_tuple_2 :: Any -> Any -> Word# -> Word# -> Any -> Any -> Double# -> Double# -> Any -> Any -> Float# -> Float# -> + (# Float#, Float#, Any, Any, Double#, Double#, Any, Any, Word#, Word#, Any, Any #) +foreign import prim cmm_tuple_3 :: Any -> Word# -> Any -> Double# -> Any -> Float# -> + (# Float#, Any, Double#, Any, Word#, Any #) +foreign import prim cmm_tuple_4 :: Any -> Any -> (# Any, Any #) + +-- boxed primitive types + +-- get the length of an array +foreign import prim cmm_array_1 :: Array# Any -> Int# +-- return some arrays +foreign import prim cmm_array_2 :: Array# Any -> Array# Any -> (# Array# Any, Array# Any #) + +foreign import prim cmm_many_arguments :: + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> Word# -> + Word# ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout ===================================== @@ -0,0 +1,60 @@ +zero arguments +123 +1.0 +1.0 +one argument functions +[0,-1,1,-128,127] +[0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,18446744073709551615] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615] +[(0,0),(-1,-1),(1,1),(-128,-128),(127,127)] +[(0,0),(-1,-1),(1,1),(-32768,-32768),(32767,32767)] +[(0,0),(-1,-1),(1,1),(-2147483648,-2147483648),(2147483647,2147483647)] +[(0,0),(-1,-1),(1,1),(-9223372036854775808,-9223372036854775808),(9223372036854775807,9223372036854775807)] +[(Nothing,Nothing),(Just 1,Just 1),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just (-18446744073709551617))] +[(0,0),(1,1),(2,2),(18446744073709551615,18446744073709551615)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e37,1.0e37),(-1.0e-37,-1.0e-37)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e307,1.0e307),(-1.0e-307,-1.0e-307)] +[(0,0),(1,1),(2,2),(4294967296,4294967296),(18446744073709551615,18446744073709551615)] +two argument functions +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-128,-128,-128,-128,-128,127,127,127,127,127] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-32768,-32768,-32768,-32768,-32768,32767,32767,32767,32767,32767] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,2147483647,2147483647,2147483647,2147483647,2147483647] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807] +[Nothing,Nothing,Nothing,Nothing,Just 1,Just 1,Just 1,Just 1,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617)] +[0,0,0,0,1,1,1,1,2,2,2,2,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307] +[0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,4294967296,4294967296,4294967296,4294967296,4294967296,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127] +[0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,18446744073709551615,0,1,2,18446744073709551615,0,1,2,18446744073709551615,0,1,2,18446744073709551615] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615] +additional floating point tests +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e37,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e37,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e37,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e37,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,Infinity,2.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-2.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e307,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e307,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e307,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e307,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,Infinity,2.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-2.0e-307] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e307),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e307),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e307),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e307),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e307),(Infinity,8060400.0),(1.0e37,8060400.0),(1.0e37,8060400.0),(1.0e37,8060399.0),(1.0e37,8060401.0),(1.0e37,8060398.0),(1.0e37,8060402.0),(1.0e37,Infinity),(1.0e37,1.0e307),(1.0e37,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0)] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e37),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e37),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e37),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e37),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e37),(Infinity,8060400.0),(1.0e307,8060400.0),(1.0e307,8060400.0),(1.0e307,8060399.0),(1.0e307,8060401.0),(1.0e307,8060398.0),(1.0e307,8060402.0),(1.0e307,Infinity),(1.0e307,1.0e37),(1.0e307,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0)] +[(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.1181512090599e13),(69,Infinity,2.1181512090601e13),(69,Infinity,2.1181512090598e13),(69,Infinity,2.1181512090602e13),(69,Infinity,Infinity),(69,Infinity,1.0e307),(69,Infinity,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.1181512090599e13),(69,1.0e37,2.1181512090601e13),(69,1.0e37,2.1181512090598e13),(69,1.0e37,2.1181512090602e13),(69,1.0e37,Infinity),(69,1.0e37,1.0e307),(69,1.0e37,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.1181512090599e13),(70,Infinity,2.1181512090601e13),(70,Infinity,2.1181512090598e13),(70,Infinity,2.1181512090602e13),(70,Infinity,Infinity),(70,Infinity,1.0e307),(70,Infinity,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.1181512090599e13),(70,1.0e37,2.1181512090601e13),(70,1.0e37,2.1181512090598e13),(70,1.0e37,2.1181512090602e13),(70,1.0e37,Infinity),(70,1.0e37,1.0e307),(70,1.0e37,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.1181512090599e13),(71,Infinity,2.1181512090601e13),(71,Infinity,2.1181512090598e13),(71,Infinity,2.1181512090602e13),(71,Infinity,Infinity),(71,Infinity,1.0e307),(71,Infinity,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.1181512090599e13),(71,1.0e37,2.1181512090601e13),(71,1.0e37,2.1181512090598e13),(71,1.0e37,2.1181512090602e13),(71,1.0e37,Infinity),(71,1.0e37,1.0e307),(71,1.0e37,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.1181512090599e13),(68,Infinity,2.1181512090601e13),(68,Infinity,2.1181512090598e13),(68,Infinity,2.1181512090602e13),(68,Infinity,Infinity),(68,Infinity,1.0e307),(68,Infinity,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.1181512090599e13),(68,1.0e37,2.1181512090601e13),(68,1.0e37,2.1181512090598e13),(68,1.0e37,2.1181512090602e13),(68,1.0e37,Infinity),(68,1.0e37,1.0e307),(68,1.0e37,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13)] +various sized tuple returns +[(3,0,0),(3,1,0),(3,2,0),(3,18446744073709551615,0),(3,0,1),(3,1,1),(3,2,1),(3,18446744073709551615,1),(3,0,2),(3,1,2),(3,2,2),(3,18446744073709551615,2),(3,0,18446744073709551615),(3,1,18446744073709551615),(3,2,18446744073709551615),(3,18446744073709551615,18446744073709551615)] +[(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just (-18446744073709551617))] +[(5.0,Just 1,3.0,Nothing,0,Nothing),(5.0,Just 1,3.0,Nothing,1,Nothing),(5.0,Just 1,3.0,Nothing,2,Nothing),(5.0,Just 1,3.0,Nothing,18446744073709551615,Nothing),(5.0,Just 1,3.0,Nothing,0,Just 1),(5.0,Just 1,3.0,Nothing,1,Just 1),(5.0,Just 1,3.0,Nothing,2,Just 1),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just 1),(5.0,Just 1,3.0,Nothing,0,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,1,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,2,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,0,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,1,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,2,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,18446744073709551615,Just (-18446744073709551617))] +[(Nothing,Nothing),(Just 1,Nothing),(Just 18446744073709551617,Nothing),(Just (-18446744073709551617),Nothing),(Nothing,Just 1),(Just 1,Just 1),(Just 18446744073709551617,Just 1),(Just (-18446744073709551617),Just 1),(Nothing,Just 18446744073709551617),(Just 1,Just 18446744073709551617),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just 18446744073709551617),(Nothing,Just (-18446744073709551617)),(Just 1,Just (-18446744073709551617)),(Just 18446744073709551617,Just (-18446744073709551617)),(Just (-18446744073709551617),Just (-18446744073709551617))] +arrays +(11,13) +(13,11) +many arguments +80200 ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.stdout-ws-32 ===================================== @@ -0,0 +1,60 @@ +zero arguments +123 +1.0 +1.0 +one argument functions +[0,-1,1,-128,127] +[0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,4294967295] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615] +[(0,0),(-1,-1),(1,1),(-128,-128),(127,127)] +[(0,0),(-1,-1),(1,1),(-32768,-32768),(32767,32767)] +[(0,0),(-1,-1),(1,1),(-2147483648,-2147483648),(2147483647,2147483647)] +[(0,0),(-1,-1),(1,1),(-9223372036854775808,-9223372036854775808),(9223372036854775807,9223372036854775807)] +[(Nothing,Nothing),(Just 1,Just 1),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just (-18446744073709551617))] +[(0,0),(1,1),(2,2),(4294967295,4294967295)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e37,1.0e37),(-1.0e-37,-1.0e-37)] +[(-0.0,-0.0),(0.0,0.0),(-1.0,-1.0),(1.0,1.0),(-2.0,-2.0),(2.0,2.0),(Infinity,Infinity),(1.0e307,1.0e307),(-1.0e-307,-1.0e-307)] +[(0,0),(1,1),(2,2),(4294967296,4294967296),(18446744073709551615,18446744073709551615)] +two argument functions +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-128,-128,-128,-128,-128,127,127,127,127,127] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-32768,-32768,-32768,-32768,-32768,32767,32767,32767,32767,32767] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,2147483647,2147483647,2147483647,2147483647,2147483647] +[0,0,0,0,0,-1,-1,-1,-1,-1,1,1,1,1,1,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807] +[Nothing,Nothing,Nothing,Nothing,Just 1,Just 1,Just 1,Just 1,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just 18446744073709551617,Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617),Just (-18446744073709551617)] +[0,0,0,0,1,1,1,1,2,2,2,2,4294967295,4294967295,4294967295,4294967295] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307,-1.0e-307] +[0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,4294967296,4294967296,4294967296,4294967296,4294967296,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615] +[0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127,0,-1,1,-128,127] +[0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767,0,-1,1,-32768,32767] +[0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647,0,-1,1,-2147483648,2147483647] +[0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807,0,-1,1,-9223372036854775808,9223372036854775807] +[Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617),Nothing,Just 1,Just 18446744073709551617,Just (-18446744073709551617)] +[0,1,2,4294967295,0,1,2,4294967295,0,1,2,4294967295,0,1,2,4294967295] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615,0,1,2,4294967296,18446744073709551615] +additional floating point tests +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-1.0e-37,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e37,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e37,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e37,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e37,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,Infinity,2.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0,1.0,-2.0,2.0,Infinity,1.0e37,-2.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-1.0,-1.0,-2.0,0.0,-3.0,1.0,Infinity,1.0e307,-1.0,1.0,1.0,0.0,2.0,-1.0,3.0,Infinity,1.0e307,1.0,-2.0,-2.0,-3.0,-1.0,-4.0,0.0,Infinity,1.0e307,-2.0,2.0,2.0,1.0,3.0,0.0,4.0,Infinity,1.0e307,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,1.0e307,Infinity,2.0e307,1.0e307,-1.0e-307,-1.0e-307,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-2.0e-307] +[-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,1.0e37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37,-1.0e-37] +[-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307,-0.0,0.0,-1.0,1.0,-2.0,2.0,Infinity,1.0e307,-1.0e-307] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e307),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e307),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e307),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e307),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e307),(Infinity,8060400.0),(1.0e37,8060400.0),(1.0e37,8060400.0),(1.0e37,8060399.0),(1.0e37,8060401.0),(1.0e37,8060398.0),(1.0e37,8060402.0),(1.0e37,Infinity),(1.0e37,1.0e307),(1.0e37,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e307),(705030.0,8060400.0)] +[(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0),(705029.0,8060400.0),(705029.0,8060400.0),(705029.0,8060399.0),(705029.0,8060401.0),(705029.0,8060398.0),(705029.0,8060402.0),(705029.0,Infinity),(705029.0,1.0e37),(705029.0,8060400.0),(705031.0,8060400.0),(705031.0,8060400.0),(705031.0,8060399.0),(705031.0,8060401.0),(705031.0,8060398.0),(705031.0,8060402.0),(705031.0,Infinity),(705031.0,1.0e37),(705031.0,8060400.0),(705028.0,8060400.0),(705028.0,8060400.0),(705028.0,8060399.0),(705028.0,8060401.0),(705028.0,8060398.0),(705028.0,8060402.0),(705028.0,Infinity),(705028.0,1.0e37),(705028.0,8060400.0),(705032.0,8060400.0),(705032.0,8060400.0),(705032.0,8060399.0),(705032.0,8060401.0),(705032.0,8060398.0),(705032.0,8060402.0),(705032.0,Infinity),(705032.0,1.0e37),(705032.0,8060400.0),(Infinity,8060400.0),(Infinity,8060400.0),(Infinity,8060399.0),(Infinity,8060401.0),(Infinity,8060398.0),(Infinity,8060402.0),(Infinity,Infinity),(Infinity,1.0e37),(Infinity,8060400.0),(1.0e307,8060400.0),(1.0e307,8060400.0),(1.0e307,8060399.0),(1.0e307,8060401.0),(1.0e307,8060398.0),(1.0e307,8060402.0),(1.0e307,Infinity),(1.0e307,1.0e37),(1.0e307,8060400.0),(705030.0,8060400.0),(705030.0,8060400.0),(705030.0,8060399.0),(705030.0,8060401.0),(705030.0,8060398.0),(705030.0,8060402.0),(705030.0,Infinity),(705030.0,1.0e37),(705030.0,8060400.0)] +[(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.11815120906e13),(69,Infinity,2.1181512090599e13),(69,Infinity,2.1181512090601e13),(69,Infinity,2.1181512090598e13),(69,Infinity,2.1181512090602e13),(69,Infinity,Infinity),(69,Infinity,1.0e307),(69,Infinity,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.11815120906e13),(69,1.0e37,2.1181512090599e13),(69,1.0e37,2.1181512090601e13),(69,1.0e37,2.1181512090598e13),(69,1.0e37,2.1181512090602e13),(69,1.0e37,Infinity),(69,1.0e37,1.0e307),(69,1.0e37,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.11815120906e13),(69,2.017141e12,2.1181512090599e13),(69,2.017141e12,2.1181512090601e13),(69,2.017141e12,2.1181512090598e13),(69,2.017141e12,2.1181512090602e13),(69,2.017141e12,Infinity),(69,2.017141e12,1.0e307),(69,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.11815120906e13),(70,Infinity,2.1181512090599e13),(70,Infinity,2.1181512090601e13),(70,Infinity,2.1181512090598e13),(70,Infinity,2.1181512090602e13),(70,Infinity,Infinity),(70,Infinity,1.0e307),(70,Infinity,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.11815120906e13),(70,1.0e37,2.1181512090599e13),(70,1.0e37,2.1181512090601e13),(70,1.0e37,2.1181512090598e13),(70,1.0e37,2.1181512090602e13),(70,1.0e37,Infinity),(70,1.0e37,1.0e307),(70,1.0e37,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.11815120906e13),(70,2.017141e12,2.1181512090599e13),(70,2.017141e12,2.1181512090601e13),(70,2.017141e12,2.1181512090598e13),(70,2.017141e12,2.1181512090602e13),(70,2.017141e12,Infinity),(70,2.017141e12,1.0e307),(70,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.11815120906e13),(71,Infinity,2.1181512090599e13),(71,Infinity,2.1181512090601e13),(71,Infinity,2.1181512090598e13),(71,Infinity,2.1181512090602e13),(71,Infinity,Infinity),(71,Infinity,1.0e307),(71,Infinity,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.11815120906e13),(71,1.0e37,2.1181512090599e13),(71,1.0e37,2.1181512090601e13),(71,1.0e37,2.1181512090598e13),(71,1.0e37,2.1181512090602e13),(71,1.0e37,Infinity),(71,1.0e37,1.0e307),(71,1.0e37,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.11815120906e13),(71,2.017141e12,2.1181512090599e13),(71,2.017141e12,2.1181512090601e13),(71,2.017141e12,2.1181512090598e13),(71,2.017141e12,2.1181512090602e13),(71,2.017141e12,Infinity),(71,2.017141e12,1.0e307),(71,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.11815120906e13),(68,Infinity,2.1181512090599e13),(68,Infinity,2.1181512090601e13),(68,Infinity,2.1181512090598e13),(68,Infinity,2.1181512090602e13),(68,Infinity,Infinity),(68,Infinity,1.0e307),(68,Infinity,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.11815120906e13),(68,1.0e37,2.1181512090599e13),(68,1.0e37,2.1181512090601e13),(68,1.0e37,2.1181512090598e13),(68,1.0e37,2.1181512090602e13),(68,1.0e37,Infinity),(68,1.0e37,1.0e307),(68,1.0e37,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.11815120906e13),(68,2.017141e12,2.1181512090599e13),(68,2.017141e12,2.1181512090601e13),(68,2.017141e12,2.1181512090598e13),(68,2.017141e12,2.1181512090602e13),(68,2.017141e12,Infinity),(68,2.017141e12,1.0e307),(68,2.017141e12,2.11815120906e13)] +various sized tuple returns +[(3,0,0),(3,1,0),(3,2,0),(3,4294967295,0),(3,0,1),(3,1,1),(3,2,1),(3,4294967295,1),(3,0,2),(3,1,2),(3,2,2),(3,4294967295,2),(3,0,4294967295),(3,1,4294967295),(3,2,4294967295),(3,4294967295,4294967295)] +[(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Nothing),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 1),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just 18446744073709551617),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Nothing,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 1,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just 18446744073709551617,Just (-18446744073709551617)),(12.0,11.0,Just (-18446744073709551617),Just 18446744073709551617,8.0,7.0,Just 1,Nothing,4,3,Just (-18446744073709551617),Just (-18446744073709551617))] +[(5.0,Just 1,3.0,Nothing,0,Nothing),(5.0,Just 1,3.0,Nothing,1,Nothing),(5.0,Just 1,3.0,Nothing,2,Nothing),(5.0,Just 1,3.0,Nothing,4294967295,Nothing),(5.0,Just 1,3.0,Nothing,0,Just 1),(5.0,Just 1,3.0,Nothing,1,Just 1),(5.0,Just 1,3.0,Nothing,2,Just 1),(5.0,Just 1,3.0,Nothing,4294967295,Just 1),(5.0,Just 1,3.0,Nothing,0,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,1,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,2,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,4294967295,Just 18446744073709551617),(5.0,Just 1,3.0,Nothing,0,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,1,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,2,Just (-18446744073709551617)),(5.0,Just 1,3.0,Nothing,4294967295,Just (-18446744073709551617))] +[(Nothing,Nothing),(Just 1,Nothing),(Just 18446744073709551617,Nothing),(Just (-18446744073709551617),Nothing),(Nothing,Just 1),(Just 1,Just 1),(Just 18446744073709551617,Just 1),(Just (-18446744073709551617),Just 1),(Nothing,Just 18446744073709551617),(Just 1,Just 18446744073709551617),(Just 18446744073709551617,Just 18446744073709551617),(Just (-18446744073709551617),Just 18446744073709551617),(Nothing,Just (-18446744073709551617)),(Just 1,Just (-18446744073709551617)),(Just 18446744073709551617,Just (-18446744073709551617)),(Just (-18446744073709551617),Just (-18446744073709551617))] +arrays +(11,13) +(13,11) +many arguments +80200 ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm ===================================== @@ -0,0 +1,230 @@ +#include "Cmm.h" + +/* zero arguments */ +cmm_zero() { /* ccall puts("cmm_zero"); buffering gets in the way */ return (); } +cmm_zero_w() { return (123::W_); } +cmm_zero_d() { return (1.0::D_); } +cmm_zero_f() { return (1.0::F_); } +cmm_zero_l() { return (123::L_); } + +/* one argument functions */ +cmm_one1_i8(I8 x) { return (x); } +cmm_one1_i16(I16 x) { return (x); } +cmm_one1_i32(I32 x) { return (x); } +cmm_one1_i64(I64 x) { return (x); } +cmm_one1_p(P_ x) { return (x); } +cmm_one1_w(W_ x) { return (x); } +cmm_one1_f(F_ x) { return (x); } +cmm_one1_d(D_ x) { return (x); } +cmm_one1_l(L_ x) { return (x); } + +cmm_one2_i8(I8 x) { return (x,x); } +cmm_one2_i16(I16 x) { return (x,x); } +cmm_one2_i32(I32 x) { return (x,x); } +cmm_one2_i64(I64 x) { return (x,x); } +cmm_one2_p(P_ x) { return (x,x); } +cmm_one2_w(W_ x) { return (x,x); } +cmm_one2_f(F_ x) { return (x,x); } +cmm_one2_d(D_ x) { return (x,x); } +cmm_one2_l(L_ x) { return (x,x); } + + +/* two argument functions */ +cmm_two1_i8(I8 x, I8 y) { return (x); } +cmm_two1_i16(I16 x, I16 y) { return (x); } +cmm_two1_i32(I32 x, I32 y) { return (x); } +cmm_two1_i64(I64 x, I64 y) { return (x); } +cmm_two1_p(P_ x, P_ y) { return (x); } +cmm_two1_w(W_ x, W_ y) { return (x); } +cmm_two1_f(F_ x, F_ y) { return (x); } +cmm_two1_d(D_ x, D_ y) { return (x); } +cmm_two1_l(L_ x, L_ y) { return (x); } + +cmm_two2_i8(I8 x, I8 y) { return (y); } +cmm_two2_i16(I16 x, I16 y) { return (y); } +cmm_two2_i32(I32 x, I32 y) { return (y); } +cmm_two2_i64(I64 x, I64 y) { return (y); } +cmm_two2_p(P_ x, P_ y) { return (y); } +cmm_two2_w(W_ x, W_ y) { return (y); } +cmm_two2_f(F_ x, F_ y) { return (y); } +cmm_two2_d(D_ x, D_ y) { return (y); } +cmm_two2_l(L_ x, L_ y) { return (y); } + +/* additional tests for floating point, since D_ and F_ registers + overlap on some platforms */ +cmm_floating_1(F_ x, F_ y) { F_ z; z = %fadd(x, y); return (z); } +cmm_floating_2(D_ x, D_ y) { D_ z; z = %fadd(x, y); return (z); } +cmm_floating_3(F_ x, D_ y) { return (x); } +cmm_floating_4(F_ x, D_ y) { return (y); } + + +cmm_floating_5(F_ x1, D_ x2, F_ x3, D_ x4, F_ x5, D_ x6, F_ x7, D_ x8) { + F_ y1; + D_ y2; + + y1 = %fadd(x1,x3); + y1 = %fadd(y1,x5); + y1 = %fadd(y1,x7); + + y2 = %fadd(x2,x4); + y2 = %fadd(y2,x6); + y2 = %fadd(y2,x8); + + return (y1, y2); +} + + +cmm_floating_6(D_ x1, F_ x2, D_ x3, F_ x4, D_ x5, F_ x6, D_ x7, F_ x8) { + D_ y1; + F_ y2; + + y1 = %fadd(x1,x3); + y1 = %fadd(y1,x5); + y1 = %fadd(y1,x7); + + y2 = %fadd(x2,x4); + y2 = %fadd(y2,x6); + y2 = %fadd(y2,x8); + + return (y1, y2); +} + + +cmm_floating_7( W_ x1, F_ x2, D_ x3 + , W_ x4, F_ x5, D_ x6 + , W_ x7, F_ x8, D_ x9 + , W_ x10, F_ x11, D_ x12 + , W_ x13, F_ x14, D_ x15 + , W_ x16, F_ x17, D_ x18 + , W_ x19, F_ x20, D_ x21 + ) { + W_ y1; + F_ y2; + D_ y3; + y1 = x1+x4+x7+x10+x13+x16+x19; + + y2 = %fadd(x2,x5); + y2 = %fadd(y2,x8); + y2 = %fadd(y2,x11); + y2 = %fadd(y2,x14); + y2 = %fadd(y2,x17); + y2 = %fadd(y2,x20); + + y3 = %fadd(x3,x6); + y3 = %fadd(y3,x9); + y3 = %fadd(y3,x12); + y3 = %fadd(y3,x15); + y3 = %fadd(y3,x18); + y3 = %fadd(y3,x21); + + return ( y1, y2, y3 ); +} + + +/* various sized tuple returns */ + +cmm_tuple_1(W_ x, W_ y, W_ z) { return (z, y, x); } +cmm_tuple_2(P_ p1, P_ p2, W_ w1, W_ w2, P_ p3, P_ p4, D_ d1, D_ d2, P_ p5, P_ p6, F_ f1, F_ f2) { + return (f2, f1, p6, p5, d2, d1, p4, p3, w2, w1, p2, p1); +} +cmm_tuple_3(P_ p1, W_ w1, P_ p2, D_ d1, P_ p3, F_ f1) { + return (f1, p3, d1, p2, w1, p1); +} +cmm_tuple_4(P_ p1, P_ p2) { return (p2, p1); } + +/* working with arrays */ +cmm_array_1(P_ x) { + W_ size; + size = StgMutArrPtrs_size(x); + return (size); +} + +/* return two arrays */ +cmm_array_2(P_ x, P_ y) { + return (y, x); +} + +/* many arguments */ +cmm_many_arguments(W_ x1, W_ x2, W_ x3, W_ x4, W_ x5, W_ x6, W_ x7, W_ x8, W_ x9, W_ x10, + W_ x11, W_ x12, W_ x13, W_ x14, W_ x15, W_ x16, W_ x17, W_ x18, W_ x19, W_ x20, + W_ x21, W_ x22, W_ x23, W_ x24, W_ x25, W_ x26, W_ x27, W_ x28, W_ x29, W_ x30, + W_ x31, W_ x32, W_ x33, W_ x34, W_ x35, W_ x36, W_ x37, W_ x38, W_ x39, W_ x40, + W_ x41, W_ x42, W_ x43, W_ x44, W_ x45, W_ x46, W_ x47, W_ x48, W_ x49, W_ x50, + W_ x51, W_ x52, W_ x53, W_ x54, W_ x55, W_ x56, W_ x57, W_ x58, W_ x59, W_ x60, + W_ x61, W_ x62, W_ x63, W_ x64, W_ x65, W_ x66, W_ x67, W_ x68, W_ x69, W_ x70, + W_ x71, W_ x72, W_ x73, W_ x74, W_ x75, W_ x76, W_ x77, W_ x78, W_ x79, W_ x80, + W_ x81, W_ x82, W_ x83, W_ x84, W_ x85, W_ x86, W_ x87, W_ x88, W_ x89, W_ x90, + W_ x91, W_ x92, W_ x93, W_ x94, W_ x95, W_ x96, W_ x97, W_ x98, W_ x99, W_ x100, + W_ x101, W_ x102, W_ x103, W_ x104, W_ x105, W_ x106, W_ x107, W_ x108, W_ x109, W_ x110, + W_ x111, W_ x112, W_ x113, W_ x114, W_ x115, W_ x116, W_ x117, W_ x118, W_ x119, W_ x120, + W_ x121, W_ x122, W_ x123, W_ x124, W_ x125, W_ x126, W_ x127, W_ x128, W_ x129, W_ x130, + W_ x131, W_ x132, W_ x133, W_ x134, W_ x135, W_ x136, W_ x137, W_ x138, W_ x139, W_ x140, + W_ x141, W_ x142, W_ x143, W_ x144, W_ x145, W_ x146, W_ x147, W_ x148, W_ x149, W_ x150, + W_ x151, W_ x152, W_ x153, W_ x154, W_ x155, W_ x156, W_ x157, W_ x158, W_ x159, W_ x160, + W_ x161, W_ x162, W_ x163, W_ x164, W_ x165, W_ x166, W_ x167, W_ x168, W_ x169, W_ x170, + W_ x171, W_ x172, W_ x173, W_ x174, W_ x175, W_ x176, W_ x177, W_ x178, W_ x179, W_ x180, + W_ x181, W_ x182, W_ x183, W_ x184, W_ x185, W_ x186, W_ x187, W_ x188, W_ x189, W_ x190, + W_ x191, W_ x192, W_ x193, W_ x194, W_ x195, W_ x196, W_ x197, W_ x198, W_ x199, W_ x200, + W_ x201, W_ x202, W_ x203, W_ x204, W_ x205, W_ x206, W_ x207, W_ x208, W_ x209, W_ x210, + W_ x211, W_ x212, W_ x213, W_ x214, W_ x215, W_ x216, W_ x217, W_ x218, W_ x219, W_ x220, + W_ x221, W_ x222, W_ x223, W_ x224, W_ x225, W_ x226, W_ x227, W_ x228, W_ x229, W_ x230, + W_ x231, W_ x232, W_ x233, W_ x234, W_ x235, W_ x236, W_ x237, W_ x238, W_ x239, W_ x240, + W_ x241, W_ x242, W_ x243, W_ x244, W_ x245, W_ x246, W_ x247, W_ x248, W_ x249, W_ x250, + W_ x251, W_ x252, W_ x253, W_ x254, W_ x255, W_ x256, W_ x257, W_ x258, W_ x259, W_ x260, + W_ x261, W_ x262, W_ x263, W_ x264, W_ x265, W_ x266, W_ x267, W_ x268, W_ x269, W_ x270, + W_ x271, W_ x272, W_ x273, W_ x274, W_ x275, W_ x276, W_ x277, W_ x278, W_ x279, W_ x280, + W_ x281, W_ x282, W_ x283, W_ x284, W_ x285, W_ x286, W_ x287, W_ x288, W_ x289, W_ x290, + W_ x291, W_ x292, W_ x293, W_ x294, W_ x295, W_ x296, W_ x297, W_ x298, W_ x299, W_ x300, + W_ x301, W_ x302, W_ x303, W_ x304, W_ x305, W_ x306, W_ x307, W_ x308, W_ x309, W_ x310, + W_ x311, W_ x312, W_ x313, W_ x314, W_ x315, W_ x316, W_ x317, W_ x318, W_ x319, W_ x320, + W_ x321, W_ x322, W_ x323, W_ x324, W_ x325, W_ x326, W_ x327, W_ x328, W_ x329, W_ x330, + W_ x331, W_ x332, W_ x333, W_ x334, W_ x335, W_ x336, W_ x337, W_ x338, W_ x339, W_ x340, + W_ x341, W_ x342, W_ x343, W_ x344, W_ x345, W_ x346, W_ x347, W_ x348, W_ x349, W_ x350, + W_ x351, W_ x352, W_ x353, W_ x354, W_ x355, W_ x356, W_ x357, W_ x358, W_ x359, W_ x360, + W_ x361, W_ x362, W_ x363, W_ x364, W_ x365, W_ x366, W_ x367, W_ x368, W_ x369, W_ x370, + W_ x371, W_ x372, W_ x373, W_ x374, W_ x375, W_ x376, W_ x377, W_ x378, W_ x379, W_ x380, + W_ x381, W_ x382, W_ x383, W_ x384, W_ x385, W_ x386, W_ x387, W_ x388, W_ x389, W_ x390, + W_ x391, W_ x392, W_ x393, W_ x394, W_ x395, W_ x396, W_ x397, W_ x398, W_ x399, W_ x400) { + W_ y; + y = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + + x21 + x22 + x23 + x24 + x25 + x26 + x27 + x28 + x29 + x30 + + x31 + x32 + x33 + x34 + x35 + x36 + x37 + x38 + x39 + x40 + + x41 + x42 + x43 + x44 + x45 + x46 + x47 + x48 + x49 + x50 + + x51 + x52 + x53 + x54 + x55 + x56 + x57 + x58 + x59 + x60 + + x61 + x62 + x63 + x64 + x65 + x66 + x67 + x68 + x69 + x70 + + x71 + x72 + x73 + x74 + x75 + x76 + x77 + x78 + x79 + x80 + + x81 + x82 + x83 + x84 + x85 + x86 + x87 + x88 + x89 + x90 + + x91 + x92 + x93 + x94 + x95 + x96 + x97 + x98 + x99 + x100 + + x101 + x102 + x103 + x104 + x105 + x106 + x107 + x108 + x109 + x110 + + x111 + x112 + x113 + x114 + x115 + x116 + x117 + x118 + x119 + x120 + + x121 + x122 + x123 + x124 + x125 + x126 + x127 + x128 + x129 + x130 + + x131 + x132 + x133 + x134 + x135 + x136 + x137 + x138 + x139 + x140 + + x141 + x142 + x143 + x144 + x145 + x146 + x147 + x148 + x149 + x150 + + x151 + x152 + x153 + x154 + x155 + x156 + x157 + x158 + x159 + x160 + + x161 + x162 + x163 + x164 + x165 + x166 + x167 + x168 + x169 + x170 + + x171 + x172 + x173 + x174 + x175 + x176 + x177 + x178 + x179 + x180 + + x181 + x182 + x183 + x184 + x185 + x186 + x187 + x188 + x189 + x190 + + x191 + x192 + x193 + x194 + x195 + x196 + x197 + x198 + x199 + x200 + + x201 + x202 + x203 + x204 + x205 + x206 + x207 + x208 + x209 + x210 + + x211 + x212 + x213 + x214 + x215 + x216 + x217 + x218 + x219 + x220 + + x221 + x222 + x223 + x224 + x225 + x226 + x227 + x228 + x229 + x230 + + x231 + x232 + x233 + x234 + x235 + x236 + x237 + x238 + x239 + x240 + + x241 + x242 + x243 + x244 + x245 + x246 + x247 + x248 + x249 + x250 + + x251 + x252 + x253 + x254 + x255 + x256 + x257 + x258 + x259 + x260 + + x261 + x262 + x263 + x264 + x265 + x266 + x267 + x268 + x269 + x270 + + x271 + x272 + x273 + x274 + x275 + x276 + x277 + x278 + x279 + x280 + + x281 + x282 + x283 + x284 + x285 + x286 + x287 + x288 + x289 + x290 + + x291 + x292 + x293 + x294 + x295 + x296 + x297 + x298 + x299 + x300 + + x301 + x302 + x303 + x304 + x305 + x306 + x307 + x308 + x309 + x310 + + x311 + x312 + x313 + x314 + x315 + x316 + x317 + x318 + x319 + x320 + + x321 + x322 + x323 + x324 + x325 + x326 + x327 + x328 + x329 + x330 + + x331 + x332 + x333 + x334 + x335 + x336 + x337 + x338 + x339 + x340 + + x341 + x342 + x343 + x344 + x345 + x346 + x347 + x348 + x349 + x350 + + x351 + x352 + x353 + x354 + x355 + x356 + x357 + x358 + x359 + x360 + + x361 + x362 + x363 + x364 + x365 + x366 + x367 + x368 + x369 + x370 + + x371 + x372 + x373 + x374 + x375 + x376 + x377 + x378 + x379 + x380 + + x381 + x382 + x383 + x384 + x385 + x386 + x387 + x388 + x389 + x390 + + x391 + x392 + x393 + x394 + x395 + x396 + x397 + x398 + x399 + x400; + return (y); +} ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile ===================================== @@ -0,0 +1,4 @@ +.PHONY: GHCiPrimCall +GHCiPrimCall: + '$(TEST_HC)' $(TEST_HC_OPTS) -fPIC -v0 -c GHCiPrimCall_cmm.cmm + -'$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -e main GHCiPrimCall.hs GHCiPrimCall_cmm.o || echo $$? >&2 ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/all.T ===================================== @@ -0,0 +1,2 @@ +test('GHCiPrimCall', [req_interp], makefile_test, ['GHCiPrimCall']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4807d580ba10d8d6ca4a0309c3a1d24990c6a771 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4807d580ba10d8d6ca4a0309c3a1d24990c6a771 You're receiving 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 Jan 10 07:50:37 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Tue, 10 Jan 2023 02:50:37 -0500 Subject: [Git][ghc/ghc][wip/int-index/type-abs-flag] 3 commits: Remove RTS hack for configuring Message-ID: <63bd18cdab73_3b1bf956324346078@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/type-abs-flag at Glasgow Haskell Compiler / GHC Commits: 5d65773e by John Ericson at 2023-01-09T20:39:27-05:00 Remove RTS hack for configuring See the brand new Note [Undefined symbols in the RTS] for additional details. - - - - - e3fff751 by Sebastian Graf at 2023-01-09T20:40:02-05:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - 449b89e4 by Vladislav Zavialov at 2023-01-10T10:50:09+03:00 Introduce the TypeAbstractions language flag GHC Proposals #448 "Modern scoped type variables" and #425 "Invisible binders in type declarations" introduce a new language extension flag: TypeAbstractions. Part of the functionality guarded by this flag has already been implemented, namely type abstractions in constructor patterns, but it was guarded by a combination of TypeApplications and ScopedTypeVariables instead of a dedicated language extension flag. This patch does the following: * introduces a new language extension flag TypeAbstractions * requires TypeAbstractions for @a-syntax in constructor patterns instead of TypeApplications and ScopedTypeVariables * creates a User's Guide page for TypeAbstractions and moves the "Type Applications in Patterns" section there To avoid a breaking change, the new flag is implied by ScopedTypeVariables and is retroactively added to GHC2021. - - - - - 22 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Rename/Pat.hs - docs/users_guide/exts/gadt.rst - + docs/users_guide/exts/type_abstractions.rst - docs/users_guide/exts/type_applications.rst - docs/users_guide/exts/types.rst - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Rules/Register.hs - libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs - rts/rts.cabal.in - testsuite/tests/driver/T4437.hs - testsuite/tests/showIface/DocsInHiFile1.stdout - testsuite/tests/showIface/DocsInHiFileTH.stdout - testsuite/tests/showIface/HaddockIssue849.stdout - testsuite/tests/showIface/HaddockOpts.stdout - testsuite/tests/showIface/MagicHashInHaddocks.stdout - testsuite/tests/showIface/NoExportList.stdout - testsuite/tests/showIface/PragmaDocs.stdout - testsuite/tests/showIface/ReExports.stdout - testsuite/tests/typecheck/should_compile/T20443a.hs - testsuite/tests/typecheck/should_fail/T19109.stderr Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -333,7 +333,8 @@ dmdAnalBindLetUp :: TopLevelFlag -> WithDmdType (DmdResult CoreBind a) dmdAnalBindLetUp top_lvl env id rhs anal_body = WithDmdType final_ty (R (NonRec id' rhs') (body')) where - WithDmdType body_ty body' = anal_body env + WithDmdType body_ty body' = anal_body (addInScopeAnalEnv env id) + -- See Note [Bringing a new variable into scope] WithDmdType body_ty' id_dmd = findBndrDmd env body_ty id -- See Note [Finalising boxity for demand signatures] @@ -473,7 +474,8 @@ dmdAnal' env dmd (App fun arg) dmdAnal' env dmd (Lam var body) | isTyVar var = let - WithDmdType body_ty body' = dmdAnal env dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) dmd body + -- See Note [Bringing a new variable into scope] in WithDmdType body_ty (Lam var body') @@ -481,7 +483,8 @@ dmdAnal' env dmd (Lam var body) = let (n, body_dmd) = peelCallDmd dmd -- body_dmd: a demand to analyze the body - WithDmdType body_ty body' = dmdAnal env body_dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) body_dmd body + -- See Note [Bringing a new variable into scope] WithDmdType lam_ty var' = annotateLamIdBndr env body_ty var new_dmd_type = multDmdType n lam_ty in @@ -493,7 +496,9 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt_con bndrs rhs]) -- can consider its field demands when analysing the scrutinee. | want_precise_field_dmds alt_con = let - WithDmdType rhs_ty rhs' = dmdAnal env dmd rhs + rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + WithDmdType rhs_ty rhs' = dmdAnal rhs_env dmd rhs WithDmdType alt_ty1 fld_dmds = findBndrsDmds env rhs_ty bndrs WithDmdType alt_ty2 case_bndr_dmd = findBndrDmd env alt_ty1 case_bndr !case_bndr' = setIdDemandInfo case_bndr case_bndr_dmd @@ -629,7 +634,9 @@ dmdAnalSumAlts env dmd case_bndr (alt:alts) dmdAnalSumAlt :: AnalEnv -> SubDemand -> Id -> CoreAlt -> WithDmdType CoreAlt dmdAnalSumAlt env dmd case_bndr (Alt con bndrs rhs) - | WithDmdType rhs_ty rhs' <- dmdAnal env dmd rhs + | let rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + , WithDmdType rhs_ty rhs' <- dmdAnal rhs_env dmd rhs , WithDmdType alt_ty dmds <- findBndrsDmds env rhs_ty bndrs , let (_ :* case_bndr_sd) = findIdDemand alt_ty case_bndr -- See Note [Demand on case-alternative binders] @@ -2399,7 +2406,7 @@ enterDFun bind env emptySigEnv :: SigEnv emptySigEnv = emptyVarEnv --- | Extend an environment with the strictness IDs attached to the id +-- | Extend an environment with the strictness sigs attached to the Ids extendAnalEnvs :: TopLevelFlag -> AnalEnv -> [Id] -> AnalEnv extendAnalEnvs top_lvl env vars = env { ae_sigs = extendSigEnvs top_lvl (ae_sigs env) vars } @@ -2418,6 +2425,12 @@ extendSigEnv top_lvl sigs var sig = extendVarEnv sigs var (sig, top_lvl) lookupSigEnv :: AnalEnv -> Id -> Maybe (DmdSig, TopLevelFlag) lookupSigEnv env id = lookupVarEnv (ae_sigs env) id +addInScopeAnalEnv :: AnalEnv -> Var -> AnalEnv +addInScopeAnalEnv env id = env { ae_sigs = delVarEnv (ae_sigs env) id } + +addInScopeAnalEnvs :: AnalEnv -> [Var] -> AnalEnv +addInScopeAnalEnvs env ids = env { ae_sigs = delVarEnvList (ae_sigs env) ids } + nonVirgin :: AnalEnv -> AnalEnv nonVirgin env = env { ae_virgin = False } @@ -2456,7 +2469,18 @@ findBndrDmd env dmd_ty id fam_envs = ae_fam_envs env -{- Note [Making dictionary parameters strict] +{- Note [Bringing a new variable into scope] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + f x = blah + g = ...(\f. ...f...)... + +In the body of the '\f', any occurrence of `f` refers to the lambda-bound `f`, +not the top-level `f` (which will be in `ae_sigs`). So it's very important +to delete `f` from `ae_sigs` when we pass a lambda/case/let-up binding of `f`. +Otherwise chaos results (#22718). + +Note [Making dictionary parameters strict] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -1412,6 +1412,7 @@ languageExtensions (Just GHC2021) LangExt.PostfixOperators, LangExt.RankNTypes, LangExt.ScopedTypeVariables, + LangExt.TypeAbstractions, -- implied by ScopedTypeVariables according to GHC Proposal #448 "Modern Scoped Type Variables" LangExt.StandaloneDeriving, LangExt.StandaloneKindSignatures, LangExt.TupleSections, @@ -3765,6 +3766,7 @@ xFlagsDeps = [ flagSpec "TraditionalRecordSyntax" LangExt.TraditionalRecordSyntax, flagSpec "TransformListComp" LangExt.TransformListComp, flagSpec "TupleSections" LangExt.TupleSections, + flagSpec "TypeAbstractions" LangExt.TypeAbstractions, flagSpec "TypeApplications" LangExt.TypeApplications, flagSpec "TypeData" LangExt.TypeData, depFlagSpec' "TypeInType" LangExt.TypeInType @@ -3901,6 +3903,9 @@ impliedXFlags , (LangExt.MultiParamTypeClasses, turnOn, LangExt.ConstrainedClassMethods) -- c.f. #7854 , (LangExt.TypeFamilyDependencies, turnOn, LangExt.TypeFamilies) + -- In accordance with GHC Proposal #448 "Modern Scoped Type Variables" + , (LangExt.ScopedTypeVariables, turnOn, LangExt.TypeAbstractions) + , (LangExt.RebindableSyntax, turnOff, LangExt.ImplicitPrelude) -- NB: turn off! , (LangExt.DerivingVia, turnOn, LangExt.DerivingStrategies) ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -640,16 +640,14 @@ rnConPatAndThen mk con (PrefixCon tyargs pats) where check_lang_exts :: RnM () check_lang_exts = do - scoped_tyvars <- xoptM LangExt.ScopedTypeVariables - type_app <- xoptM LangExt.TypeApplications - unless (scoped_tyvars && type_app) $ + type_abs <- xoptM LangExt.TypeAbstractions + unless type_abs $ case listToMaybe tyargs of Nothing -> pure () Just tyarg -> addErr $ mkTcRnUnknownMessage $ mkPlainError noHints $ hang (text "Illegal visible type application in a pattern:" <+> quotes (ppr tyarg)) - 2 (text "Both ScopedTypeVariables and TypeApplications are" - <+> text "required to use this feature") + 2 (text "Perhaps you intended to use TypeAbstractions") rnConPatTyArg (HsConPatTyArg at t) = do t' <- liftCpsWithCont $ rnHsPatSigTypeBindingVars HsTypeCtx t return (HsConPatTyArg at t') ===================================== docs/users_guide/exts/gadt.rst ===================================== @@ -227,7 +227,7 @@ also sets :extension:`GADTSyntax` and :extension:`MonoLocalBinds`. case f of (_ :: F (Maybe z) (Maybe z)) -> Nothing @z - Another way is to use :ref:`type-applications-in-patterns` instead of a + Another way is to use :ref:`type-abstractions-in-patterns` instead of a pattern type signature: :: g4 :: F a a -> a ===================================== docs/users_guide/exts/type_abstractions.rst ===================================== @@ -0,0 +1,95 @@ +Type abstractions +================= + +.. extension:: TypeAbstractions + :shortdesc: Enable type abstraction syntax in patterns and type variable binders. + + :since: 9.6.1 + + :status: Partially implemented + + Allow the use of type abstraction syntax. + +The :extension:`TypeAbstractions` extension provides a way to explicitly bind +scoped type or kind variables using the ``@a`` syntax. The feature is only +partially implemented, and this text covers only the implemented parts, whereas +the full specification can be found in GHC Proposals `#448 `__ +and `#425 `__. + + +.. _type-abstractions-in-patterns: + +Type Abstractions in Patterns +----------------------------- + +The type abstraction syntax can be used in patterns that match a data +constructor. The syntax can't be used with record patterns or infix patterns. +This is useful in particular to bind existential type variables associated with +a GADT data constructor as in the following example:: + + {-# LANGUAGE AllowAmbiguousTypes #-} + {-# LANGUAGE GADTs #-} + {-# LANGUAGE RankNTypes #-} + {-# LANGUAGE TypeApplications #-} + import Data.Proxy + + data Foo where + Foo :: forall a. (Show a, Num a) => Foo + + test :: Foo -> String + test x = case x of + Foo @t -> show @t 0 + + main :: IO () + main = print $ test (Foo @Float) + +In this example, the case in ``test``` is binding an existential variable introduced +by ``Foo`` that otherwise could not be named and used. + +It's possible to bind variables to any part of the type arguments to a constructor; +there is no need for them to be existential. In addition, it's possible to "match" against +part of the type argument using type constructors. + +For a somewhat-contrived example:: + + foo :: (Num a) => Maybe [a] -> String + foo (Nothing @[t]) = show (0 :: t) + foo (Just @[t] xs) = show (sum xs :: t) + +Here, we're binding the type variable t to be the type of the elements of the list type +which is itself the argument to Maybe. + +The order of the type arguments specified by the type applications in a pattern is the same +as that for an expression: either the order as given by the user in an explicit ``forall`` in the +definition of the data constructor, or if that is not present, the order in which the type +variables appear in its type signature from left to right. + +For example if we have the following declaration in GADT syntax:: + + data Foo :: * -> * where + A :: forall s t. [(t,s)] -> Foo (t,s) + B :: (t,s) -> Foo (t,s) + +Then the type arguments to ``A`` will match first ``s`` and then ``t``, while the type arguments +to ``B`` will match first ``t`` and then ``s``. + +Type arguments appearing in patterns can influence the inferred type of a definition:: + + foo (Nothing @Int) = 0 + foo (Just x) = x + +will have inferred type:: + + foo :: Maybe Int -> Int + +which is more restricted than what it would be without the application:: + + foo :: Num a => Maybe a -> a + +For more information and detail regarding type applications in patterns, see the paper +`Type variables in patterns `__ by Eisenberg, Breitner +and Peyton Jones. Relative to that paper, the implementation in GHC for now at least makes one +additional conservative restriction, that type variables occurring in patterns must not +already be in scope, and so are always new variables that only bind whatever type is +matched, rather than ever referring to a variable from an outer scope. Type wildcards +``_`` may be used in any place where no new variable needs binding. ===================================== docs/users_guide/exts/type_applications.rst ===================================== @@ -4,7 +4,7 @@ Visible type application ======================== .. extension:: TypeApplications - :shortdesc: Enable type application syntax in terms, patterns and types. + :shortdesc: Enable type application syntax in terms and types. :since: 8.0.1 @@ -261,81 +261,4 @@ of equality over types. For example, given the following definitions: :: app2 g x = g x GHC will deem all of ``app1 id1``, ``app1 id2``, ``app2 id1``, and ``app2 id2`` -to be well typed. - -.. _type-applications-in-patterns: - -Type Applications in Patterns ------------------------------ - -The type application syntax can be used in patterns that match a data -constructor. The syntax can't be used with record patterns or infix patterns. -This is useful in particular to bind existential type variables associated with -a GADT data constructor as in the following example:: - - {-# LANGUAGE AllowAmbiguousTypes #-} - {-# LANGUAGE GADTs #-} - {-# LANGUAGE RankNTypes #-} - {-# LANGUAGE TypeApplications #-} - import Data.Proxy - - data Foo where - Foo :: forall a. (Show a, Num a) => Foo - - test :: Foo -> String - test x = case x of - Foo @t -> show @t 0 - - main :: IO () - main = print $ test (Foo @Float) - -In this example, the case in ``test``` is binding an existential variable introduced -by ``Foo`` that otherwise could not be named and used. - -It's possible to bind variables to any part of the type arguments to a constructor; -there is no need for them to be existential. In addition, it's possible to "match" against -part of the type argument using type constructors. - -For a somewhat-contrived example:: - - foo :: (Num a) => Maybe [a] -> String - foo (Nothing @[t]) = show (0 :: t) - foo (Just @[t] xs) = show (sum xs :: t) - -Here, we're binding the type variable t to be the type of the elements of the list type -which is itself the argument to Maybe. - -The order of the type arguments specified by the type applications in a pattern is the same -as that for an expression: either the order as given by the user in an explicit ``forall`` in the -definition of the data constructor, or if that is not present, the order in which the type -variables appear in its type signature from left to right. - -For example if we have the following declaration in GADT syntax:: - - data Foo :: * -> * where - A :: forall s t. [(t,s)] -> Foo (t,s) - B :: (t,s) -> Foo (t,s) - -Then the type arguments to ``A`` will match first ``s`` and then ``t``, while the type arguments -to ``B`` will match first ``t`` and then ``s``. - -Type arguments appearing in patterns can influence the inferred type of a definition:: - - foo (Nothing @Int) = 0 - foo (Just x) = x - -will have inferred type:: - - foo :: Maybe Int -> Int - -which is more restricted than what it would be without the application:: - - foo :: Num a => Maybe a -> a - -For more information and detail regarding type applications in patterns, see the paper -`Type variables in patterns `__ by Eisenberg, Breitner -and Peyton Jones. Relative to that paper, the implementation in GHC for now at least makes one -additional conservative restriction, that type variables occurring in patterns must not -already be in scope, and so are always new variables that only bind whatever type is -matched, rather than ever referring to a variable from an outer scope. Type wildcards -``_`` may be used in any place where no new variable needs binding. +to be well typed. \ No newline at end of file ===================================== docs/users_guide/exts/types.rst ===================================== @@ -21,6 +21,7 @@ Types representation_polymorphism type_literals type_applications + type_abstractions rank_polymorphism impredicative_types linear_types ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -148,6 +148,8 @@ configurePackage context at Context {..} = do -- Figure out what hooks we need. hooks <- case C.buildType (C.flattenPackageDescription gpd) of C.Configure -> pure C.autoconfUserHooks + C.Simple -> pure C.simpleUserHooks + C.Make -> fail "build-type: Make is not supported" -- The 'time' package has a 'C.Custom' Setup.hs, but it's actually -- 'C.Configure' plus a @./Setup test@ hook. However, Cabal is also -- 'C.Custom', but doesn't have a configure script. @@ -155,12 +157,6 @@ configurePackage context at Context {..} = do configureExists <- doesFileExist $ replaceFileName (pkgCabalFile package) "configure" pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks - -- Not quite right, but good enough for us: - _ | package == rts -> - -- Don't try to do post configuration validation for 'rts'. This - -- will simply not work, due to the @ld-options@ and @Stg.h at . - pure $ C.simpleUserHooks { C.postConf = \_ _ _ _ -> return () } - | otherwise -> pure C.simpleUserHooks -- Compute the list of flags, and the Cabal configuration arguments flavourArgs <- args <$> flavour ===================================== hadrian/src/Rules/Register.hs ===================================== @@ -45,6 +45,14 @@ configurePackageRules = do isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend when isGmp $ need [buildP -/- "include/ghc-gmp.h"] + when (pkg == rts) $ do + -- Rts.h is a header listed in the cabal file, and configuring + -- therefore wants to ensure that the header "works" post-configure. + -- But it (transitively) includes these, so we must ensure they exist + -- for that check to work. + need [ buildP -/- "include/ghcautoconf.h" + , buildP -/- "include/ghcplatform.h" + ] Cabal.configurePackage ctx root -/- "**/autogen/cabal_macros.h" %> \out -> do ===================================== libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs ===================================== @@ -151,6 +151,7 @@ data Extension | FieldSelectors | OverloadedRecordDot | OverloadedRecordUpdate + | TypeAbstractions deriving (Eq, Enum, Show, Generic, Bounded) -- 'Ord' and 'Bounded' are provided for GHC API users (see discussions -- in https://gitlab.haskell.org/ghc/ghc/merge_requests/2707 and ===================================== rts/rts.cabal.in ===================================== @@ -275,6 +275,8 @@ library stg/SMP.h stg/Ticky.h stg/Types.h + + -- See Note [Undefined symbols in the RTS] if flag(64bit) if flag(leading-underscore) ld-options: @@ -474,6 +476,8 @@ library ld-options: "-Wl,-search_paths_first" -- See Note [fd_set_overflow] "-Wl,-U,___darwin_check_fd_set_overflow" + -- See Note [Undefined symbols in the RTS] + "-Wl,-undefined,dynamic_lookup" if !arch(x86_64) && !arch(aarch64) ld-options: -read_only_relocs warning @@ -714,3 +718,35 @@ library -- , https://github.com/sitsofe/fio/commit/b6a1e63a1ff607692a3caf3c2db2c3d575ba2320 -- The issue was originally reported in #19950 + + +-- Note [Undefined symbols in the RTS] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- The RTS is built with a number of `-u` flags. This is to handle cyclic +-- dependencies between the RTS and other libraries which we normally think of as +-- downstream from the RTS. "Regular" dependencies from usages in those libraries +-- to definitions in the RTS are handled normally. "Reverse" dependencies from +-- usages in the RTS to definitions in those libraries get the `-u` flag in the +-- RTS. +-- +-- The symbols are specified literally, but follow C ABI conventions (as all 3 of +-- C, C--, and Haskell do currently). Thus, we have to be careful to include a +-- leading underscore or not based on those conventions for the given platform in +-- question. +-- +-- A tricky part is that different linkers have different policies regarding +-- undefined symbols (not defined in the current binary, or found in a shared +-- library that could be loaded at run time). GNU Binutils' linker is fine with +-- undefined symbols by default, but Apple's "cctools" linker is not. To appease +-- that linker we either need to do a blanket `-undefined dynamic_lookup` or +-- whitelist each such symbol with an additional `-U` (see the man page for more +-- details). +-- +-- GHC already does `-undefined dynamic_lookup`, so we just do that for now, but +-- we might try to get more precise with `-U` in the future. +-- +-- Note that the RTS also `-u`s some atomics symbols that *are* defined --- and +-- defined within the RTS! It is not immediately clear why this is needed. This +-- dates back to c06e3f46d24ef69f3a3d794f5f604cb8c2a40cbc which mentions a build +-- failure that it was suggested that this fix, but the precise reasoning is not +-- explained. ===================================== testsuite/tests/driver/T4437.hs ===================================== @@ -37,7 +37,7 @@ check title expected got -- See Note [Adding a language extension] in compiler/GHC/Driver/Session.hs. expectedGhcOnlyExtensions :: [String] expectedGhcOnlyExtensions = - [ + [ "TypeAbstractions" ] expectedCabalOnlyExtensions :: [String] ===================================== testsuite/tests/showIface/DocsInHiFile1.stdout ===================================== @@ -143,5 +143,6 @@ docs: ImportQualifiedPost StandaloneKindSignatures FieldSelectors + TypeAbstractions extensible fields: ===================================== testsuite/tests/showIface/DocsInHiFileTH.stdout ===================================== @@ -286,5 +286,6 @@ docs: ImportQualifiedPost StandaloneKindSignatures FieldSelectors + TypeAbstractions extensible fields: ===================================== testsuite/tests/showIface/HaddockIssue849.stdout ===================================== @@ -66,5 +66,6 @@ docs: ImportQualifiedPost StandaloneKindSignatures FieldSelectors + TypeAbstractions extensible fields: ===================================== testsuite/tests/showIface/HaddockOpts.stdout ===================================== @@ -58,5 +58,6 @@ docs: ImportQualifiedPost StandaloneKindSignatures FieldSelectors + TypeAbstractions extensible fields: ===================================== testsuite/tests/showIface/MagicHashInHaddocks.stdout ===================================== @@ -68,5 +68,6 @@ docs: ImportQualifiedPost StandaloneKindSignatures FieldSelectors + TypeAbstractions extensible fields: ===================================== testsuite/tests/showIface/NoExportList.stdout ===================================== @@ -94,5 +94,6 @@ docs: ImportQualifiedPost StandaloneKindSignatures FieldSelectors + TypeAbstractions extensible fields: ===================================== testsuite/tests/showIface/PragmaDocs.stdout ===================================== @@ -68,5 +68,6 @@ docs: ImportQualifiedPost StandaloneKindSignatures FieldSelectors + TypeAbstractions extensible fields: ===================================== testsuite/tests/showIface/ReExports.stdout ===================================== @@ -65,5 +65,6 @@ docs: ImportQualifiedPost StandaloneKindSignatures FieldSelectors + TypeAbstractions extensible fields: ===================================== testsuite/tests/typecheck/should_compile/T20443a.hs ===================================== @@ -10,4 +10,4 @@ a :: () -> Proxy Int a () = Proxy @Int b :: Proxy Int -> () -b (Proxy @Int) = () -- This should compile, but doesn't +b (Proxy @Int) = () ===================================== testsuite/tests/typecheck/should_fail/T19109.stderr ===================================== @@ -1,4 +1,4 @@ T19109.hs:6:4: error: Illegal visible type application in a pattern: ‘@Int’ - Both ScopedTypeVariables and TypeApplications are required to use this feature + Perhaps you intended to use TypeAbstractions View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cda7ebdb2589abc76bc220c1fa22999de680022c...449b89e4529416efc24cefdd5c7f12be4a60d688 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cda7ebdb2589abc76bc220c1fa22999de680022c...449b89e4529416efc24cefdd5c7f12be4a60d688 You're receiving 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 Jan 10 07:58:13 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 10 Jan 2023 02:58:13 -0500 Subject: [Git][ghc/ghc][master] 6 commits: Add safe list indexing operator: !? Message-ID: <63bd1a95318ac_3b1bf959e7035581f@gitlab.mail> Matthew Pickering pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d53f6f4d by Oleg Grenrus at 2023-01-09T21:11:02-05:00 Add safe list indexing operator: !? With Joachim's amendments. Implements https://github.com/haskell/core-libraries-committee/issues/110 - - - - - cfaf1ad7 by Nicolas Trangez at 2023-01-09T21:11:03-05:00 rts, tests: limit thread name length to 15 bytes On Linux, `pthread_setname_np` (or rather, the kernel) only allows for thread names up to 16 bytes, including the terminating null byte. This commit adds a note pointing this out in `createOSThread`, and fixes up two instances where a thread name of more than 15 characters long was used (in the RTS, and in a test-case). Fixes: #22366 Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796 - - - - - 64286132 by Matthew Pickering at 2023-01-09T21:11:03-05:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 4724e8d1 by Matthew Pickering at 2023-01-09T21:11:04-05:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. This completes the fix for #22429 - - - - - 2e926b88 by Georgi Lyubenov at 2023-01-09T21:11:07-05:00 Fix outdated link to Happy section on sequences - - - - - 146a1458 by Matthew Pickering at 2023-01-09T21:11:07-05:00 Revert "NCG(x86): Compile add+shift as lea if possible." This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a. See #22666 and #21777 - - - - - 15 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Parser.y - configure.ac - distrib/configure.ac.in - libraries/base/Data/List.hs - libraries/base/Data/OldList.hs - libraries/base/GHC/List.hs - libraries/base/changelog.md - m4/ghc_llvm_target.m4 - rts/posix/OSThreads.c - rts/sm/NonMoving.c - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.asm - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.hs - testsuite/tests/codeGen/should_gen_asm/all.T - testsuite/tests/rts/pause-resume/pause_resume.c Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -1048,29 +1048,10 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps -------------------- add_code :: Width -> CmmExpr -> CmmExpr -> NatM Register - -- x + imm add_code rep x (CmmLit (CmmInt y _)) | is32BitInteger y , rep /= W8 -- LEA doesn't support byte size (#18614) = add_int rep x y - -- x + (y << imm) - add_code rep x y - -- Byte size is not supported and 16bit size is slow when computed via LEA - | rep /= W8 && rep /= W16 - -- 2^3 = 8 is the highest multiplicator supported by LEA. - , Just (x,y,shift_bits) <- get_shift x y - = add_shiftL rep x y (fromIntegral shift_bits) - where - -- x + (y << imm) - get_shift x (CmmMachOp (MO_Shl _w) [y, CmmLit (CmmInt shift_bits _)]) - | shift_bits <= 3 - = Just (x, y, shift_bits) - -- (y << imm) + x - get_shift (CmmMachOp (MO_Shl _w) [y, CmmLit (CmmInt shift_bits _)]) x - | shift_bits <= 3 - = Just (x, y, shift_bits) - get_shift _ _ - = Nothing add_code rep x y = trivialCode rep (ADD format) (Just (ADD format)) x y where format = intFormat rep -- TODO: There are other interesting patterns we want to replace @@ -1085,7 +1066,6 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps sub_code rep x y = trivialCode rep (SUB (intFormat rep)) Nothing x y -- our three-operand add instruction: - add_int :: (Width -> CmmExpr -> Integer -> NatM Register) add_int width x y = do (x_reg, x_code) <- getSomeReg x let @@ -1099,22 +1079,6 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps -- return (Any format code) - -- x + (y << shift_bits) using LEA - add_shiftL :: (Width -> CmmExpr -> CmmExpr -> Int -> NatM Register) - add_shiftL width x y shift_bits = do - (x_reg, x_code) <- getSomeReg x - (y_reg, y_code) <- getSomeReg y - let - format = intFormat width - imm = ImmInt 0 - code dst - = (x_code `appOL` y_code) `snocOL` - LEA format - (OpAddr (AddrBaseIndex (EABaseReg x_reg) (EAIndex y_reg (2 ^ shift_bits)) imm)) - (OpReg dst) - -- - return (Any format code) - ---------------------- -- See Note [DIV/IDIV for bytes] ===================================== compiler/GHC/Parser.y ===================================== @@ -540,8 +540,9 @@ importdecls This might seem like an awfully roundabout way to declare a list; plus, to add insult to injury you have to reverse the results at the end. The answer is that left recursion prevents us from running out of stack space when parsing long -sequences. See: https://www.haskell.org/happy/doc/html/sec-sequences.html for -more guidance. +sequences. See: +https://haskell-happy.readthedocs.io/en/latest/using.html#parsing-sequences +for more guidance. By adding/removing branches, you can affect what lists are accepted. Here are the most common patterns, rewritten as regular expressions for clarity: ===================================== configure.ac ===================================== @@ -667,6 +667,8 @@ GHC_LLVM_TARGET_SET_VAR # we intend to pass trough --targets to llvm as is. LLVMTarget_CPP=` echo "$LlvmTarget"` AC_SUBST(LLVMTarget_CPP) +# The target is substituted into the distrib/configure.ac file +AC_SUBST(LlvmTarget) dnl ** See whether cc supports --target= and set dnl CONF_CC_OPTS_STAGE[012] accordingly. ===================================== distrib/configure.ac.in ===================================== @@ -18,6 +18,8 @@ dnl-------------------------------------------------------------------- dnl Various things from the source distribution configure bootstrap_target=@TargetPlatform@ +bootstrap_llvm_target=@LlvmTarget@ + TargetHasRTSLinker=@TargetHasRTSLinker@ AC_SUBST(TargetHasRTSLinker) @@ -169,6 +171,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG # Stage 3 won't be supported by cross-compilation FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) +FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) +FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + AC_SUBST(CONF_CC_OPTS_STAGE0) AC_SUBST(CONF_CC_OPTS_STAGE1) AC_SUBST(CONF_CC_OPTS_STAGE2) ===================================== libraries/base/Data/List.hs ===================================== @@ -127,6 +127,7 @@ module Data.List -- | These functions treat a list @xs@ as a indexed collection, -- with indices ranging from 0 to @'length' xs - 1 at . + , (!?) , (!!) , elemIndex ===================================== libraries/base/Data/OldList.hs ===================================== @@ -127,6 +127,7 @@ module Data.OldList -- | These functions treat a list @xs@ as a indexed collection, -- with indices ranging from 0 to @'length' xs - 1 at . + , (!?) , (!!) , elemIndex ===================================== libraries/base/GHC/List.hs ===================================== @@ -31,7 +31,7 @@ module GHC.List ( -- Other functions foldl1', concat, concatMap, map, (++), filter, lookup, - head, last, tail, init, uncons, (!!), + head, last, tail, init, uncons, (!?), (!!), scanl, scanl1, scanl', scanr, scanr1, iterate, iterate', repeat, replicate, cycle, take, drop, splitAt, takeWhile, dropWhile, span, break, reverse, @@ -49,7 +49,7 @@ import GHC.Num (Num(..)) import GHC.Num.Integer (Integer) import GHC.Stack.Types (HasCallStack) -infixl 9 !! +infixl 9 !?, !! infix 4 `elem`, `notElem` -- $setup @@ -1370,9 +1370,10 @@ concat = foldr (++) [] -- >>> ['a', 'b', 'c'] !! (-1) -- *** Exception: Prelude.!!: negative index -- --- WARNING: This function is partial. You can use --- --- instead. +-- WARNING: This function is partial, and should only be used if you are +-- sure that the indexing will not fail. Otherwise, use 'Data.List.!?'. +-- +-- WARNING: This function takes linear time in the index. #if defined(USE_REPORT_PRELUDE) (!!) :: [a] -> Int -> a xs !! n | n < 0 = errorWithoutStackTrace "Prelude.!!: negative index" @@ -1401,6 +1402,30 @@ xs !! n _ -> r (k-1)) tooLarge xs n #endif +-- | List index (subscript) operator, starting from 0. Returns 'Nothing' +-- if the index is out of bounds +-- +-- >>> ['a', 'b', 'c'] !? 0 +-- Just 'a' +-- >>> ['a', 'b', 'c'] !? 2 +-- Just 'c' +-- >>> ['a', 'b', 'c'] !? 3 +-- Nothing +-- >>> ['a', 'b', 'c'] !? (-1) +-- Nothing +-- +-- This is the total variant of the partial '!!' operator. +-- +-- WARNING: This function takes linear time in the index. +(!?) :: [a] -> Int -> Maybe a + +{-# INLINABLE (!?) #-} +xs !? n + | n < 0 = Nothing + | otherwise = foldr (\x r k -> case k of + 0 -> Just x + _ -> r (k-1)) (const Nothing) xs n + -------------------------------------------------------------- -- The zip family -------------------------------------------------------------- ===================================== libraries/base/changelog.md ===================================== @@ -58,6 +58,8 @@ 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`. + * Add `Data.List.!?` per + [CLC proposal #110](https://github.com/haskell/core-libraries-committee/issues/110). ## 4.17.0.0 *August 2022* ===================================== m4/ghc_llvm_target.m4 ===================================== @@ -50,5 +50,10 @@ AC_DEFUN([GHC_LLVM_TARGET], [ # require it. AC_DEFUN([GHC_LLVM_TARGET_SET_VAR], [ AC_REQUIRE([FPTOOLS_SET_PLATFORMS_VARS]) - GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + if test "$bootstrap_llvm_target" != "" + then + LlvmTarget=$bootstrap_llvm_target + else + GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + fi ]) ===================================== rts/posix/OSThreads.c ===================================== @@ -218,6 +218,12 @@ start_thread (void *param) return startProc(startParam); } +/* Note: at least on Linux/Glibc, `pthread_setname_np` restricts the name of + * a thread to 16 bytes, including the terminating null byte. Hence, make sure + * to only pass in names of up to 15 characters. Otherwise, + * `pthread_setname_np` when called in `start_thread` will fail with `ERANGE`, + * which is not checked for, and the thread won't be named at all. + */ int createOSThread (OSThreadId* pId, const char *name, OSThreadProc *startProc, void *param) ===================================== rts/sm/NonMoving.c ===================================== @@ -1015,7 +1015,7 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) nonmoving_write_barrier_enabled = true; debugTrace(DEBUG_nonmoving_gc, "Starting concurrent mark thread"); OSThreadId thread; - if (createOSThread(&thread, "non-moving mark thread", + if (createOSThread(&thread, "nonmoving-mark", nonmovingConcurrentMark, mark_queue) != 0) { barf("nonmovingCollect: failed to spawn mark thread: %s", strerror(errno)); } ===================================== testsuite/tests/codeGen/should_gen_asm/AddMulX86.asm deleted ===================================== @@ -1,46 +0,0 @@ -.section .text -.align 8 -.align 8 - .quad 8589934604 - .quad 0 - .long 14 - .long 0 -.globl AddMulX86_f_info -.type AddMulX86_f_info, @function -AddMulX86_f_info: -.LcAx: - leaq (%r14,%rsi,8),%rbx - jmp *(%rbp) - .size AddMulX86_f_info, .-AddMulX86_f_info -.section .data -.align 8 -.align 1 -.globl AddMulX86_f_closure -.type AddMulX86_f_closure, @object -AddMulX86_f_closure: - .quad AddMulX86_f_info -.section .text -.align 8 -.align 8 - .quad 8589934604 - .quad 0 - .long 14 - .long 0 -.globl AddMulX86_g_info -.type AddMulX86_g_info, @function -AddMulX86_g_info: -.LcAL: - leaq (%r14,%rsi,8),%rbx - jmp *(%rbp) - .size AddMulX86_g_info, .-AddMulX86_g_info -.section .data -.align 8 -.align 1 -.globl AddMulX86_g_closure -.type AddMulX86_g_closure, @object -AddMulX86_g_closure: - .quad AddMulX86_g_info -.section .note.GNU-stack,"", at progbits -.ident "GHC 9.3.20220228" - - ===================================== testsuite/tests/codeGen/should_gen_asm/AddMulX86.hs deleted ===================================== @@ -1,12 +0,0 @@ -{-# LANGUAGE MagicHash #-} - -module AddMulX86 where - -import GHC.Exts - -f :: Int# -> Int# -> Int# -f x y = - x +# (y *# 8#) -- Should result in a lea instruction, which we grep the assembly output for. - -g x y = - (y *# 8#) +# x -- Should result in a lea instruction, which we grep the assembly output for. ===================================== testsuite/tests/codeGen/should_gen_asm/all.T ===================================== @@ -10,4 +10,3 @@ test('memset-unroll', is_amd64_codegen, compile_cmp_asm, ['cmm', '']) test('bytearray-memset-unroll', is_amd64_codegen, compile_grep_asm, ['hs', True, '']) test('bytearray-memcpy-unroll', is_amd64_codegen, compile_grep_asm, ['hs', True, '']) test('T18137', [when(opsys('darwin'), skip), only_ways(llvm_ways)], compile_grep_asm, ['hs', False, '-fllvm -split-sections']) -test('AddMulX86', is_amd64_codegen, compile_cmp_asm, ['hs', '-dno-typeable-binds']) ===================================== testsuite/tests/rts/pause-resume/pause_resume.c ===================================== @@ -187,7 +187,7 @@ void pauseAndResumeViaThread ) { OSThreadId threadId; - createOSThread(&threadId, "Pause and resume thread", &pauseAndResumeViaThread_helper, (void *)count); + createOSThread(&threadId, "pause-resume", &pauseAndResumeViaThread_helper, (void *)count); } const int TIMEOUT = 1000000; // 1 second View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e3fff7512bbf989386faaa1dccafdad1deabde84...146a145835f5c2e82da4dd0bcb90702460505a01 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e3fff7512bbf989386faaa1dccafdad1deabde84...146a145835f5c2e82da4dd0bcb90702460505a01 You're receiving 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 Jan 10 08:03:47 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 10 Jan 2023 03:03:47 -0500 Subject: [Git][ghc/ghc][wip/misc-cleanup4] 11 commits: Disable split sections on aarch64-deb10 build Message-ID: <63bd1be3a7e0c_3b1bf93fcc99037683c@gitlab.mail> Matthew Pickering pushed to branch wip/misc-cleanup4 at Glasgow Haskell Compiler / GHC Commits: 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 5d65773e by John Ericson at 2023-01-09T20:39:27-05:00 Remove RTS hack for configuring See the brand new Note [Undefined symbols in the RTS] for additional details. - - - - - e3fff751 by Sebastian Graf at 2023-01-09T20:40:02-05:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - d53f6f4d by Oleg Grenrus at 2023-01-09T21:11:02-05:00 Add safe list indexing operator: !? With Joachim's amendments. Implements https://github.com/haskell/core-libraries-committee/issues/110 - - - - - cfaf1ad7 by Nicolas Trangez at 2023-01-09T21:11:03-05:00 rts, tests: limit thread name length to 15 bytes On Linux, `pthread_setname_np` (or rather, the kernel) only allows for thread names up to 16 bytes, including the terminating null byte. This commit adds a note pointing this out in `createOSThread`, and fixes up two instances where a thread name of more than 15 characters long was used (in the RTS, and in a test-case). Fixes: #22366 Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796 - - - - - 64286132 by Matthew Pickering at 2023-01-09T21:11:03-05:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 4724e8d1 by Matthew Pickering at 2023-01-09T21:11:04-05:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. This completes the fix for #22429 - - - - - 2e926b88 by Georgi Lyubenov at 2023-01-09T21:11:07-05:00 Fix outdated link to Happy section on sequences - - - - - 146a1458 by Matthew Pickering at 2023-01-09T21:11:07-05:00 Revert "NCG(x86): Compile add+shift as lea if possible." This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a. See #22666 and #21777 - - - - - aae5f085 by Krzysztof Gogolewski at 2023-01-10T08:03:45+00:00 Misc cleanup - Remove unused mkWildEvBinder - Use typeTypeOrConstraint - more symmetric and asserts that that the type is Type or Constraint - Use text "foo" in JS, to make sure the rule fires - Fix escape sequences in Python; they raise a deprecation warning with -Wdefault - - - - - 30 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Type.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/JS/Ppr.hs - compiler/GHC/Parser.y - compiler/GHC/Tc/Validity.hs - configure.ac - distrib/configure.ac.in - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Rules/Register.hs - libraries/base/Data/List.hs - libraries/base/Data/OldList.hs - libraries/base/GHC/List.hs - libraries/base/changelog.md - m4/ghc_llvm_target.m4 - rts/posix/OSThreads.c - rts/rts.cabal.in - rts/sm/NonMoving.c - testsuite/driver/runtests.py - testsuite/tests/cabal/all.T - testsuite/tests/cmm/should_compile/all.T - testsuite/tests/codeGen/should_compile/all.T - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.asm - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/327cd74684f6b1d70aa2e4c54f09e4a9d789962f...aae5f085a32358000d930d8b9165a9ee49ed0200 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/327cd74684f6b1d70aa2e4c54f09e4a9d789962f...aae5f085a32358000d930d8b9165a9ee49ed0200 You're receiving 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 Jan 10 08:04:23 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 10 Jan 2023 03:04:23 -0500 Subject: [Git][ghc/ghc][wip/ghci-primcall] 7 commits: Add safe list indexing operator: !? Message-ID: <63bd1c07973cd_3b1bf959e70377950@gitlab.mail> Matthew Pickering pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: d53f6f4d by Oleg Grenrus at 2023-01-09T21:11:02-05:00 Add safe list indexing operator: !? With Joachim's amendments. Implements https://github.com/haskell/core-libraries-committee/issues/110 - - - - - cfaf1ad7 by Nicolas Trangez at 2023-01-09T21:11:03-05:00 rts, tests: limit thread name length to 15 bytes On Linux, `pthread_setname_np` (or rather, the kernel) only allows for thread names up to 16 bytes, including the terminating null byte. This commit adds a note pointing this out in `createOSThread`, and fixes up two instances where a thread name of more than 15 characters long was used (in the RTS, and in a test-case). Fixes: #22366 Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796 - - - - - 64286132 by Matthew Pickering at 2023-01-09T21:11:03-05:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 4724e8d1 by Matthew Pickering at 2023-01-09T21:11:04-05:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. This completes the fix for #22429 - - - - - 2e926b88 by Georgi Lyubenov at 2023-01-09T21:11:07-05:00 Fix outdated link to Happy section on sequences - - - - - 146a1458 by Matthew Pickering at 2023-01-09T21:11:07-05:00 Revert "NCG(x86): Compile add+shift as lea if possible." This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a. See #22666 and #21777 - - - - - 7b1933be by Luite Stegeman at 2023-01-10T08:04:21+00:00 Add PrimCallConv support to GHCi This adds support for calling Cmm code from bytecode using the native calling convention, allowing modules that use `foreign import prim` to be loaded and debugged in GHCi. This patch introduces a new `PRIMCALL` bytecode instruction and a helper stack frame `stg_primcall`. The code is based on the existing functionality for dealing with unboxed tuples in bytecode, which has been generalised to handle arbitrary calls. Fixes #22051 - - - - - 30 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Parser.y - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Foreign.hs - configure.ac - distrib/configure.ac.in - libraries/base/Data/List.hs - libraries/base/Data/OldList.hs - libraries/base/GHC/List.hs - libraries/base/changelog.md - m4/ghc_llvm_target.m4 - rts/Disassembler.c - rts/Interpreter.c - rts/RtsSymbols.c - rts/StgMiscClosures.cmm - rts/include/rts/Bytecodes.h - rts/include/stg/MiscClosures.h - rts/posix/OSThreads.c - rts/sm/NonMoving.c - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.asm - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.hs - testsuite/tests/codeGen/should_gen_asm/all.T - testsuite/tests/ghci/prog014/prog014.T - + testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4807d580ba10d8d6ca4a0309c3a1d24990c6a771...7b1933be1295f97620879065d1f98b086a2a0915 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4807d580ba10d8d6ca4a0309c3a1d24990c6a771...7b1933be1295f97620879065d1f98b086a2a0915 You're receiving 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 Jan 10 08:04:33 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 10 Jan 2023 03:04:33 -0500 Subject: [Git][ghc/ghc][wip/int-index/type-abs-flag] 7 commits: Add safe list indexing operator: !? Message-ID: <63bd1c11f36a7_3b1bf959e7037862e@gitlab.mail> Matthew Pickering pushed to branch wip/int-index/type-abs-flag at Glasgow Haskell Compiler / GHC Commits: d53f6f4d by Oleg Grenrus at 2023-01-09T21:11:02-05:00 Add safe list indexing operator: !? With Joachim's amendments. Implements https://github.com/haskell/core-libraries-committee/issues/110 - - - - - cfaf1ad7 by Nicolas Trangez at 2023-01-09T21:11:03-05:00 rts, tests: limit thread name length to 15 bytes On Linux, `pthread_setname_np` (or rather, the kernel) only allows for thread names up to 16 bytes, including the terminating null byte. This commit adds a note pointing this out in `createOSThread`, and fixes up two instances where a thread name of more than 15 characters long was used (in the RTS, and in a test-case). Fixes: #22366 Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796 - - - - - 64286132 by Matthew Pickering at 2023-01-09T21:11:03-05:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 4724e8d1 by Matthew Pickering at 2023-01-09T21:11:04-05:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. This completes the fix for #22429 - - - - - 2e926b88 by Georgi Lyubenov at 2023-01-09T21:11:07-05:00 Fix outdated link to Happy section on sequences - - - - - 146a1458 by Matthew Pickering at 2023-01-09T21:11:07-05:00 Revert "NCG(x86): Compile add+shift as lea if possible." This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a. See #22666 and #21777 - - - - - 9020062f by Vladislav Zavialov at 2023-01-10T08:04:31+00:00 Introduce the TypeAbstractions language flag GHC Proposals #448 "Modern scoped type variables" and #425 "Invisible binders in type declarations" introduce a new language extension flag: TypeAbstractions. Part of the functionality guarded by this flag has already been implemented, namely type abstractions in constructor patterns, but it was guarded by a combination of TypeApplications and ScopedTypeVariables instead of a dedicated language extension flag. This patch does the following: * introduces a new language extension flag TypeAbstractions * requires TypeAbstractions for @a-syntax in constructor patterns instead of TypeApplications and ScopedTypeVariables * creates a User's Guide page for TypeAbstractions and moves the "Type Applications in Patterns" section there To avoid a breaking change, the new flag is implied by ScopedTypeVariables and is retroactively added to GHC2021. - - - - - 30 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Parser.y - compiler/GHC/Rename/Pat.hs - configure.ac - distrib/configure.ac.in - docs/users_guide/exts/gadt.rst - + docs/users_guide/exts/type_abstractions.rst - docs/users_guide/exts/type_applications.rst - docs/users_guide/exts/types.rst - libraries/base/Data/List.hs - libraries/base/Data/OldList.hs - libraries/base/GHC/List.hs - libraries/base/changelog.md - libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs - m4/ghc_llvm_target.m4 - rts/posix/OSThreads.c - rts/sm/NonMoving.c - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.asm - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.hs - testsuite/tests/codeGen/should_gen_asm/all.T - testsuite/tests/driver/T4437.hs - testsuite/tests/rts/pause-resume/pause_resume.c - testsuite/tests/showIface/DocsInHiFile1.stdout - testsuite/tests/showIface/DocsInHiFileTH.stdout - testsuite/tests/showIface/HaddockIssue849.stdout - testsuite/tests/showIface/HaddockOpts.stdout - testsuite/tests/showIface/MagicHashInHaddocks.stdout - testsuite/tests/showIface/NoExportList.stdout - testsuite/tests/showIface/PragmaDocs.stdout The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/449b89e4529416efc24cefdd5c7f12be4a60d688...9020062fc21a2fc598d14d7d011f216fd81073d3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/449b89e4529416efc24cefdd5c7f12be4a60d688...9020062fc21a2fc598d14d7d011f216fd81073d3 You're receiving 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 Jan 10 08:05:01 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 10 Jan 2023 03:05:01 -0500 Subject: [Git][ghc/ghc][wip/rts-configure-0] 7 commits: Add safe list indexing operator: !? Message-ID: <63bd1c2da1ecd_3b1bf9563243791f3@gitlab.mail> Matthew Pickering pushed to branch wip/rts-configure-0 at Glasgow Haskell Compiler / GHC Commits: d53f6f4d by Oleg Grenrus at 2023-01-09T21:11:02-05:00 Add safe list indexing operator: !? With Joachim's amendments. Implements https://github.com/haskell/core-libraries-committee/issues/110 - - - - - cfaf1ad7 by Nicolas Trangez at 2023-01-09T21:11:03-05:00 rts, tests: limit thread name length to 15 bytes On Linux, `pthread_setname_np` (or rather, the kernel) only allows for thread names up to 16 bytes, including the terminating null byte. This commit adds a note pointing this out in `createOSThread`, and fixes up two instances where a thread name of more than 15 characters long was used (in the RTS, and in a test-case). Fixes: #22366 Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796 - - - - - 64286132 by Matthew Pickering at 2023-01-09T21:11:03-05:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 4724e8d1 by Matthew Pickering at 2023-01-09T21:11:04-05:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. This completes the fix for #22429 - - - - - 2e926b88 by Georgi Lyubenov at 2023-01-09T21:11:07-05:00 Fix outdated link to Happy section on sequences - - - - - 146a1458 by Matthew Pickering at 2023-01-09T21:11:07-05:00 Revert "NCG(x86): Compile add+shift as lea if possible." This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a. See #22666 and #21777 - - - - - 5a763d8c by John Ericson at 2023-01-10T08:04:54+00:00 Give the RTS it's own configure script Currently it doesn't do much anything, we are just trying to introduce it without breaking the build. Later, we will move functionality from the top-level configure script over to it. We need to bump Cabal for https://github.com/haskell/cabal/pull/8649; to facilitate and existing hack of skipping some configure checks for the RTS we now need to skip just *part* not *all* of the "post configure" hook, as running the configure script (which we definitely want to do) is also implemented as part of the "post configure" hook. But doing this requires exposing functionality that wasn't exposed before. - - - - - 26 changed files: - boot - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Parser.y - configure.ac - distrib/configure.ac.in - hadrian/src/Base.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Lint.hs - hadrian/src/Rules/Register.hs - hadrian/src/Rules/SourceDist.hs - libraries/base/.gitignore - libraries/base/Data/List.hs - libraries/base/Data/OldList.hs - libraries/base/GHC/List.hs - libraries/base/changelog.md - m4/fp_find_libdw.m4 - m4/ghc_llvm_target.m4 - rts/.gitignore - + rts/configure.ac - rts/posix/OSThreads.c - rts/rts.cabal.in - rts/sm/NonMoving.c - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.asm - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.hs - testsuite/tests/codeGen/should_gen_asm/all.T - testsuite/tests/rts/pause-resume/pause_resume.c Changes: ===================================== boot ===================================== @@ -63,7 +63,7 @@ def autoreconf(): else: reconf_cmd = 'autoreconf' - for dir_ in ['.'] + glob.glob('libraries/*/'): + for dir_ in ['.', 'rts'] + glob.glob('libraries/*/'): if os.path.isfile(os.path.join(dir_, 'configure.ac')): print("Booting %s" % dir_) # Update config.sub in submodules ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -1048,29 +1048,10 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps -------------------- add_code :: Width -> CmmExpr -> CmmExpr -> NatM Register - -- x + imm add_code rep x (CmmLit (CmmInt y _)) | is32BitInteger y , rep /= W8 -- LEA doesn't support byte size (#18614) = add_int rep x y - -- x + (y << imm) - add_code rep x y - -- Byte size is not supported and 16bit size is slow when computed via LEA - | rep /= W8 && rep /= W16 - -- 2^3 = 8 is the highest multiplicator supported by LEA. - , Just (x,y,shift_bits) <- get_shift x y - = add_shiftL rep x y (fromIntegral shift_bits) - where - -- x + (y << imm) - get_shift x (CmmMachOp (MO_Shl _w) [y, CmmLit (CmmInt shift_bits _)]) - | shift_bits <= 3 - = Just (x, y, shift_bits) - -- (y << imm) + x - get_shift (CmmMachOp (MO_Shl _w) [y, CmmLit (CmmInt shift_bits _)]) x - | shift_bits <= 3 - = Just (x, y, shift_bits) - get_shift _ _ - = Nothing add_code rep x y = trivialCode rep (ADD format) (Just (ADD format)) x y where format = intFormat rep -- TODO: There are other interesting patterns we want to replace @@ -1085,7 +1066,6 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps sub_code rep x y = trivialCode rep (SUB (intFormat rep)) Nothing x y -- our three-operand add instruction: - add_int :: (Width -> CmmExpr -> Integer -> NatM Register) add_int width x y = do (x_reg, x_code) <- getSomeReg x let @@ -1099,22 +1079,6 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps -- return (Any format code) - -- x + (y << shift_bits) using LEA - add_shiftL :: (Width -> CmmExpr -> CmmExpr -> Int -> NatM Register) - add_shiftL width x y shift_bits = do - (x_reg, x_code) <- getSomeReg x - (y_reg, y_code) <- getSomeReg y - let - format = intFormat width - imm = ImmInt 0 - code dst - = (x_code `appOL` y_code) `snocOL` - LEA format - (OpAddr (AddrBaseIndex (EABaseReg x_reg) (EAIndex y_reg (2 ^ shift_bits)) imm)) - (OpReg dst) - -- - return (Any format code) - ---------------------- -- See Note [DIV/IDIV for bytes] ===================================== compiler/GHC/Parser.y ===================================== @@ -540,8 +540,9 @@ importdecls This might seem like an awfully roundabout way to declare a list; plus, to add insult to injury you have to reverse the results at the end. The answer is that left recursion prevents us from running out of stack space when parsing long -sequences. See: https://www.haskell.org/happy/doc/html/sec-sequences.html for -more guidance. +sequences. See: +https://haskell-happy.readthedocs.io/en/latest/using.html#parsing-sequences +for more guidance. By adding/removing branches, you can affect what lists are accepted. Here are the most common patterns, rewritten as regular expressions for clarity: ===================================== configure.ac ===================================== @@ -667,6 +667,8 @@ GHC_LLVM_TARGET_SET_VAR # we intend to pass trough --targets to llvm as is. LLVMTarget_CPP=` echo "$LlvmTarget"` AC_SUBST(LLVMTarget_CPP) +# The target is substituted into the distrib/configure.ac file +AC_SUBST(LlvmTarget) dnl ** See whether cc supports --target= and set dnl CONF_CC_OPTS_STAGE[012] accordingly. ===================================== distrib/configure.ac.in ===================================== @@ -18,6 +18,8 @@ dnl-------------------------------------------------------------------- dnl Various things from the source distribution configure bootstrap_target=@TargetPlatform@ +bootstrap_llvm_target=@LlvmTarget@ + TargetHasRTSLinker=@TargetHasRTSLinker@ AC_SUBST(TargetHasRTSLinker) @@ -169,6 +171,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG # Stage 3 won't be supported by cross-compilation FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) +FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) +FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + AC_SUBST(CONF_CC_OPTS_STAGE0) AC_SUBST(CONF_CC_OPTS_STAGE1) AC_SUBST(CONF_CC_OPTS_STAGE2) ===================================== hadrian/src/Base.hs ===================================== @@ -20,9 +20,6 @@ module Base ( module Stage, module Way, - -- * Files - configH, - -- * Paths hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, @@ -72,11 +69,6 @@ configFile = configPath -/- "system.config" sourcePath :: FilePath sourcePath = hadrianPath -/- "src" --- TODO: Change @mk/config.h@ to @shake-build/cfg/config.h at . --- | Path to the generated @mk/config.h@ file. -configH :: FilePath -configH = "mk/config.h" - -- | The directory in 'buildRoot' containing the Shake database and other -- auxiliary files generated by Hadrian. shakeFilesDir :: FilePath ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -147,7 +147,8 @@ generatePackageCode context@(Context stage pkg _ _) = do root -/- "**" -/- dir -/- "cmm/AutoApply.cmm" %> \file -> build $ target context GenApply [] [file] let go gen file = generate file (semiEmptyTarget stage) gen - root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> go generateGhcAutoconfH + root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> \_ -> + need . pure =<< pkgSetupConfigFile context root -/- "**" -/- dir -/- "include/ghcplatform.h" %> go generateGhcPlatformH root -/- "**" -/- dir -/- "include/DerivedConstants.h" %> genPlatformConstantsHeader context root -/- "**" -/- dir -/- "include/rts/EventLogConstants.h" %> genEventTypes "--event-types-defines" @@ -486,26 +487,6 @@ generateConfigHs = do stageString (Stage0 GlobalLibs) = error "stageString: StageBoot" --- | Generate @ghcautoconf.h@ header. -generateGhcAutoconfH :: Expr String -generateGhcAutoconfH = do - trackGenerateHs - configHContents <- expr $ mapMaybe undefinePackage <$> readFileLines configH - return . unlines $ - [ "#if !defined(__GHCAUTOCONF_H__)" - , "#define __GHCAUTOCONF_H__" ] - ++ configHContents ++ - [ "#endif /* __GHCAUTOCONF_H__ */" ] - where - undefinePackage s - | "#define PACKAGE_" `isPrefixOf` s - = Just $ "/* #undef " ++ takeWhile (/=' ') (drop 8 s) ++ " */" - | "#define __GLASGOW_HASKELL" `isPrefixOf` s - = Nothing - | "/* REMOVE ME */" == s - = Nothing - | otherwise = Just s - -- | Generate @Version.hs@ files. generateVersionHs :: Expr String generateVersionHs = do ===================================== hadrian/src/Rules/Lint.hs ===================================== @@ -11,13 +11,15 @@ lintRules :: Rules () lintRules = do "lint:base" ~> lint base "lint:compiler" ~> lint compiler + + -- Ensure that autoconf scripts, which are usually run by Cabal, are run to + -- avoid depending upon Cabal from the stage0 compiler.. "libraries" -/- "base" -/- "include" -/- "HsBaseConfig.h" %> \_ -> -- ./configure is called here manually because we need to generate -- HsBaseConfig.h, which is created from HsBaseConfig.h.in. ./configure - -- is usually run by Cabal which generates this file but if we do that - -- then hadrian thinks it needs to build the stage0 compiler before - -- attempting to configure. Therefore we just run it directly here. cmd_ (Cwd "libraries/base") "./configure" + "rts" -/- "include" -/- "ghcautoconf.h" %> \_ -> + cmd_ (Cwd "rts") "./configure" lint :: Action () -> Action () lint lintAction = do ===================================== hadrian/src/Rules/Register.hs ===================================== @@ -48,11 +48,9 @@ configurePackageRules = do when (pkg == rts) $ do -- Rts.h is a header listed in the cabal file, and configuring -- therefore wants to ensure that the header "works" post-configure. - -- But it (transitively) includes these, so we must ensure they exist + -- But it (transitively) includes this, so we must ensure it exists -- for that check to work. - need [ buildP -/- "include/ghcautoconf.h" - , buildP -/- "include/ghcplatform.h" - ] + need [buildP -/- "include/ghcplatform.h"] Cabal.configurePackage ctx root -/- "**/autogen/cabal_macros.h" %> \out -> do ===================================== hadrian/src/Rules/SourceDist.hs ===================================== @@ -142,7 +142,9 @@ prepareTree dest = do moveFile (dest -/- "boot") (dest -/- "boot.source") bootFiles = - [ pkgPath process -/- "include" -/- "HsProcessConfig.h.in" + [ pkgPath rts -/- "configure" + , pkgPath rts -/- "ghcautoconf.h.autoconf.in" + , pkgPath process -/- "include" -/- "HsProcessConfig.h.in" , pkgPath process -/- "configure" , pkgPath ghcBignum -/- "configure" , pkgPath base -/- "configure" ===================================== libraries/base/.gitignore ===================================== @@ -19,4 +19,3 @@ /include/EventConfig.h /include/HsBaseConfig.h /include/HsBaseConfig.h.in - ===================================== libraries/base/Data/List.hs ===================================== @@ -127,6 +127,7 @@ module Data.List -- | These functions treat a list @xs@ as a indexed collection, -- with indices ranging from 0 to @'length' xs - 1 at . + , (!?) , (!!) , elemIndex ===================================== libraries/base/Data/OldList.hs ===================================== @@ -127,6 +127,7 @@ module Data.OldList -- | These functions treat a list @xs@ as a indexed collection, -- with indices ranging from 0 to @'length' xs - 1 at . + , (!?) , (!!) , elemIndex ===================================== libraries/base/GHC/List.hs ===================================== @@ -31,7 +31,7 @@ module GHC.List ( -- Other functions foldl1', concat, concatMap, map, (++), filter, lookup, - head, last, tail, init, uncons, (!!), + head, last, tail, init, uncons, (!?), (!!), scanl, scanl1, scanl', scanr, scanr1, iterate, iterate', repeat, replicate, cycle, take, drop, splitAt, takeWhile, dropWhile, span, break, reverse, @@ -49,7 +49,7 @@ import GHC.Num (Num(..)) import GHC.Num.Integer (Integer) import GHC.Stack.Types (HasCallStack) -infixl 9 !! +infixl 9 !?, !! infix 4 `elem`, `notElem` -- $setup @@ -1370,9 +1370,10 @@ concat = foldr (++) [] -- >>> ['a', 'b', 'c'] !! (-1) -- *** Exception: Prelude.!!: negative index -- --- WARNING: This function is partial. You can use --- --- instead. +-- WARNING: This function is partial, and should only be used if you are +-- sure that the indexing will not fail. Otherwise, use 'Data.List.!?'. +-- +-- WARNING: This function takes linear time in the index. #if defined(USE_REPORT_PRELUDE) (!!) :: [a] -> Int -> a xs !! n | n < 0 = errorWithoutStackTrace "Prelude.!!: negative index" @@ -1401,6 +1402,30 @@ xs !! n _ -> r (k-1)) tooLarge xs n #endif +-- | List index (subscript) operator, starting from 0. Returns 'Nothing' +-- if the index is out of bounds +-- +-- >>> ['a', 'b', 'c'] !? 0 +-- Just 'a' +-- >>> ['a', 'b', 'c'] !? 2 +-- Just 'c' +-- >>> ['a', 'b', 'c'] !? 3 +-- Nothing +-- >>> ['a', 'b', 'c'] !? (-1) +-- Nothing +-- +-- This is the total variant of the partial '!!' operator. +-- +-- WARNING: This function takes linear time in the index. +(!?) :: [a] -> Int -> Maybe a + +{-# INLINABLE (!?) #-} +xs !? n + | n < 0 = Nothing + | otherwise = foldr (\x r k -> case k of + 0 -> Just x + _ -> r (k-1)) (const Nothing) xs n + -------------------------------------------------------------- -- The zip family -------------------------------------------------------------- ===================================== libraries/base/changelog.md ===================================== @@ -58,6 +58,8 @@ 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`. + * Add `Data.List.!?` per + [CLC proposal #110](https://github.com/haskell/core-libraries-committee/issues/110). ## 4.17.0.0 *August 2022* ===================================== m4/fp_find_libdw.m4 ===================================== @@ -48,9 +48,6 @@ AC_DEFUN([FP_FIND_LIBDW], AC_SUBST(UseLibdw) if test $UseLibdw = "YES" ; then USE_LIBDW=1 - AC_SUBST([CabalHaveLibdw],[True]) - else - AC_SUBST([CabalHaveLibdw],[False]) fi AC_DEFINE_UNQUOTED([USE_LIBDW], [$USE_LIBDW], [Set to 1 to use libdw]) ]) ===================================== m4/ghc_llvm_target.m4 ===================================== @@ -50,5 +50,10 @@ AC_DEFUN([GHC_LLVM_TARGET], [ # require it. AC_DEFUN([GHC_LLVM_TARGET_SET_VAR], [ AC_REQUIRE([FPTOOLS_SET_PLATFORMS_VARS]) - GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + if test "$bootstrap_llvm_target" != "" + then + LlvmTarget=$bootstrap_llvm_target + else + GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + fi ]) ===================================== rts/.gitignore ===================================== @@ -12,7 +12,12 @@ /package.conf.install.raw /fs.* +/aclocal.m4 /autom4te.cache/ /config.log /config.status /configure + +/ghcautoconf.h.autoconf.in +/ghcautoconf.h.autoconf +/include/ghcautoconf.h ===================================== rts/configure.ac ===================================== @@ -0,0 +1,57 @@ +# Configure script template for the Run-time System of GHC +# +# Process with 'autoreconf' to get a working configure script. +# +# For the generated configure script, do "./configure --help" to +# see what flags are available. (Better yet, read the documentation!) +# + +AC_INIT([GHC run-time system], [1.0.2], [libraries at haskell.org], [rts]) + +AC_CONFIG_MACRO_DIRS([../m4]) + +# Safety check: Ensure that we are in the correct source directory. +AC_CONFIG_SRCDIR([include/rts/Constants.h]) + +dnl * We require autoconf version 2.69 due to +dnl https://bugs.ruby-lang.org/issues/8179. Also see #14910. +dnl * We need 2.50 due to the use of AC_SYS_LARGEFILE and AC_MSG_NOTICE. +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.69]) + +AC_CONFIG_HEADERS([ghcautoconf.h.autoconf]) + +# We have to run these unconditionally, but we may discard their +# results in the following code +AC_CANONICAL_BUILD +AC_CANONICAL_HOST + +GHC_CONVERT_PLATFORM_PARTS([host], [Host]) +FPTOOLS_SET_PLATFORM_VARS([host], [Host]) +FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host]) + +AC_OUTPUT + +dnl ###################################################################### +dnl Generate ghcautoconf.h +dnl ###################################################################### + +[ +mkdir -p include +touch include/ghcautoconf.h +> include/ghcautoconf.h + +echo "#if !defined(__GHCAUTOCONF_H__)" >> include/ghcautoconf.h +echo "#define __GHCAUTOCONF_H__" >> include/ghcautoconf.h +# Copy the contents of $srcdir/../mk/config.h, turning '#define PACKAGE_FOO +# "blah"' into '/* #undef PACKAGE_FOO */' to avoid clashes. +cat $srcdir/../mk/config.h ghcautoconf.h.autoconf | sed \ + -e 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$,\1/* #undef \2 */,' \ + -e '/__GLASGOW_HASKELL/d' \ + -e '/REMOVE ME/d' \ + >> include/ghcautoconf.h +echo "#endif /* __GHCAUTOCONF_H__ */" >> include/ghcautoconf.h +] ===================================== rts/posix/OSThreads.c ===================================== @@ -218,6 +218,12 @@ start_thread (void *param) return startProc(startParam); } +/* Note: at least on Linux/Glibc, `pthread_setname_np` restricts the name of + * a thread to 16 bytes, including the terminating null byte. Hence, make sure + * to only pass in names of up to 15 characters. Otherwise, + * `pthread_setname_np` when called in `start_thread` will fail with `ERANGE`, + * which is not checked for, and the thread won't be named at all. + */ int createOSThread (OSThreadId* pId, const char *name, OSThreadProc *startProc, void *param) ===================================== rts/rts.cabal.in ===================================== @@ -1,9 +1,24 @@ cabal-version: 3.0 name: rts version: 1.0.2 +synopsis: The GHC runtime system +description: + The GHC runtime system. + + Code produced by GHC links this library to provide missing functionality + that cannot be written in Haskell itself. license: BSD-3-Clause maintainer: glasgow-haskell-users at haskell.org -build-type: Simple +build-type: Configure + +extra-source-files: + configure + configure.ac + +extra-tmp-files: + autom4te.cache + config.log + config.status source-repository head type: git @@ -206,6 +221,7 @@ library include-dirs: include includes: Rts.h + autogen-includes: ghcautoconf.h install-includes: Cmm.h HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h -- ^ from include ===================================== rts/sm/NonMoving.c ===================================== @@ -1015,7 +1015,7 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) nonmoving_write_barrier_enabled = true; debugTrace(DEBUG_nonmoving_gc, "Starting concurrent mark thread"); OSThreadId thread; - if (createOSThread(&thread, "non-moving mark thread", + if (createOSThread(&thread, "nonmoving-mark", nonmovingConcurrentMark, mark_queue) != 0) { barf("nonmovingCollect: failed to spawn mark thread: %s", strerror(errno)); } ===================================== testsuite/tests/codeGen/should_gen_asm/AddMulX86.asm deleted ===================================== @@ -1,46 +0,0 @@ -.section .text -.align 8 -.align 8 - .quad 8589934604 - .quad 0 - .long 14 - .long 0 -.globl AddMulX86_f_info -.type AddMulX86_f_info, @function -AddMulX86_f_info: -.LcAx: - leaq (%r14,%rsi,8),%rbx - jmp *(%rbp) - .size AddMulX86_f_info, .-AddMulX86_f_info -.section .data -.align 8 -.align 1 -.globl AddMulX86_f_closure -.type AddMulX86_f_closure, @object -AddMulX86_f_closure: - .quad AddMulX86_f_info -.section .text -.align 8 -.align 8 - .quad 8589934604 - .quad 0 - .long 14 - .long 0 -.globl AddMulX86_g_info -.type AddMulX86_g_info, @function -AddMulX86_g_info: -.LcAL: - leaq (%r14,%rsi,8),%rbx - jmp *(%rbp) - .size AddMulX86_g_info, .-AddMulX86_g_info -.section .data -.align 8 -.align 1 -.globl AddMulX86_g_closure -.type AddMulX86_g_closure, @object -AddMulX86_g_closure: - .quad AddMulX86_g_info -.section .note.GNU-stack,"", at progbits -.ident "GHC 9.3.20220228" - - ===================================== testsuite/tests/codeGen/should_gen_asm/AddMulX86.hs deleted ===================================== @@ -1,12 +0,0 @@ -{-# LANGUAGE MagicHash #-} - -module AddMulX86 where - -import GHC.Exts - -f :: Int# -> Int# -> Int# -f x y = - x +# (y *# 8#) -- Should result in a lea instruction, which we grep the assembly output for. - -g x y = - (y *# 8#) +# x -- Should result in a lea instruction, which we grep the assembly output for. ===================================== testsuite/tests/codeGen/should_gen_asm/all.T ===================================== @@ -10,4 +10,3 @@ test('memset-unroll', is_amd64_codegen, compile_cmp_asm, ['cmm', '']) test('bytearray-memset-unroll', is_amd64_codegen, compile_grep_asm, ['hs', True, '']) test('bytearray-memcpy-unroll', is_amd64_codegen, compile_grep_asm, ['hs', True, '']) test('T18137', [when(opsys('darwin'), skip), only_ways(llvm_ways)], compile_grep_asm, ['hs', False, '-fllvm -split-sections']) -test('AddMulX86', is_amd64_codegen, compile_cmp_asm, ['hs', '-dno-typeable-binds']) ===================================== testsuite/tests/rts/pause-resume/pause_resume.c ===================================== @@ -187,7 +187,7 @@ void pauseAndResumeViaThread ) { OSThreadId threadId; - createOSThread(&threadId, "Pause and resume thread", &pauseAndResumeViaThread_helper, (void *)count); + createOSThread(&threadId, "pause-resume", &pauseAndResumeViaThread_helper, (void *)count); } const int TIMEOUT = 1000000; // 1 second View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/65a07527316b1cfef564b62cbc809c118b3973ff...5a763d8c5126c4b42b4508f69bb55d7b3dbdb423 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/65a07527316b1cfef564b62cbc809c118b3973ff...5a763d8c5126c4b42b4508f69bb55d7b3dbdb423 You're receiving 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 Jan 10 08:08:36 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 10 Jan 2023 03:08:36 -0500 Subject: [Git][ghc/ghc][ghc-9.6] 4 commits: Revert "NCG(x86): Compile add+shift as lea if possible." Message-ID: <63bd1d04431e2_3b1bf95632437989a@gitlab.mail> Matthew Pickering pushed to branch ghc-9.6 at Glasgow Haskell Compiler / GHC Commits: 548380ea by Matthew Pickering at 2023-01-09T12:03:07+00:00 Revert "NCG(x86): Compile add+shift as lea if possible." This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a. See #22666 and #21777 - - - - - 48a9e688 by Matthew Pickering at 2023-01-10T08:07:45+00:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 (cherry picked from commit 64286132cc0db4e227637887f98f5a3ecf7d326a) - - - - - 2a7c7fa7 by Matthew Pickering at 2023-01-10T08:07:45+00:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. This completes the fix for #22429 (cherry picked from commit 4724e8d1a66fa0a821d322d9d2d90db7d7604916) - - - - - 6db7d9da by Sebastian Graf at 2023-01-10T08:07:59+00:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite (cherry picked from commit e3fff7512bbf989386faaa1dccafdad1deabde84) - - - - - 8 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/Opt/DmdAnal.hs - configure.ac - distrib/configure.ac.in - m4/ghc_llvm_target.m4 - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.asm - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.hs - testsuite/tests/codeGen/should_gen_asm/all.T Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -1048,29 +1048,10 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps -------------------- add_code :: Width -> CmmExpr -> CmmExpr -> NatM Register - -- x + imm add_code rep x (CmmLit (CmmInt y _)) | is32BitInteger y , rep /= W8 -- LEA doesn't support byte size (#18614) = add_int rep x y - -- x + (y << imm) - add_code rep x y - -- Byte size is not supported and 16bit size is slow when computed via LEA - | rep /= W8 && rep /= W16 - -- 2^3 = 8 is the highest multiplicator supported by LEA. - , Just (x,y,shift_bits) <- get_shift x y - = add_shiftL rep x y (fromIntegral shift_bits) - where - -- x + (y << imm) - get_shift x (CmmMachOp (MO_Shl _w) [y, CmmLit (CmmInt shift_bits _)]) - | shift_bits <= 3 - = Just (x, y, shift_bits) - -- (y << imm) + x - get_shift (CmmMachOp (MO_Shl _w) [y, CmmLit (CmmInt shift_bits _)]) x - | shift_bits <= 3 - = Just (x, y, shift_bits) - get_shift _ _ - = Nothing add_code rep x y = trivialCode rep (ADD format) (Just (ADD format)) x y where format = intFormat rep -- TODO: There are other interesting patterns we want to replace @@ -1085,7 +1066,6 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps sub_code rep x y = trivialCode rep (SUB (intFormat rep)) Nothing x y -- our three-operand add instruction: - add_int :: (Width -> CmmExpr -> Integer -> NatM Register) add_int width x y = do (x_reg, x_code) <- getSomeReg x let @@ -1099,22 +1079,6 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps -- return (Any format code) - -- x + (y << shift_bits) using LEA - add_shiftL :: (Width -> CmmExpr -> CmmExpr -> Int -> NatM Register) - add_shiftL width x y shift_bits = do - (x_reg, x_code) <- getSomeReg x - (y_reg, y_code) <- getSomeReg y - let - format = intFormat width - imm = ImmInt 0 - code dst - = (x_code `appOL` y_code) `snocOL` - LEA format - (OpAddr (AddrBaseIndex (EABaseReg x_reg) (EAIndex y_reg (2 ^ shift_bits)) imm)) - (OpReg dst) - -- - return (Any format code) - ---------------------- -- See Note [DIV/IDIV for bytes] ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -333,7 +333,8 @@ dmdAnalBindLetUp :: TopLevelFlag -> WithDmdType (DmdResult CoreBind a) dmdAnalBindLetUp top_lvl env id rhs anal_body = WithDmdType final_ty (R (NonRec id' rhs') (body')) where - WithDmdType body_ty body' = anal_body env + WithDmdType body_ty body' = anal_body (addInScopeAnalEnv env id) + -- See Note [Bringing a new variable into scope] WithDmdType body_ty' id_dmd = findBndrDmd env body_ty id -- See Note [Finalising boxity for demand signatures] @@ -473,7 +474,8 @@ dmdAnal' env dmd (App fun arg) dmdAnal' env dmd (Lam var body) | isTyVar var = let - WithDmdType body_ty body' = dmdAnal env dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) dmd body + -- See Note [Bringing a new variable into scope] in WithDmdType body_ty (Lam var body') @@ -481,7 +483,8 @@ dmdAnal' env dmd (Lam var body) = let (n, body_dmd) = peelCallDmd dmd -- body_dmd: a demand to analyze the body - WithDmdType body_ty body' = dmdAnal env body_dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) body_dmd body + -- See Note [Bringing a new variable into scope] WithDmdType lam_ty var' = annotateLamIdBndr env body_ty var new_dmd_type = multDmdType n lam_ty in @@ -493,7 +496,9 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt_con bndrs rhs]) -- can consider its field demands when analysing the scrutinee. | want_precise_field_dmds alt_con = let - WithDmdType rhs_ty rhs' = dmdAnal env dmd rhs + rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + WithDmdType rhs_ty rhs' = dmdAnal rhs_env dmd rhs WithDmdType alt_ty1 fld_dmds = findBndrsDmds env rhs_ty bndrs WithDmdType alt_ty2 case_bndr_dmd = findBndrDmd env alt_ty1 case_bndr !case_bndr' = setIdDemandInfo case_bndr case_bndr_dmd @@ -629,7 +634,9 @@ dmdAnalSumAlts env dmd case_bndr (alt:alts) dmdAnalSumAlt :: AnalEnv -> SubDemand -> Id -> CoreAlt -> WithDmdType CoreAlt dmdAnalSumAlt env dmd case_bndr (Alt con bndrs rhs) - | WithDmdType rhs_ty rhs' <- dmdAnal env dmd rhs + | let rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + , WithDmdType rhs_ty rhs' <- dmdAnal rhs_env dmd rhs , WithDmdType alt_ty dmds <- findBndrsDmds env rhs_ty bndrs , let (_ :* case_bndr_sd) = findIdDemand alt_ty case_bndr -- See Note [Demand on case-alternative binders] @@ -2399,7 +2406,7 @@ enterDFun bind env emptySigEnv :: SigEnv emptySigEnv = emptyVarEnv --- | Extend an environment with the strictness IDs attached to the id +-- | Extend an environment with the strictness sigs attached to the Ids extendAnalEnvs :: TopLevelFlag -> AnalEnv -> [Id] -> AnalEnv extendAnalEnvs top_lvl env vars = env { ae_sigs = extendSigEnvs top_lvl (ae_sigs env) vars } @@ -2418,6 +2425,12 @@ extendSigEnv top_lvl sigs var sig = extendVarEnv sigs var (sig, top_lvl) lookupSigEnv :: AnalEnv -> Id -> Maybe (DmdSig, TopLevelFlag) lookupSigEnv env id = lookupVarEnv (ae_sigs env) id +addInScopeAnalEnv :: AnalEnv -> Var -> AnalEnv +addInScopeAnalEnv env id = env { ae_sigs = delVarEnv (ae_sigs env) id } + +addInScopeAnalEnvs :: AnalEnv -> [Var] -> AnalEnv +addInScopeAnalEnvs env ids = env { ae_sigs = delVarEnvList (ae_sigs env) ids } + nonVirgin :: AnalEnv -> AnalEnv nonVirgin env = env { ae_virgin = False } @@ -2456,7 +2469,18 @@ findBndrDmd env dmd_ty id fam_envs = ae_fam_envs env -{- Note [Making dictionary parameters strict] +{- Note [Bringing a new variable into scope] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + f x = blah + g = ...(\f. ...f...)... + +In the body of the '\f', any occurrence of `f` refers to the lambda-bound `f`, +not the top-level `f` (which will be in `ae_sigs`). So it's very important +to delete `f` from `ae_sigs` when we pass a lambda/case/let-up binding of `f`. +Otherwise chaos results (#22718). + +Note [Making dictionary parameters strict] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? ===================================== configure.ac ===================================== @@ -667,6 +667,8 @@ GHC_LLVM_TARGET_SET_VAR # we intend to pass trough --targets to llvm as is. LLVMTarget_CPP=` echo "$LlvmTarget"` AC_SUBST(LLVMTarget_CPP) +# The target is substituted into the distrib/configure.ac file +AC_SUBST(LlvmTarget) dnl ** See whether cc supports --target= and set dnl CONF_CC_OPTS_STAGE[012] accordingly. ===================================== distrib/configure.ac.in ===================================== @@ -18,6 +18,8 @@ dnl-------------------------------------------------------------------- dnl Various things from the source distribution configure bootstrap_target=@TargetPlatform@ +bootstrap_llvm_target=@LlvmTarget@ + TargetHasRTSLinker=@TargetHasRTSLinker@ AC_SUBST(TargetHasRTSLinker) @@ -169,6 +171,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG # Stage 3 won't be supported by cross-compilation FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) +FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) +FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + AC_SUBST(CONF_CC_OPTS_STAGE0) AC_SUBST(CONF_CC_OPTS_STAGE1) AC_SUBST(CONF_CC_OPTS_STAGE2) ===================================== m4/ghc_llvm_target.m4 ===================================== @@ -50,5 +50,10 @@ AC_DEFUN([GHC_LLVM_TARGET], [ # require it. AC_DEFUN([GHC_LLVM_TARGET_SET_VAR], [ AC_REQUIRE([FPTOOLS_SET_PLATFORMS_VARS]) - GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + if test "$bootstrap_llvm_target" != "" + then + LlvmTarget=$bootstrap_llvm_target + else + GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + fi ]) ===================================== testsuite/tests/codeGen/should_gen_asm/AddMulX86.asm deleted ===================================== @@ -1,46 +0,0 @@ -.section .text -.align 8 -.align 8 - .quad 8589934604 - .quad 0 - .long 14 - .long 0 -.globl AddMulX86_f_info -.type AddMulX86_f_info, @function -AddMulX86_f_info: -.LcAx: - leaq (%r14,%rsi,8),%rbx - jmp *(%rbp) - .size AddMulX86_f_info, .-AddMulX86_f_info -.section .data -.align 8 -.align 1 -.globl AddMulX86_f_closure -.type AddMulX86_f_closure, @object -AddMulX86_f_closure: - .quad AddMulX86_f_info -.section .text -.align 8 -.align 8 - .quad 8589934604 - .quad 0 - .long 14 - .long 0 -.globl AddMulX86_g_info -.type AddMulX86_g_info, @function -AddMulX86_g_info: -.LcAL: - leaq (%r14,%rsi,8),%rbx - jmp *(%rbp) - .size AddMulX86_g_info, .-AddMulX86_g_info -.section .data -.align 8 -.align 1 -.globl AddMulX86_g_closure -.type AddMulX86_g_closure, @object -AddMulX86_g_closure: - .quad AddMulX86_g_info -.section .note.GNU-stack,"", at progbits -.ident "GHC 9.3.20220228" - - ===================================== testsuite/tests/codeGen/should_gen_asm/AddMulX86.hs deleted ===================================== @@ -1,12 +0,0 @@ -{-# LANGUAGE MagicHash #-} - -module AddMulX86 where - -import GHC.Exts - -f :: Int# -> Int# -> Int# -f x y = - x +# (y *# 8#) -- Should result in a lea instruction, which we grep the assembly output for. - -g x y = - (y *# 8#) +# x -- Should result in a lea instruction, which we grep the assembly output for. ===================================== testsuite/tests/codeGen/should_gen_asm/all.T ===================================== @@ -10,4 +10,3 @@ test('memset-unroll', is_amd64_codegen, compile_cmp_asm, ['cmm', '']) test('bytearray-memset-unroll', is_amd64_codegen, compile_grep_asm, ['hs', True, '']) test('bytearray-memcpy-unroll', is_amd64_codegen, compile_grep_asm, ['hs', True, '']) test('T18137', [when(opsys('darwin'), skip), only_ways(llvm_ways)], compile_grep_asm, ['hs', False, '-fllvm -split-sections']) -test('AddMulX86', is_amd64_codegen, compile_cmp_asm, ['hs', '-dno-typeable-binds']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a587499c6dc8a7e7e646e9c5f246903a4cc99e56...6db7d9da21854fa9decaf6e49f7d4f6c45f70883 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a587499c6dc8a7e7e646e9c5f246903a4cc99e56...6db7d9da21854fa9decaf6e49f7d4f6c45f70883 You're receiving 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 Jan 10 08:31:43 2023 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Tue, 10 Jan 2023 03:31:43 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/ci-codeowners Message-ID: <63bd226ff100c_3b1bf95262038159b@gitlab.mail> Bryan R pushed new branch wip/ci-codeowners at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ci-codeowners You're receiving 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 Jan 10 08:52:40 2023 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Tue, 10 Jan 2023 03:52:40 -0500 Subject: [Git][ghc/ghc][wip/ci-codeowners] 35 commits: Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Message-ID: <63bd27588777e_3b1bf95632438958e@gitlab.mail> Bryan R pushed to branch wip/ci-codeowners at Glasgow Haskell Compiler / GHC Commits: 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - 541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - 28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00 Add support for sized literals in the bytecode interpreter. The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945 - - - - - ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00 rts: MUT_VAR is not a StgMutArrPtrs There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs. - - - - - 6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s - - - - - 73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. - - - - - 8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 5d65773e by John Ericson at 2023-01-09T20:39:27-05:00 Remove RTS hack for configuring See the brand new Note [Undefined symbols in the RTS] for additional details. - - - - - e3fff751 by Sebastian Graf at 2023-01-09T20:40:02-05:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - d53f6f4d by Oleg Grenrus at 2023-01-09T21:11:02-05:00 Add safe list indexing operator: !? With Joachim's amendments. Implements https://github.com/haskell/core-libraries-committee/issues/110 - - - - - cfaf1ad7 by Nicolas Trangez at 2023-01-09T21:11:03-05:00 rts, tests: limit thread name length to 15 bytes On Linux, `pthread_setname_np` (or rather, the kernel) only allows for thread names up to 16 bytes, including the terminating null byte. This commit adds a note pointing this out in `createOSThread`, and fixes up two instances where a thread name of more than 15 characters long was used (in the RTS, and in a test-case). Fixes: #22366 Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796 - - - - - 64286132 by Matthew Pickering at 2023-01-09T21:11:03-05:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 4724e8d1 by Matthew Pickering at 2023-01-09T21:11:04-05:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. This completes the fix for #22429 - - - - - 2e926b88 by Georgi Lyubenov at 2023-01-09T21:11:07-05:00 Fix outdated link to Happy section on sequences - - - - - 146a1458 by Matthew Pickering at 2023-01-09T21:11:07-05:00 Revert "NCG(x86): Compile add+shift as lea if possible." This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a. See #22666 and #21777 - - - - - c5ab3400 by Bryan Richter at 2023-01-10T10:52:29+02:00 Add Bryan and Ben as CI codeowners - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - CODEOWNERS - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Data/EnumSet.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/DocString.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Binds.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd5800ad458b1ac6c4b102c92089445914a48325...c5ab3400590293c203b0160cbad6bf5f2cedb018 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd5800ad458b1ac6c4b102c92089445914a48325...c5ab3400590293c203b0160cbad6bf5f2cedb018 You're receiving 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 Jan 10 10:06:32 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 10 Jan 2023 05:06:32 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22502 Message-ID: <63bd38a897bd7_3b1bf956324419145@gitlab.mail> Simon Peyton Jones pushed new branch wip/T22502 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22502 You're receiving 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 Jan 10 10:12:10 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 10 Jan 2023 05:12:10 -0500 Subject: [Git][ghc/ghc][wip/T22725] 9 commits: Remove RTS hack for configuring Message-ID: <63bd39fa3852a_3b1bf956324428957@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22725 at Glasgow Haskell Compiler / GHC Commits: 5d65773e by John Ericson at 2023-01-09T20:39:27-05:00 Remove RTS hack for configuring See the brand new Note [Undefined symbols in the RTS] for additional details. - - - - - e3fff751 by Sebastian Graf at 2023-01-09T20:40:02-05:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - d53f6f4d by Oleg Grenrus at 2023-01-09T21:11:02-05:00 Add safe list indexing operator: !? With Joachim's amendments. Implements https://github.com/haskell/core-libraries-committee/issues/110 - - - - - cfaf1ad7 by Nicolas Trangez at 2023-01-09T21:11:03-05:00 rts, tests: limit thread name length to 15 bytes On Linux, `pthread_setname_np` (or rather, the kernel) only allows for thread names up to 16 bytes, including the terminating null byte. This commit adds a note pointing this out in `createOSThread`, and fixes up two instances where a thread name of more than 15 characters long was used (in the RTS, and in a test-case). Fixes: #22366 Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796 - - - - - 64286132 by Matthew Pickering at 2023-01-09T21:11:03-05:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 4724e8d1 by Matthew Pickering at 2023-01-09T21:11:04-05:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. This completes the fix for #22429 - - - - - 2e926b88 by Georgi Lyubenov at 2023-01-09T21:11:07-05:00 Fix outdated link to Happy section on sequences - - - - - 146a1458 by Matthew Pickering at 2023-01-09T21:11:07-05:00 Revert "NCG(x86): Compile add+shift as lea if possible." This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a. See #22666 and #21777 - - - - - 8fa3edde by Simon Peyton Jones at 2023-01-10T10:09:54+00:00 Fix void-arg-adding mechanism for worker/wrapper As #22725 shows, in worker/wrapper we must add the void argument /last/, not first. See GHC.Core.Opt.WorkWrap.Utils Note [Worker/wrapper needs to add void arg last]. That led me to to study GHC.Core.Opt.SpecConstr Note [SpecConstr needs to add void args first] which suggests the opposite! And indeed I think it's the other way round for SpecConstr -- or more precisely the void arg must precede the "extra_bndrs". That led me to some refactoring of GHC.Core.Opt.SpecConstr.calcSpecInfo. - - - - - 27 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Parser.y - configure.ac - distrib/configure.ac.in - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Rules/Register.hs - libraries/base/Data/List.hs - libraries/base/Data/OldList.hs - libraries/base/GHC/List.hs - libraries/base/changelog.md - m4/ghc_llvm_target.m4 - rts/posix/OSThreads.c - rts/rts.cabal.in - rts/sm/NonMoving.c - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.asm - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.hs - testsuite/tests/codeGen/should_gen_asm/all.T - testsuite/tests/rts/pause-resume/pause_resume.c - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/simplCore/should_compile/T18328.stderr - + testsuite/tests/simplCore/should_compile/T22725.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -1048,29 +1048,10 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps -------------------- add_code :: Width -> CmmExpr -> CmmExpr -> NatM Register - -- x + imm add_code rep x (CmmLit (CmmInt y _)) | is32BitInteger y , rep /= W8 -- LEA doesn't support byte size (#18614) = add_int rep x y - -- x + (y << imm) - add_code rep x y - -- Byte size is not supported and 16bit size is slow when computed via LEA - | rep /= W8 && rep /= W16 - -- 2^3 = 8 is the highest multiplicator supported by LEA. - , Just (x,y,shift_bits) <- get_shift x y - = add_shiftL rep x y (fromIntegral shift_bits) - where - -- x + (y << imm) - get_shift x (CmmMachOp (MO_Shl _w) [y, CmmLit (CmmInt shift_bits _)]) - | shift_bits <= 3 - = Just (x, y, shift_bits) - -- (y << imm) + x - get_shift (CmmMachOp (MO_Shl _w) [y, CmmLit (CmmInt shift_bits _)]) x - | shift_bits <= 3 - = Just (x, y, shift_bits) - get_shift _ _ - = Nothing add_code rep x y = trivialCode rep (ADD format) (Just (ADD format)) x y where format = intFormat rep -- TODO: There are other interesting patterns we want to replace @@ -1085,7 +1066,6 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps sub_code rep x y = trivialCode rep (SUB (intFormat rep)) Nothing x y -- our three-operand add instruction: - add_int :: (Width -> CmmExpr -> Integer -> NatM Register) add_int width x y = do (x_reg, x_code) <- getSomeReg x let @@ -1099,22 +1079,6 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps -- return (Any format code) - -- x + (y << shift_bits) using LEA - add_shiftL :: (Width -> CmmExpr -> CmmExpr -> Int -> NatM Register) - add_shiftL width x y shift_bits = do - (x_reg, x_code) <- getSomeReg x - (y_reg, y_code) <- getSomeReg y - let - format = intFormat width - imm = ImmInt 0 - code dst - = (x_code `appOL` y_code) `snocOL` - LEA format - (OpAddr (AddrBaseIndex (EABaseReg x_reg) (EAIndex y_reg (2 ^ shift_bits)) imm)) - (OpReg dst) - -- - return (Any format code) - ---------------------- -- See Note [DIV/IDIV for bytes] ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -333,7 +333,8 @@ dmdAnalBindLetUp :: TopLevelFlag -> WithDmdType (DmdResult CoreBind a) dmdAnalBindLetUp top_lvl env id rhs anal_body = WithDmdType final_ty (R (NonRec id' rhs') (body')) where - WithDmdType body_ty body' = anal_body env + WithDmdType body_ty body' = anal_body (addInScopeAnalEnv env id) + -- See Note [Bringing a new variable into scope] WithDmdType body_ty' id_dmd = findBndrDmd env body_ty id -- See Note [Finalising boxity for demand signatures] @@ -473,7 +474,8 @@ dmdAnal' env dmd (App fun arg) dmdAnal' env dmd (Lam var body) | isTyVar var = let - WithDmdType body_ty body' = dmdAnal env dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) dmd body + -- See Note [Bringing a new variable into scope] in WithDmdType body_ty (Lam var body') @@ -481,7 +483,8 @@ dmdAnal' env dmd (Lam var body) = let (n, body_dmd) = peelCallDmd dmd -- body_dmd: a demand to analyze the body - WithDmdType body_ty body' = dmdAnal env body_dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) body_dmd body + -- See Note [Bringing a new variable into scope] WithDmdType lam_ty var' = annotateLamIdBndr env body_ty var new_dmd_type = multDmdType n lam_ty in @@ -493,7 +496,9 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt_con bndrs rhs]) -- can consider its field demands when analysing the scrutinee. | want_precise_field_dmds alt_con = let - WithDmdType rhs_ty rhs' = dmdAnal env dmd rhs + rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + WithDmdType rhs_ty rhs' = dmdAnal rhs_env dmd rhs WithDmdType alt_ty1 fld_dmds = findBndrsDmds env rhs_ty bndrs WithDmdType alt_ty2 case_bndr_dmd = findBndrDmd env alt_ty1 case_bndr !case_bndr' = setIdDemandInfo case_bndr case_bndr_dmd @@ -629,7 +634,9 @@ dmdAnalSumAlts env dmd case_bndr (alt:alts) dmdAnalSumAlt :: AnalEnv -> SubDemand -> Id -> CoreAlt -> WithDmdType CoreAlt dmdAnalSumAlt env dmd case_bndr (Alt con bndrs rhs) - | WithDmdType rhs_ty rhs' <- dmdAnal env dmd rhs + | let rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + , WithDmdType rhs_ty rhs' <- dmdAnal rhs_env dmd rhs , WithDmdType alt_ty dmds <- findBndrsDmds env rhs_ty bndrs , let (_ :* case_bndr_sd) = findIdDemand alt_ty case_bndr -- See Note [Demand on case-alternative binders] @@ -2399,7 +2406,7 @@ enterDFun bind env emptySigEnv :: SigEnv emptySigEnv = emptyVarEnv --- | Extend an environment with the strictness IDs attached to the id +-- | Extend an environment with the strictness sigs attached to the Ids extendAnalEnvs :: TopLevelFlag -> AnalEnv -> [Id] -> AnalEnv extendAnalEnvs top_lvl env vars = env { ae_sigs = extendSigEnvs top_lvl (ae_sigs env) vars } @@ -2418,6 +2425,12 @@ extendSigEnv top_lvl sigs var sig = extendVarEnv sigs var (sig, top_lvl) lookupSigEnv :: AnalEnv -> Id -> Maybe (DmdSig, TopLevelFlag) lookupSigEnv env id = lookupVarEnv (ae_sigs env) id +addInScopeAnalEnv :: AnalEnv -> Var -> AnalEnv +addInScopeAnalEnv env id = env { ae_sigs = delVarEnv (ae_sigs env) id } + +addInScopeAnalEnvs :: AnalEnv -> [Var] -> AnalEnv +addInScopeAnalEnvs env ids = env { ae_sigs = delVarEnvList (ae_sigs env) ids } + nonVirgin :: AnalEnv -> AnalEnv nonVirgin env = env { ae_virgin = False } @@ -2456,7 +2469,18 @@ findBndrDmd env dmd_ty id fam_envs = ae_fam_envs env -{- Note [Making dictionary parameters strict] +{- Note [Bringing a new variable into scope] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + f x = blah + g = ...(\f. ...f...)... + +In the body of the '\f', any occurrence of `f` refers to the lambda-bound `f`, +not the top-level `f` (which will be in `ae_sigs`). So it's very important +to delete `f` from `ae_sigs` when we pass a lambda/case/let-up binding of `f`. +Otherwise chaos results (#22718). + +Note [Making dictionary parameters strict] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -53,6 +53,7 @@ import GHC.Unit.Module.ModGuts import GHC.Types.Literal ( litIsLifted ) import GHC.Types.Id import GHC.Types.Id.Info ( IdDetails(..) ) +import GHC.Types.Id.Make ( voidArgId, voidPrimId ) import GHC.Types.Var.Env import GHC.Types.Var.Set import GHC.Types.Name @@ -1924,23 +1925,9 @@ spec_one env fn arg_bndrs body (call_pat, rule_number) -- And build the results ; (qvars', pats') <- generaliseDictPats qvars pats - ; let spec_body_ty = exprType spec_body - (spec_lam_args1, spec_sig, spec_arity1, spec_join_arity1) - = calcSpecInfo fn call_pat extra_bndrs - -- Annotate the variables with the strictness information from - -- the function (see Note [Strictness information in worker binders]) - add_void_arg = needsVoidWorkerArg fn arg_bndrs spec_lam_args1 - (spec_lam_args, spec_call_args, spec_arity, spec_join_arity) - | add_void_arg - -- See Note [SpecConstr needs to add void args first] - , (spec_lam_args, spec_call_args, _) <- addVoidWorkerArg spec_lam_args1 [] - -- needsVoidWorkerArg: usual w/w hack to avoid generating - -- a spec_rhs of unlifted type and no args. - , !spec_arity <- spec_arity1 + 1 - , !spec_join_arity <- fmap (+ 1) spec_join_arity1 - = (spec_lam_args, spec_call_args, spec_arity, spec_join_arity) - | otherwise - = (spec_lam_args1, spec_lam_args1, spec_arity1, spec_join_arity1) + ; let spec_body_ty = exprType spec_body + (spec_lam_args, spec_call_args, spec_sig, spec_arity, spec_join_arity) + = calcSpecInfo fn arg_bndrs call_pat extra_bndrs spec_id = asWorkerLikeId $ mkLocalId spec_name ManyTy @@ -1953,11 +1940,7 @@ spec_one env fn arg_bndrs body (call_pat, rule_number) -- Conditionally use result of new worker-wrapper transform spec_rhs = mkLams spec_lam_args (mkSeqs cbv_args spec_body_ty spec_body) - rule_rhs = mkVarApps (Var spec_id) $ - -- This will give us all the arguments we quantify over - -- in the rule plus the void argument if present - -- since `length(qvars) + void + length(extra_bndrs) = length spec_call_args` - dropTail (length extra_bndrs) spec_call_args + rule_rhs = mkVarApps (Var spec_id) spec_call_args inline_act = idInlineActivation fn this_mod = sc_module $ sc_opts env rule = mkRule this_mod True {- Auto -} True {- Local -} @@ -2023,30 +2006,41 @@ mkSeqs seqees res_ty rhs = {- Note [SpecConstr needs to add void args first] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider a function + f :: Bool -> forall t. blah f start @t = e We want to specialize for a partially applied call `f True`. See also Note [SpecConstr call patterns], second Wrinkle. Naively we would expect to get + $sf :: forall t. blah $sf @t = $se RULE: f True = $sf -The specialized function only takes a single type argument -so we add a void argument to prevent it from turning into -a thunk. See Note [Protecting the last value argument] for details -why. Normally we would add the void argument after the -type argument giving us: +The specialized function only takes a single type argument so we add a +void argument to prevent it from turning into a thunk. See Note +[Protecting the last value argument] for details why. Normally we +would add the void argument after the type argument giving us: + $sf :: forall t. Void# -> bla $sf @t void = $se RULE: f True = $sf void# (wrong) -But if you look closely this wouldn't typecheck! -If we substitute `f True` with `$sf void#` we expect the type argument to be applied first -but we apply void# first. -The easiest fix seems to be just to add the void argument to the front of the arguments. -Now we get: + +But if you look closely this wouldn't typecheck! If we substitute `f +True` with `$sf void#` we expect the type argument to be applied first +but we apply void# first. The easiest fix seems to be just to add the +void argument to the front of the arguments. Now we get: + $sf :: Void# -> forall t. bla $sf void @t = $se RULE: f True = $sf void# + And now we can substitute `f True` with `$sf void#` with everything working out nicely! +More preisely, we need the void arg to precede the `extra_bndrs` in +calcSpecInfo, but it's fine it put it before /all/ the arguments. + +Note that putting the extra arg first is exactly from what is needed +in worker/wrapper; see Note [Worker/wrapper needs to add void arg last] +in GHC.Core.Opt.WorkWrap.Utils. + Note [generaliseDictPats] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider these two rules (#21831, item 2): @@ -2076,35 +2070,49 @@ And /now/ "SPEC:foo" is clearly more specific: we can instantiate the new -} calcSpecInfo :: Id -- The original function + -> [InVar] -- Lambda binders of original RHS -> CallPat -- Call pattern -> [Var] -- Extra bndrs - -> ( [Var] -- Demand-decorated binders + -> ( [Var] -- Demand-decorated lambda binders + -- for RHS of specialised function + , [Var] -- Args for call site , DmdSig -- Strictness of specialised thing , Arity, Maybe JoinArity ) -- Arities of specialised thing -- Calculate bits of IdInfo for the specialised function -- See Note [Transfer strictness] -- See Note [Strictness information in worker binders] -calcSpecInfo fn (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs - | isJoinId fn -- Join points have strictness and arity for LHS only - = ( bndrs_w_dmds - , mkClosedDmdSig qvar_dmds div - , count isId qvars - , Just (length qvars) ) +calcSpecInfo fn arg_bndrs (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs + | needsVoidWorkerArg fn arg_bndrs spec_lam_bndrs_w_dmds + = -- Usual w/w hack to avoid generating + -- a spec_rhs of unlifted type and no args. + -- See Note [SpecConstr needs to add void args first] + ( voidArgId : spec_lam_bndrs_w_dmds + , voidPrimId : qvars_w_dmds + , mkClosedDmdSig (topDmd : all_dmds) div + , arity + 1 + , if isJoinId fn then Just (length qvars + 1) else Nothing ) + | otherwise - = ( bndrs_w_dmds - , mkClosedDmdSig (qvar_dmds ++ extra_dmds) div - , count isId qvars + count isId extra_bndrs - , Nothing ) + = ( spec_lam_bndrs_w_dmds + , qvars_w_dmds + , mkClosedDmdSig all_dmds div + , arity + , if isJoinId fn then Just (length qvars) else Nothing ) where DmdSig (DmdType _ fn_dmds div) = idDmdSig fn + arity = count isId qvars + count isId extra_bndrs + all_dmds = qvar_dmds ++ extra_dmds val_pats = filterOut isTypeArg pats -- value args at call sites, used to determine how many demands to drop -- from the original functions demand and for setting up dmd_env. qvar_dmds = [ lookupVarEnv dmd_env qv `orElse` topDmd | qv <- qvars, isId qv ] extra_dmds = dropList val_pats fn_dmds - bndrs_w_dmds = set_dmds qvars qvar_dmds - ++ set_dmds extra_bndrs extra_dmds + -- Annotate the variables with the strictness information from + -- the function (see Note [Strictness information in worker binders]) + qvars_w_dmds = set_dmds qvars qvar_dmds + extras_w_dmds = set_dmds extra_bndrs extra_dmds + spec_lam_bndrs_w_dmds = qvars_w_dmds ++ extras_w_dmds set_dmds :: [Var] -> [Demand] -> [Var] set_dmds [] _ = [] @@ -2127,7 +2135,6 @@ calcSpecInfo fn (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs = go env ds args go_one env _ _ = env - {- Note [spec_usg includes rhs_usg] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -9,7 +9,7 @@ A library for the ``worker\/wrapper'' back-end to the strictness analyser module GHC.Core.Opt.WorkWrap.Utils ( WwOpts(..), mkWwBodies, mkWWstr, mkWWstr_one - , needsVoidWorkerArg, addVoidWorkerArg + , needsVoidWorkerArg , DataConPatContext(..) , UnboxingDecision(..), canUnboxArg , findTypeShape, IsRecDataConResult(..), isRecDataCon @@ -377,25 +377,34 @@ We use the state-token type which generates no code. -- Note [Preserving float barriers]. needsVoidWorkerArg :: Id -> [Var] -> [Var] -> Bool needsVoidWorkerArg fn_id wrap_args work_args - = not (isJoinId fn_id) && no_value_arg -- See Note [Protecting the last value argument] - || needs_float_barrier -- See Note [Preserving float barriers] + = thunk_problem -- See Note [Protecting the last value argument] + || needs_float_barrier -- See Note [Preserving float barriers] where - no_value_arg = all (not . isId) work_args + -- thunk_problem: see Note [Protecting the last value argument] + -- For join points we are only worried about (4), not (1-4). + -- And (4) can't happen if (null work_args) + -- (We could be more clever, by looking at the result type, but + -- this approach is simple and conservative.) + thunk_problem | isJoinId fn_id = no_value_arg && not (null work_args) + | otherwise = no_value_arg + no_value_arg = not (any isId work_args) + + -- needs_float_barrier: see Note [Preserving float barriers] + needs_float_barrier = wrap_had_barrier && not work_has_barrier is_float_barrier v = isId v && hasNoOneShotInfo (idOneShotInfo v) wrap_had_barrier = any is_float_barrier wrap_args work_has_barrier = any is_float_barrier work_args - needs_float_barrier = wrap_had_barrier && not work_has_barrier --- | Inserts a `Void#` arg before the first argument. --- --- Why as the first argument? See Note [SpecConstr needs to add void args first] --- in SpecConstr. +-- | Inserts a `Void#` arg as the last argument. +-- Why last? See Note [Worker/wrapper needs to add void arg last] addVoidWorkerArg :: [Var] -> [StrictnessMark] - -> ([Var], -- Lambda bound args - [Var], -- Args at call site - [StrictnessMark]) -- str semantics for the worker args. + -> ( [Var] -- Lambda bound args + , [Var] -- Args at call site + , [StrictnessMark]) -- str semantics for the worker args addVoidWorkerArg work_args str_marks - = (voidArgId : work_args, voidPrimId:work_args, NotMarkedStrict:str_marks) + = ( work_args ++ [voidArgId] + , work_args ++ [voidPrimId] + , str_marks ++ [NotMarkedStrict] ) {- Note [Protecting the last value argument] @@ -403,8 +412,8 @@ Note [Protecting the last value argument] If the user writes (\_ -> E), they might be intentionally disallowing the sharing of E. Since absence analysis and worker-wrapper are keen to remove such unused arguments, we add in a void argument to prevent -the function from becoming a thunk. Three reasons why turning a function -into a thunk might be bad: +the function from becoming a thunk. Here are several reasons why turning +a function into a thunk might be bad: 1) It can create a space leak. e.g. f x = let y () = [1..x] @@ -423,7 +432,19 @@ into a thunk might be bad: g = \x. 30# Removing the \x would leave an unlifted binding. -NB: none of these apply to a join point. +4) It can create a worker of ill-kinded type (#22275). Consider + f :: forall r (a :: TYPE r). () -> a + f x = f x + Here `x` is absent, but if we simply drop it we'd end up with + $wf :: forall r (a :: TYPE r). a + But alas $wf's type is ill-kinded: the kind of (/\r (a::TYPE r).a) + is (TYPE r), which mentions the bound variable `r`. See also + Note [Worker/wrapper needs to add void arg last] + +See also Note [Preserving float barriers] + +NB: Of these, only (1-3) don't apply to a join point, which can be +unlifted even if the RHS is not ok-for-speculation. Note [Preserving float barriers] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -457,7 +478,7 @@ which some are absent or one-shot and the resulting worker arguments: * \a{Abs}.\b{os}.\c{os}... ==> \b{os}.\c{os}.\(_::Void#)... Wrapper arg `a` was the only float barrier and had been dropped. Hence Void# - * \a{Abs,os}.\b{os}.\c... ==> \b{os}.\c... +p * \a{Abs,os}.\b{os}.\c... ==> \b{os}.\c... Worker arg `c` is a float barrier. * \a.\b{Abs}.\c{os}... ==> \a.\c{os}... Worker arg `a` is a float barrier. @@ -469,6 +490,28 @@ which some are absent or one-shot and the resulting worker arguments: Executable examples in T21150. +Note [Worker/wrapper needs to add void arg last] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider point (4) of Note [Protecting the last value argument] + + f :: forall r (a :: TYPE r). () -> a + f x = f x + +As pointed out in (4) we need to add a void argument. But if we add +it /first/ we'd get + + $wf :: Void# -> forall r (a :: TYPE r). a + $wf = ... + +But alas $wf's type is /still/ still-kinded, just as before in (4). +Solution is simple: put the void argument /last/: + + $wf :: forall r (a :: TYPE r). Void# -> a + $wf = ... + +Notice that this is exactly backwards from GHC.Core.Opt.SpecConstr +Note [SpecConstr needs to add void args first]. + Note [Join points and beta-redexes] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Originally, the worker would invoke the original function by calling it with ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1337,7 +1337,7 @@ ty_con_app_fun_maybe many_ty_co tc args | otherwise = Nothing -mkFunctionType :: Mult -> Type -> Type -> Type +mkFunctionType :: HasDebugCallStack => Mult -> Type -> Type -> Type -- ^ This one works out the FunTyFlag from the argument type -- See GHC.Types.Var Note [FunTyFlag] mkFunctionType mult arg_ty res_ty ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -158,7 +158,7 @@ coreAltsType :: [CoreAlt] -> Type coreAltsType (alt:_) = coreAltType alt coreAltsType [] = panic "coreAltsType" -mkLamType :: Var -> Type -> Type +mkLamType :: HasDebugCallStack => Var -> Type -> Type -- ^ Makes a @(->)@ type or an implicit forall type, depending -- on whether it is given a type variable or a term variable. -- This is used, for example, when producing the type of a lambda. ===================================== compiler/GHC/Parser.y ===================================== @@ -540,8 +540,9 @@ importdecls This might seem like an awfully roundabout way to declare a list; plus, to add insult to injury you have to reverse the results at the end. The answer is that left recursion prevents us from running out of stack space when parsing long -sequences. See: https://www.haskell.org/happy/doc/html/sec-sequences.html for -more guidance. +sequences. See: +https://haskell-happy.readthedocs.io/en/latest/using.html#parsing-sequences +for more guidance. By adding/removing branches, you can affect what lists are accepted. Here are the most common patterns, rewritten as regular expressions for clarity: ===================================== configure.ac ===================================== @@ -667,6 +667,8 @@ GHC_LLVM_TARGET_SET_VAR # we intend to pass trough --targets to llvm as is. LLVMTarget_CPP=` echo "$LlvmTarget"` AC_SUBST(LLVMTarget_CPP) +# The target is substituted into the distrib/configure.ac file +AC_SUBST(LlvmTarget) dnl ** See whether cc supports --target= and set dnl CONF_CC_OPTS_STAGE[012] accordingly. ===================================== distrib/configure.ac.in ===================================== @@ -18,6 +18,8 @@ dnl-------------------------------------------------------------------- dnl Various things from the source distribution configure bootstrap_target=@TargetPlatform@ +bootstrap_llvm_target=@LlvmTarget@ + TargetHasRTSLinker=@TargetHasRTSLinker@ AC_SUBST(TargetHasRTSLinker) @@ -169,6 +171,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG # Stage 3 won't be supported by cross-compilation FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) +FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) +FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + AC_SUBST(CONF_CC_OPTS_STAGE0) AC_SUBST(CONF_CC_OPTS_STAGE1) AC_SUBST(CONF_CC_OPTS_STAGE2) ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -148,6 +148,8 @@ configurePackage context at Context {..} = do -- Figure out what hooks we need. hooks <- case C.buildType (C.flattenPackageDescription gpd) of C.Configure -> pure C.autoconfUserHooks + C.Simple -> pure C.simpleUserHooks + C.Make -> fail "build-type: Make is not supported" -- The 'time' package has a 'C.Custom' Setup.hs, but it's actually -- 'C.Configure' plus a @./Setup test@ hook. However, Cabal is also -- 'C.Custom', but doesn't have a configure script. @@ -155,12 +157,6 @@ configurePackage context at Context {..} = do configureExists <- doesFileExist $ replaceFileName (pkgCabalFile package) "configure" pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks - -- Not quite right, but good enough for us: - _ | package == rts -> - -- Don't try to do post configuration validation for 'rts'. This - -- will simply not work, due to the @ld-options@ and @Stg.h at . - pure $ C.simpleUserHooks { C.postConf = \_ _ _ _ -> return () } - | otherwise -> pure C.simpleUserHooks -- Compute the list of flags, and the Cabal configuration arguments flavourArgs <- args <$> flavour ===================================== hadrian/src/Rules/Register.hs ===================================== @@ -45,6 +45,14 @@ configurePackageRules = do isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend when isGmp $ need [buildP -/- "include/ghc-gmp.h"] + when (pkg == rts) $ do + -- Rts.h is a header listed in the cabal file, and configuring + -- therefore wants to ensure that the header "works" post-configure. + -- But it (transitively) includes these, so we must ensure they exist + -- for that check to work. + need [ buildP -/- "include/ghcautoconf.h" + , buildP -/- "include/ghcplatform.h" + ] Cabal.configurePackage ctx root -/- "**/autogen/cabal_macros.h" %> \out -> do ===================================== libraries/base/Data/List.hs ===================================== @@ -127,6 +127,7 @@ module Data.List -- | These functions treat a list @xs@ as a indexed collection, -- with indices ranging from 0 to @'length' xs - 1 at . + , (!?) , (!!) , elemIndex ===================================== libraries/base/Data/OldList.hs ===================================== @@ -127,6 +127,7 @@ module Data.OldList -- | These functions treat a list @xs@ as a indexed collection, -- with indices ranging from 0 to @'length' xs - 1 at . + , (!?) , (!!) , elemIndex ===================================== libraries/base/GHC/List.hs ===================================== @@ -31,7 +31,7 @@ module GHC.List ( -- Other functions foldl1', concat, concatMap, map, (++), filter, lookup, - head, last, tail, init, uncons, (!!), + head, last, tail, init, uncons, (!?), (!!), scanl, scanl1, scanl', scanr, scanr1, iterate, iterate', repeat, replicate, cycle, take, drop, splitAt, takeWhile, dropWhile, span, break, reverse, @@ -49,7 +49,7 @@ import GHC.Num (Num(..)) import GHC.Num.Integer (Integer) import GHC.Stack.Types (HasCallStack) -infixl 9 !! +infixl 9 !?, !! infix 4 `elem`, `notElem` -- $setup @@ -1370,9 +1370,10 @@ concat = foldr (++) [] -- >>> ['a', 'b', 'c'] !! (-1) -- *** Exception: Prelude.!!: negative index -- --- WARNING: This function is partial. You can use --- --- instead. +-- WARNING: This function is partial, and should only be used if you are +-- sure that the indexing will not fail. Otherwise, use 'Data.List.!?'. +-- +-- WARNING: This function takes linear time in the index. #if defined(USE_REPORT_PRELUDE) (!!) :: [a] -> Int -> a xs !! n | n < 0 = errorWithoutStackTrace "Prelude.!!: negative index" @@ -1401,6 +1402,30 @@ xs !! n _ -> r (k-1)) tooLarge xs n #endif +-- | List index (subscript) operator, starting from 0. Returns 'Nothing' +-- if the index is out of bounds +-- +-- >>> ['a', 'b', 'c'] !? 0 +-- Just 'a' +-- >>> ['a', 'b', 'c'] !? 2 +-- Just 'c' +-- >>> ['a', 'b', 'c'] !? 3 +-- Nothing +-- >>> ['a', 'b', 'c'] !? (-1) +-- Nothing +-- +-- This is the total variant of the partial '!!' operator. +-- +-- WARNING: This function takes linear time in the index. +(!?) :: [a] -> Int -> Maybe a + +{-# INLINABLE (!?) #-} +xs !? n + | n < 0 = Nothing + | otherwise = foldr (\x r k -> case k of + 0 -> Just x + _ -> r (k-1)) (const Nothing) xs n + -------------------------------------------------------------- -- The zip family -------------------------------------------------------------- ===================================== libraries/base/changelog.md ===================================== @@ -58,6 +58,8 @@ 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`. + * Add `Data.List.!?` per + [CLC proposal #110](https://github.com/haskell/core-libraries-committee/issues/110). ## 4.17.0.0 *August 2022* ===================================== m4/ghc_llvm_target.m4 ===================================== @@ -50,5 +50,10 @@ AC_DEFUN([GHC_LLVM_TARGET], [ # require it. AC_DEFUN([GHC_LLVM_TARGET_SET_VAR], [ AC_REQUIRE([FPTOOLS_SET_PLATFORMS_VARS]) - GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + if test "$bootstrap_llvm_target" != "" + then + LlvmTarget=$bootstrap_llvm_target + else + GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + fi ]) ===================================== rts/posix/OSThreads.c ===================================== @@ -218,6 +218,12 @@ start_thread (void *param) return startProc(startParam); } +/* Note: at least on Linux/Glibc, `pthread_setname_np` restricts the name of + * a thread to 16 bytes, including the terminating null byte. Hence, make sure + * to only pass in names of up to 15 characters. Otherwise, + * `pthread_setname_np` when called in `start_thread` will fail with `ERANGE`, + * which is not checked for, and the thread won't be named at all. + */ int createOSThread (OSThreadId* pId, const char *name, OSThreadProc *startProc, void *param) ===================================== rts/rts.cabal.in ===================================== @@ -275,6 +275,8 @@ library stg/SMP.h stg/Ticky.h stg/Types.h + + -- See Note [Undefined symbols in the RTS] if flag(64bit) if flag(leading-underscore) ld-options: @@ -474,6 +476,8 @@ library ld-options: "-Wl,-search_paths_first" -- See Note [fd_set_overflow] "-Wl,-U,___darwin_check_fd_set_overflow" + -- See Note [Undefined symbols in the RTS] + "-Wl,-undefined,dynamic_lookup" if !arch(x86_64) && !arch(aarch64) ld-options: -read_only_relocs warning @@ -714,3 +718,35 @@ library -- , https://github.com/sitsofe/fio/commit/b6a1e63a1ff607692a3caf3c2db2c3d575ba2320 -- The issue was originally reported in #19950 + + +-- Note [Undefined symbols in the RTS] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- The RTS is built with a number of `-u` flags. This is to handle cyclic +-- dependencies between the RTS and other libraries which we normally think of as +-- downstream from the RTS. "Regular" dependencies from usages in those libraries +-- to definitions in the RTS are handled normally. "Reverse" dependencies from +-- usages in the RTS to definitions in those libraries get the `-u` flag in the +-- RTS. +-- +-- The symbols are specified literally, but follow C ABI conventions (as all 3 of +-- C, C--, and Haskell do currently). Thus, we have to be careful to include a +-- leading underscore or not based on those conventions for the given platform in +-- question. +-- +-- A tricky part is that different linkers have different policies regarding +-- undefined symbols (not defined in the current binary, or found in a shared +-- library that could be loaded at run time). GNU Binutils' linker is fine with +-- undefined symbols by default, but Apple's "cctools" linker is not. To appease +-- that linker we either need to do a blanket `-undefined dynamic_lookup` or +-- whitelist each such symbol with an additional `-U` (see the man page for more +-- details). +-- +-- GHC already does `-undefined dynamic_lookup`, so we just do that for now, but +-- we might try to get more precise with `-U` in the future. +-- +-- Note that the RTS also `-u`s some atomics symbols that *are* defined --- and +-- defined within the RTS! It is not immediately clear why this is needed. This +-- dates back to c06e3f46d24ef69f3a3d794f5f604cb8c2a40cbc which mentions a build +-- failure that it was suggested that this fix, but the precise reasoning is not +-- explained. ===================================== rts/sm/NonMoving.c ===================================== @@ -1015,7 +1015,7 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) nonmoving_write_barrier_enabled = true; debugTrace(DEBUG_nonmoving_gc, "Starting concurrent mark thread"); OSThreadId thread; - if (createOSThread(&thread, "non-moving mark thread", + if (createOSThread(&thread, "nonmoving-mark", nonmovingConcurrentMark, mark_queue) != 0) { barf("nonmovingCollect: failed to spawn mark thread: %s", strerror(errno)); } ===================================== testsuite/tests/codeGen/should_gen_asm/AddMulX86.asm deleted ===================================== @@ -1,46 +0,0 @@ -.section .text -.align 8 -.align 8 - .quad 8589934604 - .quad 0 - .long 14 - .long 0 -.globl AddMulX86_f_info -.type AddMulX86_f_info, @function -AddMulX86_f_info: -.LcAx: - leaq (%r14,%rsi,8),%rbx - jmp *(%rbp) - .size AddMulX86_f_info, .-AddMulX86_f_info -.section .data -.align 8 -.align 1 -.globl AddMulX86_f_closure -.type AddMulX86_f_closure, @object -AddMulX86_f_closure: - .quad AddMulX86_f_info -.section .text -.align 8 -.align 8 - .quad 8589934604 - .quad 0 - .long 14 - .long 0 -.globl AddMulX86_g_info -.type AddMulX86_g_info, @function -AddMulX86_g_info: -.LcAL: - leaq (%r14,%rsi,8),%rbx - jmp *(%rbp) - .size AddMulX86_g_info, .-AddMulX86_g_info -.section .data -.align 8 -.align 1 -.globl AddMulX86_g_closure -.type AddMulX86_g_closure, @object -AddMulX86_g_closure: - .quad AddMulX86_g_info -.section .note.GNU-stack,"", at progbits -.ident "GHC 9.3.20220228" - - ===================================== testsuite/tests/codeGen/should_gen_asm/AddMulX86.hs deleted ===================================== @@ -1,12 +0,0 @@ -{-# LANGUAGE MagicHash #-} - -module AddMulX86 where - -import GHC.Exts - -f :: Int# -> Int# -> Int# -f x y = - x +# (y *# 8#) -- Should result in a lea instruction, which we grep the assembly output for. - -g x y = - (y *# 8#) +# x -- Should result in a lea instruction, which we grep the assembly output for. ===================================== testsuite/tests/codeGen/should_gen_asm/all.T ===================================== @@ -10,4 +10,3 @@ test('memset-unroll', is_amd64_codegen, compile_cmp_asm, ['cmm', '']) test('bytearray-memset-unroll', is_amd64_codegen, compile_grep_asm, ['hs', True, '']) test('bytearray-memcpy-unroll', is_amd64_codegen, compile_grep_asm, ['hs', True, '']) test('T18137', [when(opsys('darwin'), skip), only_ways(llvm_ways)], compile_grep_asm, ['hs', False, '-fllvm -split-sections']) -test('AddMulX86', is_amd64_codegen, compile_cmp_asm, ['hs', '-dno-typeable-binds']) ===================================== testsuite/tests/rts/pause-resume/pause_resume.c ===================================== @@ -187,7 +187,7 @@ void pauseAndResumeViaThread ) { OSThreadId threadId; - createOSThread(&threadId, "Pause and resume thread", &pauseAndResumeViaThread_helper, (void *)count); + createOSThread(&threadId, "pause-resume", &pauseAndResumeViaThread_helper, (void *)count); } const int TIMEOUT = 1000000; // 1 second ===================================== testsuite/tests/simplCore/should_compile/T13143.stderr ===================================== @@ -1,14 +1,14 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 71, types: 41, coercions: 0, joins: 0/0} + = {terms: 71, types: 40, coercions: 0, joins: 0/0} Rec { -- RHS size: {terms: 4, types: 3, coercions: 0, joins: 0/0} T13143.$wf [InlPrag=NOINLINE, Occ=LoopBreaker] - :: (# #) -> forall {a}. a + :: forall {a}. (# #) -> a [GblId, Arity=1, Str=b, Cpr=b, Unf=OtherCon []] -T13143.$wf = \ _ [Occ=Dead] (@a) -> T13143.$wf GHC.Prim.(##) @a +T13143.$wf = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##) end Rec } -- RHS size: {terms: 4, types: 3, coercions: 0, joins: 0/0} @@ -17,55 +17,60 @@ f [InlPrag=NOINLINE[final]] :: forall a. Int -> a Arity=1, Str=b, Cpr=b, - 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=True) - Tmpl= \ (@a) _ [Occ=Dead] -> T13143.$wf GHC.Prim.(##) @a}] -f = \ (@a) _ [Occ=Dead] -> T13143.$wf GHC.Prim.(##) @a + Tmpl= \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##)}] +f = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##) -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T13143.$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}] T13143.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T13143.$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}] T13143.$trModule3 = GHC.Types.TrNameS T13143.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T13143.$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}] T13143.$trModule2 = "T13143"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T13143.$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}] 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}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T13143.$trModule = GHC.Types.Module T13143.$trModule3 T13143.$trModule1 --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -lvl :: forall {a}. a +-- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} +lvl :: Int [GblId, Str=b, Cpr=b] -lvl = T13143.$wf GHC.Prim.(##) +lvl = T13143.$wf @Int GHC.Prim.(##) Rec { --- RHS size: {terms: 28, types: 8, coercions: 0, joins: 0/0} +-- RHS size: {terms: 28, types: 7, coercions: 0, joins: 0/0} T13143.$wg [InlPrag=[2], Occ=LoopBreaker] :: Bool -> Bool -> GHC.Prim.Int# -> GHC.Prim.Int# [GblId[StrictWorker([!, !])], @@ -94,8 +99,8 @@ g [InlPrag=[2]] :: Bool -> Bool -> Int -> Int Arity=3, Str=<1L><1L><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=3,unsat_ok=True,boring_ok=False) Tmpl= \ (ds [Occ=Once1] :: Bool) (ds1 [Occ=Once1] :: Bool) ===================================== testsuite/tests/simplCore/should_compile/T18328.stderr ===================================== @@ -1,84 +1,90 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 65, types: 53, coercions: 0, joins: 1/1} + = {terms: 69, types: 55, coercions: 0, joins: 1/1} --- RHS size: {terms: 38, types: 23, coercions: 0, joins: 1/1} +-- RHS size: {terms: 42, types: 25, coercions: 0, joins: 1/1} T18328.$wf [InlPrag=[2]] :: forall {a}. GHC.Prim.Int# -> [a] -> [a] -> [a] -[GblId, +[GblId[StrictWorker([~, !])], Arity=3, Str=, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [176 0 0] 306 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [176 0 0] 306 0}] T18328.$wf - = \ (@a) (ww :: GHC.Prim.Int#) (w :: [a]) (w1 :: [a]) -> + = \ (@a) (ww :: GHC.Prim.Int#) (ys :: [a]) (eta :: [a]) -> join { - $wj [InlPrag=NOINLINE, Dmd=ML] :: forall {p}. [a] - [LclId[JoinId(1)]] - $wj (@p) + $wj [InlPrag=NOINLINE, Dmd=MC(1,L)] :: forall {p}. (# #) -> [a] + [LclId[JoinId(2)(Nothing)], Arity=1, Str=, Unf=OtherCon []] + $wj (@p) _ [Occ=Dead, OS=OneShot] = case ww of { - __DEFAULT -> ++ @a w (++ @a w (++ @a w w1)); - 3# -> ++ @a w (++ @a w (++ @a w (++ @a w w1))) + __DEFAULT -> ++ @a ys (++ @a ys (++ @a ys eta)); + 3# -> ++ @a ys (++ @a ys (++ @a ys (++ @a ys eta))) } } in case ww of { - __DEFAULT -> ++ @a w w1; - 1# -> jump $wj @Integer; - 2# -> jump $wj @Integer; - 3# -> jump $wj @Integer + __DEFAULT -> ++ @a ys eta; + 1# -> jump $wj @Integer GHC.Prim.(##); + 2# -> jump $wj @Integer GHC.Prim.(##); + 3# -> jump $wj @Integer GHC.Prim.(##) } -- RHS size: {terms: 11, types: 9, coercions: 0, joins: 0/0} f [InlPrag=[2]] :: forall a. Int -> [a] -> [a] -> [a] [GblId, Arity=3, - Str=<1P(SL)>, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Str=<1!P(SL)>, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) Tmpl= \ (@a) - (w [Occ=Once1!] :: Int) - (w1 [Occ=Once1] :: [a]) - (w2 [Occ=Once1] :: [a]) -> - case w of { GHC.Types.I# ww [Occ=Once1] -> - T18328.$wf @a ww w1 w2 + (x [Occ=Once1!] :: Int) + (ys [Occ=Once1] :: [a]) + (eta [Occ=Once1] :: [a]) -> + case x of { GHC.Types.I# ww [Occ=Once1] -> + T18328.$wf @a ww ys eta }}] -f = \ (@a) (w :: Int) (w1 :: [a]) (w2 :: [a]) -> - case w of { GHC.Types.I# ww -> T18328.$wf @a ww w1 w2 } +f = \ (@a) (x :: Int) (ys :: [a]) (eta :: [a]) -> + case x of { GHC.Types.I# ww -> T18328.$wf @a ww ys eta } -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule3 = GHC.Types.TrNameS T18328.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule2 = "T18328"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule1 = GHC.Types.TrNameS T18328.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T18328.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T18328.$trModule = GHC.Types.Module T18328.$trModule3 T18328.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T22725.hs ===================================== @@ -0,0 +1,6 @@ +module M where + +import GHC.Exts (TYPE) + +f :: forall r (a :: TYPE r). () -> a +f x = f x ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -462,3 +462,4 @@ test('T22272', normal, multimod_compile, ['T22272', '-O -fexpose-all-unfoldings test('T22459', normal, compile, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) test('T22662', normal, compile, ['']) +test('T22725', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2c66b095151d28feded5e0d595842fc8bb82941c...8fa3eddea469c7c44ce15a8304f12c566ac946a2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2c66b095151d28feded5e0d595842fc8bb82941c...8fa3eddea469c7c44ce15a8304f12c566ac946a2 You're receiving 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 Jan 10 10:25:28 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 10 Jan 2023 05:25:28 -0500 Subject: [Git][ghc/ghc][wip/T22428] Fix contification with stable unfoldings (#22428) Message-ID: <63bd3d18c798e_3b1bf98fe52c443367a@gitlab.mail> Sebastian Graf pushed to branch wip/T22428 at Glasgow Haskell Compiler / GHC Commits: be991556 by Sebastian Graf at 2023-01-10T11:24:41+01:00 Fix contification with stable unfoldings (#22428) Many functions now return a `TailUsageDetails` that adorns a `UsageDetails` with a `JoinArity` that reflects the number of join point binders around the body for which the `UsageDetails` was computed. `TailUsageDetails` is now returned by `occAnalLamTail` as well as `occAnalUnfolding` and `occAnalRules`. I adjusted `Note [Join points and unfoldings/rules]` and `Note [Adjusting right-hand sides]` to account for the new machinery. I also wrote a new `Note [Join arity prediction based on joinRhsArity]` and refer to it when we combine `TailUsageDetails` for a recursive RHS. I also renamed * `occAnalLam` to `occAnalLamTail` * `adjustRhsUsage` to `adjustTailUsage` * a few other less important functions and properly documented the that each call of `occAnalLamTail` must pair up with `adjustTailUsage`. I removed `Note [Unfoldings and join points]` because it was redundant with `Note [Occurrences in stable unfoldings]`. While in town, I refactored `mkLoopBreakerNodes` so that it returns a condensed `NodeDetails` called `SimpleNodeDetails`. Fixes #22428. Metric Decrease: T12150 T12425 T21839c T21839r T9961 - - - - - 7 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Data/Graph/Directed.hs - compiler/GHC/Utils/Misc.hs - + testsuite/tests/simplCore/should_compile/T22428.hs - + testsuite/tests/simplCore/should_compile/T22428.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -132,6 +132,9 @@ joinRhsArity :: CoreExpr -> JoinArity -- Join points are supposed to have manifestly-visible -- lambdas at the top: no ticks, no casts, nothing -- Moreover, type lambdas count in JoinArity +-- NB: For non-recursive bindings, the join arity of the binding may actually be +-- less that the number of manifestly-visible lambdas. +-- See Note [Join arity prediction based on joinRhsArity] in GHC.Core.Opt.OccurAnal joinRhsArity (Lam _ e) = 1 + joinRhsArity e joinRhsArity _ = 0 ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -59,7 +59,7 @@ import GHC.Builtin.Names( runRWKey ) import GHC.Unit.Module( Module ) import Data.List (mapAccumL, mapAccumR) -import Data.List.NonEmpty (NonEmpty (..), nonEmpty) +import Data.List.NonEmpty (NonEmpty (..)) import qualified Data.List.NonEmpty as NE {- @@ -510,6 +510,16 @@ of the file. at any of the definitions. This is done by Simplify.simplRecBind, when it calls addLetIdInfo. +Note [TailUsageDetails when forming Rec groups] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `TailUsageDetails` stored in the `nd_uds` field of a `NodeDetails` is +computed by `occAnalLamTail` applied to the RHS, not `occAnalExpr`. +That is because the binding might still become a *non-recursive join point* in +the AcyclicSCC case of dependency analysis! +Hence we do the delayed `adjustTailUsage` in `occAnalRec`/`tagRecBinders` to get +a regular, adjusted UsageDetails. +See Note [Join points and unfoldings/rules] for more details on the contract. + Note [Stable unfoldings] ~~~~~~~~~~~~~~~~~~~~~~~~ None of the above stuff about RULES applies to a stable unfolding @@ -608,6 +618,64 @@ tail call with `n` arguments (counting both value and type arguments). Otherwise 'occ_tail' will be 'NoTailCallInfo'. The tail call info flows bottom-up with the rest of 'OccInfo' until it goes on the binder. +Note [Join arity prediction based on joinRhsArity] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In general, the join arity from tail occurrences of a join point (O) may be +higher or lower than the manifest join arity of the join body (M). E.g., + + -- M > O: + let f x y = x + y -- M = 2 + in if b then f 1 else f 2 -- O = 1 + ==> { Contify for join arity 1 } + join f x = \y -> x + y + in if b then jump f 1 else jump f 2 + + -- M < O + let f = id -- M = 0 + in if ... then f 12 else f 13 -- O = 1 + ==> { Contify for join arity 1, eta-expand f } + join f x = id x + in if b then jump f 12 else jump f 13 + +But for *recursive* let, it is crucial that both arities match up, consider + + letrec f x y = if ... then f x else True + in f 42 + +Here, M=2 but O=1. If we settled for a joinrec arity of 1, the recursive jump +would not happen in a tail context! Contification is invalid here. +So indeed it is crucial to demand that M=O. + +(Side note: Actually, we could be more specific: Let O1 be the join arity of +occurrences from the letrec RHS and O2 the join arity from the let body. Then +we need M=O1 and M<=O2 and could simply eta-expand the RHS to match O2 later. +M=O is the specific case where we don't want to eta-expand. Neither the join +points paper nor GHC does this at the moment.) + +We can capitalise on this observation and conclude that *if* f could become a +joinrec (without eta-expansion), it will have join arity M. +Now, M is just the result of 'joinRhsArity', a rather simple, local analysis. +It is also the join arity inside the 'TailUsageDetails' returned by +'occAnalLamTail', so we can predict join arity without doing any fixed-point +iteration or really doing any deep traversal of let body or RHS at all. + +All this is quite apparent if you look at the contification transformation in +Fig. 5 of "Compiling without Continuations" (which does not account for +eta-expansion at all, mind you). The letrec case looks like this + + letrec f = /\as.\xs. L[us] in L'[es] + ... and a bunch of conditions establishing that f only occurs + in app heads of join arity (len as + len xs) inside us and es ... + +The syntactic form `/\as.\xs. L[us]` forces M=O iff `f` occurs in `us`. However, +for non-recursive functions, this is the definition of contification from the +paper: + + let f = /\as.\xs.u in L[es] ... conditions ... + +Note that u could be a lambda itself, as we have seen. No relationship between M +and O to exploit here. + Note [Join points and unfoldings/rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider @@ -618,8 +686,10 @@ Consider Before j is inlined, we'll have occurrences of j2 in both j's RHS and in its stable unfolding. We want to discover -j2 as a join point. So we must do the adjustRhsUsage thing -on j's RHS. That's why we pass mb_join_arity to calcUnfolding. +j2 as a join point. So 'occAnalUnfolding' returns an unadjusted +'TailUsageDetails', like 'occAnalLamTail'. We adjust the usage details of the +unfolding to the actual join arity using the same 'adjustTailArity' as for +the RHS, see Note [Adjusting right-hand sides]. Same with rules. Suppose we have: @@ -636,14 +706,31 @@ up. So provided the join-point arity of k matches the args of the rule we can allow the tail-call info from the RHS of the rule to propagate. -* Wrinkle for Rec case. In the recursive case we don't know the - join-point arity in advance, when calling occAnalUnfolding and - occAnalRules. (See makeNode.) We don't want to pass Nothing, - because then a recursive joinrec might lose its join-poin-hood - when SpecConstr adds a RULE. So we just make do with the - *current* join-poin-hood, stored in the Id. +* Note that the join arity of the RHS and that of the unfolding or RULE might + mismatch: + + let j x y = j2 (x+x) + {-# INLINE[2] j = \x. g #-} + {-# RULE forall x y z. j x y z = h 17 #-} + in j 1 2 - In the non-recursive case things are simple: see occAnalNonRecBind + So it is crucial that we adjust each TailUsageDetails individually + with the actual join arity 2 here before we combine with `andUDs`. + Here, that means losing tail call info on `g` and `h`. + +* Wrinkle for Rec case: We store one TailUsageDetails in the node Details for + RHS, unfolding and RULE combined. Clearly, if they don't agree on their join + arity, we have to do some adjusting. We choose to adjust to the join arity + of the RHS, because that is likely the join arity that the join point will + have; see Note [Join arity prediction based on joinRhsArity]. + + If the guess is correct, then tail calls in the RHS are preserved; a necessary + condition for the whole binding becoming a joinrec. + The guess can only be incorrect in the 'AcyclicSCC' case when the binding + becomes a non-recursive join point with a different join arity. But then the + eventual call to 'adjustTailUsage' in 'tagRecBinders'/'occAnalRec' will + be with a different join arity and destroy unsound tail call info with + 'markNonTail'. * Wrinkle for RULES. Suppose the example was a bit different: let j :: Int -> Int @@ -669,28 +756,21 @@ propagate. This appears to be very rare in practice. TODO Perhaps we should gather statistics to be sure. -Note [Unfoldings and join points] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We assume that anything in an unfolding occurs multiple times, since -unfoldings are often copied (that's the whole point!). But we still -need to track tail calls for the purpose of finding join points. - - ------------------------------------------------------------ Note [Adjusting right-hand sides] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There's a bit of a dance we need to do after analysing a lambda expression or a right-hand side. In particular, we need to - a) call 'markAllInsideLam' *unless* the binding is for a thunk, a one-shot - lambda, or a non-recursive join point; and - b) call 'markAllNonTail' *unless* the binding is for a join point, and - the RHS has the right arity; e.g. + a) call 'markAllNonTail' *unless* the binding is for a join point, and + the TailUsageDetails from the RHS has the right join arity; e.g. join j x y = case ... of A -> j2 p B -> j2 q in j a b Here we want the tail calls to j2 to be tail calls of the whole expression + b) call 'markAllInsideLam' *unless* the binding is for a thunk, a one-shot + lambda, or a non-recursive join point Some examples, with how the free occurrences in e (assumed not to be a value lambda) get marked: @@ -707,26 +787,39 @@ lambda) get marked: There are a few other caveats; most importantly, if we're marking a binding as 'AlwaysTailCalled', it's *going* to be a join point, so we treat it as one so that the effect cascades properly. Consequently, at the time the RHS is -analysed, we won't know what adjustments to make; thus 'occAnalLamOrRhs' must -return the unadjusted 'UsageDetails', to be adjusted by 'adjustRhsUsage' once -join-point-hood has been decided. - -Thus the overall sequence taking place in 'occAnalNonRecBind' and -'occAnalRecBind' is as follows: - - 1. Call 'occAnalLamOrRhs' to find usage information for the RHS. - 2. Call 'tagNonRecBinder' or 'tagRecBinders', which decides whether to make +analysed, we won't know what adjustments to make; thus 'occAnalLamTail' must +return the unadjusted 'TailUsageDetails', to be adjusted by 'adjustTailUsage' +once join-point-hood has been decided and eventual one-shot annotations have +been added through 'markNonRecJoinOneShots'. + +It is not so simple to see that 'occAnalNonRecBind' and 'occAnalRecBind' indeed +perform a similar sequence of steps. Thus, here is an interleaving of events +of both functions, serving as a specification: + + 1. Call 'occAnalLamTail' to find usage information for the RHS. + Recursive case: 'makeNode' + Non-recursive case: 'occAnalNonRecBind' + 2. (Analyse the binding's scope. Done in 'occAnalBind'/`occAnal Let{}`. + Same whether recursive or not.) + 3. Call 'tagNonRecBinder' or 'tagRecBinders', which decides whether to make the binding a join point. - 3. Call 'adjustRhsUsage' accordingly. (Done as part of 'tagRecBinders' when - recursive.) - -(In the recursive case, this logic is spread between 'makeNode' and -'occAnalRec'.) + Cyclic Recursive case: 'mkLoopBreakerNodes' + Acyclic Recursive case: `occAnalRec AcyclicSCC{}` + Non-recursive case: 'occAnalNonRecBind' + 4. Non-recursive join point: Call 'markNonRecJoinOneShots' so that e.g., + FloatOut sees one-shot annotations on lambdas + Acyclic Recursive case: `occAnalRec AcyclicSCC{}` calls 'adjustNonRecRhs' + Non-recursive case: 'occAnalNonRecBind' calls 'adjustNonRecRhs' + 5. Call 'adjustTailUsage' accordingly. + Cyclic Recursive case: 'tagRecBinders' + Acyclic Recursive case: 'adjustNonRecRhs' + Non-recursive case: 'adjustNonRecRhs' -} - data WithUsageDetails a = WithUsageDetails !UsageDetails !a +data WithTailUsageDetails a = WithTailUsageDetails !TailUsageDetails !a + ------------------------------------------------------------------ -- occAnalBind ------------------------------------------------------------------ @@ -754,15 +847,13 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage = WithUsageDetails body_usage [] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr rhs'] + = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr final_rhs] where - (body_usage', tagged_bndr) = tagNonRecBinder lvl body_usage bndr - final_bndr = tagged_bndr `setIdUnfolding` unf' - `setIdSpecialisation` mkRuleInfo rules' - rhs_usage = rhs_uds `andUDs` unf_uds `andUDs` rule_uds + WithUsageDetails body_usage' tagged_bndr = tagNonRecBinder lvl body_usage bndr -- Get the join info from the *new* decision -- See Note [Join points and unfoldings/rules] + -- => join arity O of Note [Join arity prediction based on joinRhsArity] mb_join_arity = willBeJoinId_maybe tagged_bndr is_join_point = isJust mb_join_arity @@ -773,17 +864,28 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- See Note [Sources of one-shot information] rhs_env = env1 { occ_one_shots = argOneShots dmd } - (WithUsageDetails rhs_uds rhs') = occAnalRhs rhs_env NonRecursive mb_join_arity rhs + -- See Note [Join arity prediction based on joinRhsArity] + -- Match join arity O from mb_join_arity with manifest join arity M as + -- returned by of occAnalLamTail. It's totally OK for them to mismatch; + -- hence adjust the UDs from the RHS + WithUsageDetails adj_rhs_uds final_rhs + = adjustNonRecRhs mb_join_arity $ occAnalLamTail rhs_env rhs + rhs_usage = adj_rhs_uds `andUDs` adj_unf_uds `andUDs` adj_rule_uds + final_bndr = tagged_bndr `setIdSpecialisation` mkRuleInfo rules' + `setIdUnfolding` unf2 --------- Unfolding --------- - -- See Note [Unfoldings and join points] + -- See Note [Join points and unfoldings/rules] unf | isId bndr = idUnfolding bndr | otherwise = NoUnfolding - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env NonRecursive mb_join_arity unf + WithTailUsageDetails unf_uds unf1 = occAnalUnfolding rhs_env unf + !unf2 = markNonRecUnfoldingOneShots mb_join_arity unf1 + adj_unf_uds = adjustTailArity mb_join_arity unf_uds --------- Rules --------- -- See Note [Rules are extra RHSs] and Note [Rule dependency info] - rules_w_uds = occAnalRules rhs_env mb_join_arity bndr + -- and Note [Join points and unfoldings/rules] + rules_w_uds = occAnalRules rhs_env bndr rules' = map fstOf3 rules_w_uds imp_rule_uds = impRulesScopeUsage (lookupImpRules imp_rule_edges bndr) -- imp_rule_uds: consider @@ -794,8 +896,9 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- that g is (since the RULE might turn g into h), so -- we make g mention h. - rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds - add_rule_uds (_, l, r) uds = l `andUDs` r `andUDs` uds + adj_rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds + add_rule_uds (_, l, r) uds + = l `andUDs` adjustTailArity mb_join_arity r `andUDs` uds ---------- occ = idOccInfo tagged_bndr @@ -820,7 +923,7 @@ occAnalRecBind :: OccEnv -> TopLevelFlag -> ImpRuleEdges -> [(Var,CoreExpr)] occAnalRecBind !env lvl imp_rule_edges pairs body_usage = foldr (occAnalRec rhs_env lvl) (WithUsageDetails body_usage []) sccs where - sccs :: [SCC Details] + sccs :: [SCC NodeDetails] sccs = {-# SCC "occAnalBind.scc" #-} stronglyConnCompFromEdgedVerticesUniq nodes @@ -832,27 +935,41 @@ occAnalRecBind !env lvl imp_rule_edges pairs body_usage bndr_set = mkVarSet bndrs rhs_env = env `addInScope` bndrs +adjustNonRecRhs :: Maybe JoinArity -> WithTailUsageDetails CoreExpr -> WithUsageDetails CoreExpr +-- ^ This function concentrates shared logic between occAnalNonRecBind and the +-- AcyclicSCC case of occAnalRec. +-- * It applies 'markNonRecJoinOneShots' to the RHS +-- * and returns the adjusted rhs UsageDetails combined with the body usage +adjustNonRecRhs mb_join_arity (WithTailUsageDetails rhs_tuds rhs) + = WithUsageDetails rhs_uds' rhs' + where + --------- Marking (non-rec) join binders one-shot --------- + !rhs' | Just ja <- mb_join_arity = markNonRecJoinOneShots ja rhs + | otherwise = rhs + --------- Adjusting right-hand side usage --------- + rhs_uds' = adjustTailUsage mb_join_arity rhs' rhs_tuds ----------------------------- occAnalRec :: OccEnv -> TopLevelFlag - -> SCC Details + -> SCC NodeDetails -> WithUsageDetails [CoreBind] -> WithUsageDetails [CoreBind] -- The NonRec case is just like a Let (NonRec ...) above -occAnalRec !_ lvl (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = rhs - , nd_uds = rhs_uds })) +occAnalRec !_ lvl + (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = wtuds })) (WithUsageDetails body_uds binds) | not (bndr `usedIn` body_uds) = WithUsageDetails body_uds binds -- See Note [Dead code] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_uds' `andUDs` rhs_uds') - (NonRec tagged_bndr rhs : binds) + = WithUsageDetails (body_uds' `andUDs` rhs_uds') (NonRec bndr' rhs' : binds) where - (body_uds', tagged_bndr) = tagNonRecBinder lvl body_uds bndr - rhs_uds' = adjustRhsUsage mb_join_arity rhs rhs_uds + WithUsageDetails body_uds' tagged_bndr = tagNonRecBinder lvl body_uds bndr mb_join_arity = willBeJoinId_maybe tagged_bndr + WithUsageDetails rhs_uds' rhs' = adjustNonRecRhs mb_join_arity wtuds + !unf' = markNonRecUnfoldingOneShots mb_join_arity (idUnfolding tagged_bndr) + !bndr' = tagged_bndr `setIdUnfolding` unf' -- The Rec case is the interesting one -- See Note [Recursive bindings: the grand plan] @@ -873,7 +990,7 @@ occAnalRec env lvl (CyclicSCC details_s) (WithUsageDetails body_uds binds) -- Make the nodes for the loop-breaker analysis -- See Note [Choosing loop breakers] for loop_breaker_nodes final_uds :: UsageDetails - loop_breaker_nodes :: [LetrecNode] + loop_breaker_nodes :: [LoopBreakerNode] (WithUsageDetails final_uds loop_breaker_nodes) = mkLoopBreakerNodes env lvl body_uds details_s ------------------------------ @@ -1102,7 +1219,7 @@ type Binding = (Id,CoreExpr) loopBreakNodes :: Int -> VarSet -- Binders whose dependencies may be "missing" -- See Note [Weak loop breakers] - -> [LetrecNode] + -> [LoopBreakerNode] -> [Binding] -- Append these to the end -> [Binding] @@ -1121,7 +1238,7 @@ loopBreakNodes depth weak_fvs nodes binds CyclicSCC nodes -> reOrderNodes depth weak_fvs nodes binds ---------------------------------- -reOrderNodes :: Int -> VarSet -> [LetrecNode] -> [Binding] -> [Binding] +reOrderNodes :: Int -> VarSet -> [LoopBreakerNode] -> [Binding] -> [Binding] -- Choose a loop breaker, mark it no-inline, -- and call loopBreakNodes on the rest reOrderNodes _ _ [] _ = panic "reOrderNodes" @@ -1133,7 +1250,7 @@ reOrderNodes depth weak_fvs (node : nodes) binds (map (nodeBinding mk_loop_breaker) chosen_nodes ++ binds) where (chosen_nodes, unchosen) = chooseLoopBreaker approximate_lb - (nd_score (node_payload node)) + (snd_score (node_payload node)) [node] [] nodes approximate_lb = depth >= 2 @@ -1142,8 +1259,8 @@ reOrderNodes depth weak_fvs (node : nodes) binds -- After two iterations (d=0, d=1) give up -- and approximate, returning to d=0 -nodeBinding :: (Id -> Id) -> LetrecNode -> Binding -nodeBinding set_id_occ (node_payload -> ND { nd_bndr = bndr, nd_rhs = rhs}) +nodeBinding :: (Id -> Id) -> LoopBreakerNode -> Binding +nodeBinding set_id_occ (node_payload -> SND { snd_bndr = bndr, snd_rhs = rhs}) = (set_id_occ bndr, rhs) mk_loop_breaker :: Id -> Id @@ -1163,13 +1280,13 @@ mk_non_loop_breaker weak_fvs bndr tail_info = tailCallInfo (idOccInfo bndr) ---------------------------------- -chooseLoopBreaker :: Bool -- True <=> Too many iterations, - -- so approximate - -> NodeScore -- Best score so far - -> [LetrecNode] -- Nodes with this score - -> [LetrecNode] -- Nodes with higher scores - -> [LetrecNode] -- Unprocessed nodes - -> ([LetrecNode], [LetrecNode]) +chooseLoopBreaker :: Bool -- True <=> Too many iterations, + -- so approximate + -> NodeScore -- Best score so far + -> [LoopBreakerNode] -- Nodes with this score + -> [LoopBreakerNode] -- Nodes with higher scores + -> [LoopBreakerNode] -- Unprocessed nodes + -> ([LoopBreakerNode], [LoopBreakerNode]) -- This loop looks for the bind with the lowest score -- to pick as the loop breaker. The rest accumulate in chooseLoopBreaker _ _ loop_nodes acc [] @@ -1189,7 +1306,7 @@ chooseLoopBreaker approx_lb loop_sc loop_nodes acc (node : nodes) | otherwise -- Worse score so don't pick it = chooseLoopBreaker approx_lb loop_sc loop_nodes (node : acc) nodes where - sc = nd_score (node_payload node) + sc = snd_score (node_payload node) {- Note [Complexity of loop breaking] @@ -1322,16 +1439,21 @@ ToDo: try using the occurrence info for the inline'd binder. ************************************************************************ -} -type LetrecNode = Node Unique Details -- Node comes from Digraph - -- The Unique key is gotten from the Id -data Details - = ND { nd_bndr :: Id -- Binder +-- | Digraph node as constructed by 'makeNode' and consumed by 'occAnalRec'. +-- The Unique key is gotten from the Id. +type LetrecNode = Node Unique NodeDetails - , nd_rhs :: CoreExpr -- RHS, already occ-analysed +-- | Node details as consumed by 'occAnalRec'. +data NodeDetails + = ND { nd_bndr :: Id -- Binder - , nd_uds :: UsageDetails -- Usage from RHS, and RULES, and stable unfoldings - -- ignoring phase (ie assuming all are active) - -- See Note [Forming Rec groups] + , nd_rhs :: !(WithTailUsageDetails CoreExpr) + -- ^ RHS, already occ-analysed + -- With TailUsageDetails from RHS, and RULES, and stable unfoldings, + -- ignoring phase (ie assuming all are active). + -- NB: Unadjusted TailUsageDetails, as if this Node becomes a + -- non-recursive join point! + -- See Note [TailUsageDetails when forming Rec groups] , nd_inl :: IdSet -- Free variables of the stable unfolding and the RHS -- but excluding any RULES @@ -1348,18 +1470,33 @@ data Details , nd_active_rule_fvs :: IdSet -- Variables bound in this Rec group that are free -- in the RHS of an active rule for this bndr -- See Note [Rules and loop breakers] - - , nd_score :: NodeScore } -instance Outputable Details where +instance Outputable NodeDetails where ppr nd = text "ND" <> braces (sep [ text "bndr =" <+> ppr (nd_bndr nd) - , text "uds =" <+> ppr (nd_uds nd) + , text "uds =" <+> ppr uds , text "inl =" <+> ppr (nd_inl nd) , text "simple =" <+> ppr (nd_simple nd) , text "active_rule_fvs =" <+> ppr (nd_active_rule_fvs nd) - , text "score =" <+> ppr (nd_score nd) + ]) + where WithTailUsageDetails uds _ = nd_rhs nd + +-- | Digraph with simplified and completely occurrence analysed +-- 'SimpleNodeDetails', retaining just the info we need for breaking loops. +type LoopBreakerNode = Node Unique SimpleNodeDetails + +-- | Condensed variant of 'NodeDetails' needed during loop breaking. +data SimpleNodeDetails + = SND { snd_bndr :: IdWithOccInfo -- OccInfo accurate + , snd_rhs :: CoreExpr -- properly occur-analysed + , snd_score :: NodeScore + } + +instance Outputable SimpleNodeDetails where + ppr nd = text "SND" <> braces + (sep [ text "bndr =" <+> ppr (snd_bndr nd) + , text "score =" <+> ppr (snd_score nd) ]) -- The NodeScore is compared lexicographically; @@ -1387,52 +1524,59 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) -- explained in Note [Deterministic SCC] in GHC.Data.Graph.Directed. where details = ND { nd_bndr = bndr' - , nd_rhs = rhs' - , nd_uds = scope_uds + , nd_rhs = WithTailUsageDetails scope_uds rhs' , nd_inl = inl_fvs , nd_simple = null rules_w_uds && null imp_rule_info , nd_weak_fvs = weak_fvs - , nd_active_rule_fvs = active_rule_fvs - , nd_score = pprPanic "makeNodeDetails" (ppr bndr) } + , nd_active_rule_fvs = active_rule_fvs } bndr' = bndr `setIdUnfolding` unf' `setIdSpecialisation` mkRuleInfo rules' - inl_uds = rhs_uds `andUDs` unf_uds - scope_uds = inl_uds `andUDs` rule_uds + -- NB: Both adj_unf_uds and adj_rule_uds have been adjusted to match the + -- JoinArity rhs_ja of unadj_rhs_uds. + unadj_inl_uds = unadj_rhs_uds `andUDs` adj_unf_uds + unadj_scope_uds = unadj_inl_uds `andUDs` adj_rule_uds + scope_uds = TUD rhs_ja unadj_scope_uds -- Note [Rules are extra RHSs] -- Note [Rule dependency info] - scope_fvs = udFreeVars bndr_set scope_uds + scope_fvs = udFreeVars bndr_set unadj_scope_uds -- scope_fvs: all occurrences from this binder: RHS, unfolding, -- and RULES, both LHS and RHS thereof, active or inactive - inl_fvs = udFreeVars bndr_set inl_uds + inl_fvs = udFreeVars bndr_set unadj_inl_uds -- inl_fvs: vars that would become free if the function was inlined. -- We conservatively approximate that by thefree vars from the RHS -- and the unfolding together. -- See Note [inl_fvs] - mb_join_arity = isJoinId_maybe bndr - -- Get join point info from the *current* decision - -- We don't know what the new decision will be! - -- Using the old decision at least allows us to - -- preserve existing join point, even RULEs are added - -- See Note [Join points and unfoldings/rules] --------- Right hand side --------- -- Constructing the edges for the main Rec computation -- See Note [Forming Rec groups] - -- Do not use occAnalRhs because we don't yet know the final - -- answer for mb_join_arity; instead, do the occAnalLam call from - -- occAnalRhs, and postpone adjustRhsUsage until occAnalRec - rhs_env = rhsCtxt env - (WithUsageDetails rhs_uds rhs') = occAnalLam rhs_env rhs + -- and Note [TailUsageDetails when forming Rec groups] + -- Compared to occAnalNonRecBind, we can't yet adjust the RHS because + -- (a) we don't yet know the final joinpointhood. It might not become a + -- join point after all! + -- (b) we don't even know whether it stays a recursive RHS after the SCC + -- analysis we are about to seed! So we can't markAllInsideLam in + -- advance, because if it ends up as a non-recursive join point we'll + -- consider it as one-shot and don't need to markAllInsideLam. + -- Instead, do the occAnalLamTail call here and postpone adjustTailUsage + -- until occAnalRec. In effect, we pretend that the RHS becomes a + -- non-recursive join point and fix up later with adjustTailUsage. + rhs_env = rhsCtxt env + WithTailUsageDetails (TUD rhs_ja unadj_rhs_uds) rhs' = occAnalLamTail rhs_env rhs + -- corresponding call to adjustTailUsage in occAnalRec and tagRecBinders --------- Unfolding --------- - -- See Note [Unfoldings and join points] + -- See Note [Join points and unfoldings/rules] unf = realIdUnfolding bndr -- realIdUnfolding: Ignore loop-breaker-ness -- here because that is what we are setting! - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env Recursive mb_join_arity unf + WithTailUsageDetails unf_tuds unf' = occAnalUnfolding rhs_env unf + adj_unf_uds = adjustTailArity (Just rhs_ja) unf_tuds + -- `rhs_ja` is `joinRhsArity rhs` and is the prediction for source M + -- of Note [Join arity prediction based on joinRhsArity] --------- IMP-RULES -------- is_active = occ_rule_act env :: Activation -> Bool @@ -1441,11 +1585,15 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) imp_rule_fvs = impRulesActiveFvs is_active bndr_set imp_rule_info --------- All rules -------- + -- See Note [Join points and unfoldings/rules] + -- `rhs_ja` is `joinRhsArity rhs'` and is the prediction for source M + -- of Note [Join arity prediction based on joinRhsArity] rules_w_uds :: [(CoreRule, UsageDetails, UsageDetails)] - rules_w_uds = occAnalRules rhs_env mb_join_arity bndr + rules_w_uds = [ (r,l,adjustTailArity (Just rhs_ja) rhs_tuds) + | (r,l,rhs_tuds) <- occAnalRules rhs_env bndr ] rules' = map fstOf3 rules_w_uds - rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds + adj_rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds add_rule_uds (_, l, r) uds = l `andUDs` r `andUDs` uds -------- active_rule_fvs ------------ @@ -1463,8 +1611,8 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) mkLoopBreakerNodes :: OccEnv -> TopLevelFlag -> UsageDetails -- for BODY of let - -> [Details] - -> WithUsageDetails [LetrecNode] -- adjusted + -> [NodeDetails] + -> WithUsageDetails [LoopBreakerNode] -- with OccInfo up-to-date -- See Note [Choosing loop breakers] -- This function primarily creates the Nodes for the -- loop-breaker SCC analysis. More specifically: @@ -1477,10 +1625,10 @@ mkLoopBreakerNodes :: OccEnv -> TopLevelFlag mkLoopBreakerNodes !env lvl body_uds details_s = WithUsageDetails final_uds (zipWithEqual "mkLoopBreakerNodes" mk_lb_node details_s bndrs') where - (final_uds, bndrs') = tagRecBinders lvl body_uds details_s + WithUsageDetails final_uds bndrs' = tagRecBinders lvl body_uds details_s mk_lb_node nd@(ND { nd_bndr = old_bndr, nd_inl = inl_fvs }) new_bndr - = DigraphNode { node_payload = new_nd + = DigraphNode { node_payload = simple_nd , node_key = varUnique old_bndr , node_dependencies = nonDetKeysUniqSet lb_deps } -- It's OK to use nonDetKeysUniqSet here as @@ -1488,7 +1636,8 @@ mkLoopBreakerNodes !env lvl body_uds details_s -- in nondeterministic order as explained in -- Note [Deterministic SCC] in GHC.Data.Graph.Directed. where - new_nd = nd { nd_bndr = new_bndr, nd_score = score } + WithTailUsageDetails _ rhs = nd_rhs nd + simple_nd = SND { snd_bndr = new_bndr, snd_rhs = rhs, snd_score = score } score = nodeScore env new_bndr lb_deps nd lb_deps = extendFvs_ rule_fv_env inl_fvs -- See Note [Loop breaker dependencies] @@ -1524,10 +1673,10 @@ group { f1 = e1; ...; fn = en } are: nodeScore :: OccEnv -> Id -- Binder with new occ-info -> VarSet -- Loop-breaker dependencies - -> Details + -> NodeDetails -> NodeScore nodeScore !env new_bndr lb_deps - (ND { nd_bndr = old_bndr, nd_rhs = bind_rhs }) + (ND { nd_bndr = old_bndr, nd_rhs = WithTailUsageDetails _ bind_rhs }) | not (isId old_bndr) -- A type or coercion variable is never a loop breaker = (100, 0, False) @@ -1748,7 +1897,7 @@ lambda and casts, e.g. * Occurrence analyser: we just mark each binder in the lambda-group (here: x,y,z) with its occurrence info in the *body* of the - lambda-group. See occAnalLam. + lambda-group. See occAnalLamTail. * Simplifier. The simplifier is careful when partially applying lambda-groups. See the call to zapLambdaBndrs in @@ -1804,25 +1953,31 @@ zapLambdaBndrs fun arg_count zap_bndr b | isTyVar b = b | otherwise = zapLamIdInfo b -occAnalLam :: OccEnv -> CoreExpr -> (WithUsageDetails CoreExpr) --- See Note [Occurrence analysis for lambda binders] +occAnalLamTail :: OccEnv -> CoreExpr -> WithTailUsageDetails CoreExpr +-- ^ See Note [Occurrence analysis for lambda binders]. -- It does the following: -- * Sets one-shot info on the lambda binder from the OccEnv, and -- removes that one-shot info from the OccEnv -- * Sets the OccEnv to OccVanilla when going under a value lambda -- * Tags each lambda with its occurrence information -- * Walks through casts +-- * Package up the analysed lambda with its manifest join arity +-- -- This function does /not/ do -- markAllInsideLam or -- markAllNonTail --- The caller does that, either in occAnal (Lam {}), or in adjustRhsUsage +-- The caller does that, via adjustTailUsage (mostly calls go through +-- adjustNonRecRhs). Every call to occAnalLamTail must ultimately call +-- adjustTailUsage to discharge the assumed join arity. +-- +-- In effect, the analysis result is for a non-recursive join point with +-- manifest arity and adjustTailUsage does the fixup. -- See Note [Adjusting right-hand sides] - -occAnalLam env (Lam bndr expr) +occAnalLamTail env (Lam bndr expr) | isTyVar bndr - = let env1 = addOneInScope env bndr - WithUsageDetails usage expr' = occAnalLam env1 expr - in WithUsageDetails usage (Lam bndr expr') + , let env1 = addOneInScope env bndr + , WithTailUsageDetails (TUD ja usage) expr' <- occAnalLamTail env1 expr + = WithTailUsageDetails (TUD (ja+1) usage) (Lam bndr expr') -- Important: Keep the 'env' unchanged so that with a RHS like -- \(@ x) -> K @x (f @x) -- we'll see that (K @x (f @x)) is in a OccRhs, and hence refrain @@ -1840,14 +1995,14 @@ occAnalLam env (Lam bndr expr) env1 = env { occ_encl = OccVanilla, occ_one_shots = env_one_shots' } env2 = addOneInScope env1 bndr - (WithUsageDetails usage expr') = occAnalLam env2 expr + WithTailUsageDetails (TUD ja usage) expr' = occAnalLamTail env2 expr (usage', bndr2) = tagLamBinder usage bndr1 - in WithUsageDetails usage' (Lam bndr2 expr') + in WithTailUsageDetails (TUD (ja+1) usage') (Lam bndr2 expr') -- For casts, keep going in the same lambda-group -- See Note [Occurrence analysis for lambda binders] -occAnalLam env (Cast expr co) - = let (WithUsageDetails usage expr') = occAnalLam env expr +occAnalLamTail env (Cast expr co) + = let WithTailUsageDetails (TUD ja usage) expr' = occAnalLamTail env expr -- usage1: see Note [Gather occurrences of coercion variables] usage1 = addManyOccs usage (coVarsOfCo co) @@ -1857,15 +2012,16 @@ occAnalLam env (Cast expr co) _ -> usage1 -- usage3: you might think this was not necessary, because of - -- the markAllNonTail in adjustRhsUsage; but not so! For a - -- join point, adjustRhsUsage doesn't do this; yet if there is + -- the markAllNonTail in adjustTailUsage; but not so! For a + -- join point, adjustTailUsage doesn't do this; yet if there is -- a cast, we must! Also: why markAllNonTail? See -- GHC.Core.Lint: Note Note [Join points and casts] usage3 = markAllNonTail usage2 - in WithUsageDetails usage3 (Cast expr' co) + in WithTailUsageDetails (TUD ja usage3) (Cast expr' co) -occAnalLam env expr = occAnal env expr +occAnalLamTail env expr = case occAnal env expr of + WithUsageDetails usage expr' -> WithTailUsageDetails (TUD 0 usage) expr' {- Note [Occ-anal and cast worker/wrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1885,8 +2041,8 @@ RHS. So it'll get a Many occ-info. (Maybe Cast w/w should create a stable unfolding, which would obviate this Note; but that seems a bit of a heavyweight solution.) -We only need to this in occAnalLam, not occAnal, because the top leve -of a right hand side is handled by occAnalLam. +We only need to this in occAnalLamTail, not occAnal, because the top leve +of a right hand side is handled by occAnalLamTail. -} @@ -1896,57 +2052,23 @@ of a right hand side is handled by occAnalLam. * * ********************************************************************* -} -occAnalRhs :: OccEnv -> RecFlag -> Maybe JoinArity - -> CoreExpr -- RHS - -> WithUsageDetails CoreExpr -occAnalRhs !env is_rec mb_join_arity rhs - = let (WithUsageDetails usage rhs1) = occAnalLam env rhs - -- We call occAnalLam here, not occAnalExpr, so that it doesn't - -- do the markAllInsideLam and markNonTailCall stuff before - -- we've had a chance to help with join points; that comes next - rhs2 = markJoinOneShots is_rec mb_join_arity rhs1 - rhs_usage = adjustRhsUsage mb_join_arity rhs2 usage - in WithUsageDetails rhs_usage rhs2 - - - -markJoinOneShots :: RecFlag -> Maybe JoinArity -> CoreExpr -> CoreExpr --- For a /non-recursive/ join point we can mark all --- its join-lambda as one-shot; and it's a good idea to do so -markJoinOneShots NonRecursive (Just join_arity) rhs - = go join_arity rhs - where - go 0 rhs = rhs - go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) - (go (n-1) rhs) - go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. - -- e.g. let j = case ... in j True - -- This will become an arity-1 join point after the - -- simplifier has eta-expanded it; but it may not have - -- enough lambdas /yet/. (Lint checks that JoinIds do - -- have enough lambdas.) -markJoinOneShots _ _ rhs - = rhs - occAnalUnfolding :: OccEnv - -> RecFlag - -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Unfolding - -> WithUsageDetails Unfolding + -> WithTailUsageDetails Unfolding -- Occurrence-analyse a stable unfolding; --- discard a non-stable one altogether. -occAnalUnfolding !env is_rec mb_join_arity unf +-- discard a non-stable one altogether and return empty usage details. +occAnalUnfolding !env unf = case unf of unf@(CoreUnfolding { uf_tmpl = rhs, uf_src = src }) | isStableSource src -> let - (WithUsageDetails usage rhs') = occAnalRhs env is_rec mb_join_arity rhs + WithTailUsageDetails (TUD rhs_ja usage) rhs' = occAnalLamTail env rhs unf' | noBinderSwaps env = unf -- Note [Unfoldings and rules] | otherwise = unf { uf_tmpl = rhs' } - in WithUsageDetails (markAllMany usage) unf' + in WithTailUsageDetails (TUD rhs_ja (markAllMany usage)) unf' -- markAllMany: see Note [Occurrences in stable unfoldings] - | otherwise -> WithUsageDetails emptyDetails unf + | otherwise -> WithTailUsageDetails (TUD 0 emptyDetails) unf -- For non-Stable unfoldings we leave them undisturbed, but -- don't count their usage because the simplifier will discard them. -- We leave them undisturbed because nodeScore uses their size info @@ -1955,29 +2077,26 @@ occAnalUnfolding !env is_rec mb_join_arity unf -- scope remain in scope; there is no cloning etc. unf@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) - -> WithUsageDetails final_usage (unf { df_args = args' }) + -> WithTailUsageDetails (TUD 0 final_usage) (unf { df_args = args' }) where env' = env `addInScope` bndrs (WithUsageDetails usage args') = occAnalList env' args - final_usage = markAllManyNonTail (delDetailsList usage bndrs) - `addLamCoVarOccs` bndrs - `delDetailsList` bndrs + final_usage = usage `addLamCoVarOccs` bndrs `delDetailsList` bndrs -- delDetailsList; no need to use tagLamBinders because we -- never inline DFuns so the occ-info on binders doesn't matter - unf -> WithUsageDetails emptyDetails unf + unf -> WithTailUsageDetails (TUD 0 emptyDetails) unf occAnalRules :: OccEnv - -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Id -- Get rules from here -> [(CoreRule, -- Each (non-built-in) rule UsageDetails, -- Usage details for LHS - UsageDetails)] -- Usage details for RHS -occAnalRules !env mb_join_arity bndr + TailUsageDetails)] -- Usage details for RHS +occAnalRules !env bndr = map occ_anal_rule (idCoreRules bndr) where occ_anal_rule rule@(Rule { ru_bndrs = bndrs, ru_args = args, ru_rhs = rhs }) - = (rule', lhs_uds', rhs_uds') + = (rule', lhs_uds', TUD rhs_ja rhs_uds') where env' = env `addInScope` bndrs rule' | noBinderSwaps env = rule -- Note [Unfoldings and rules] @@ -1990,14 +2109,11 @@ occAnalRules !env mb_join_arity bndr (WithUsageDetails rhs_uds rhs') = occAnal env' rhs -- Note [Rules are extra RHSs] -- Note [Rule dependency info] - rhs_uds' = markAllNonTailIf (not exact_join) $ - markAllMany $ + rhs_uds' = markAllMany $ rhs_uds `delDetailsList` bndrs + rhs_ja = length args -- See Note [Join points and unfoldings/rules] - exact_join = exactJoin mb_join_arity args - -- See Note [Join points and unfoldings/rules] - - occ_anal_rule other_rule = (other_rule, emptyDetails, emptyDetails) + occ_anal_rule other_rule = (other_rule, emptyDetails, TUD 0 emptyDetails) {- Note [Join point RHSs] ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2032,6 +2148,8 @@ Another way to think about it: if we inlined g as-is into multiple call sites, now there's be multiple calls to f. Bottom line: treat all occurrences in a stable unfolding as "Many". +We still leave tail call information intact, though, as to not spoil +potential join points. Note [Unfoldings and rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2209,10 +2327,7 @@ occAnal env app@(App _ _) = occAnalApp env (collectArgsTicks tickishFloatable app) occAnal env expr@(Lam {}) - = let (WithUsageDetails usage expr') = occAnalLam env expr - final_usage = markAllInsideLamIf (not (isOneShotFun expr')) $ - markAllNonTail usage - in WithUsageDetails final_usage expr' + = adjustNonRecRhs Nothing $ occAnalLamTail env expr -- mb_join_arity == Nothing <=> markAllManyNonTail occAnal env (Case scrut bndr ty alts) = let @@ -2287,7 +2402,7 @@ occAnalApp !env (Var fun, args, ticks) -- This caused #18296 | fun `hasKey` runRWKey , [t1, t2, arg] <- args - , let (WithUsageDetails usage arg') = occAnalRhs env NonRecursive (Just 1) arg + , WithUsageDetails usage arg' <- adjustNonRecRhs (Just 1) $ occAnalLamTail env arg = WithUsageDetails usage (mkTicks ticks $ mkApps (Var fun) [t1, t2, arg']) occAnalApp env (Var fun_id, args, ticks) @@ -2872,7 +2987,6 @@ lookupBndrSwap env@(OccEnv { occ_bs_env = bs_env }) bndr case lookupBndrSwap env bndr1 of (fun, fun_id) -> (mkCastMCo fun mco, fun_id) } - {- Historical note [Proxy let-bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We used to do the binder-swap transformation by introducing @@ -2998,6 +3112,19 @@ data UsageDetails instance Outputable UsageDetails where ppr ud = ppr (ud_env (flattenUsageDetails ud)) +-- | Captures the result of applying 'occAnalLamTail' to a function `\xyz.body`. +-- The TailUsageDetails records +-- * the number of lambdas (including type lambdas: a JoinArity) +-- * UsageDetails for the `body`, unadjusted by `adjustTailUsage`. +-- If the binding turns out to be a join point with the indicated join +-- arity, this unadjusted usage details is just what we need; otherwise we +-- need to discard tail calls. That's what `adjustTailUsage` does. +data TailUsageDetails = TUD !JoinArity !UsageDetails + +instance Outputable TailUsageDetails where + ppr (TUD ja uds) = lambda <> ppr ja <> ppr uds + + ------------------- -- UsageDetails API @@ -3139,24 +3266,49 @@ flattenUsageDetails ud@(UD { ud_env = env }) ------------------- -- See Note [Adjusting right-hand sides] -adjustRhsUsage :: Maybe JoinArity - -> CoreExpr -- Rhs, AFTER occ anal - -> UsageDetails -- From body of lambda +adjustTailUsage :: Maybe JoinArity + -> CoreExpr -- Rhs, AFTER occAnalLamTail + -> TailUsageDetails -- From body of lambda -> UsageDetails -adjustRhsUsage mb_join_arity rhs usage +adjustTailUsage mb_join_arity rhs (TUD rhs_ja usage) = -- c.f. occAnal (Lam {}) markAllInsideLamIf (not one_shot) $ markAllNonTailIf (not exact_join) $ usage where one_shot = isOneShotFun rhs - exact_join = exactJoin mb_join_arity bndrs - (bndrs,_) = collectBinders rhs + exact_join = mb_join_arity == Just rhs_ja + +adjustTailArity :: Maybe JoinArity -> TailUsageDetails -> UsageDetails +adjustTailArity mb_rhs_ja (TUD ud_ja usage) = + markAllNonTailIf (mb_rhs_ja /= Just ud_ja) usage + +markNonRecJoinOneShots :: JoinArity -> CoreExpr -> CoreExpr +-- For a /non-recursive/ join point we can mark all +-- its join-lambda as one-shot; and it's a good idea to do so +markNonRecJoinOneShots join_arity rhs + = go join_arity rhs + where + go 0 rhs = rhs + go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) + (go (n-1) rhs) + go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. + -- e.g. let j = case ... in j True + -- This will become an arity-1 join point after the + -- simplifier has eta-expanded it; but it may not have + -- enough lambdas /yet/. (Lint checks that JoinIds do + -- have enough lambdas.) -exactJoin :: Maybe JoinArity -> [a] -> Bool -exactJoin Nothing _ = False -exactJoin (Just join_arity) args = args `lengthIs` join_arity - -- Remember join_arity includes type binders +markNonRecUnfoldingOneShots :: Maybe JoinArity -> Unfolding -> Unfolding +-- ^ Apply 'markNonRecJoinOneShots' to a stable unfolding +markNonRecUnfoldingOneShots mb_join_arity unf + | Just ja <- mb_join_arity + , CoreUnfolding{uf_src=src,uf_tmpl=tmpl} <- unf + , isStableSource src + , let !tmpl' = markNonRecJoinOneShots ja tmpl + = unf{uf_tmpl=tmpl'} + | otherwise + = unf type IdWithOccInfo = Id @@ -3192,8 +3344,8 @@ tagLamBinder usage bndr tagNonRecBinder :: TopLevelFlag -- At top level? -> UsageDetails -- Of scope -> CoreBndr -- Binder - -> (UsageDetails, -- Details with binder removed - IdWithOccInfo) -- Tagged binder + -> WithUsageDetails -- Details with binder removed + IdWithOccInfo -- Tagged binder tagNonRecBinder lvl usage binder = let @@ -3205,37 +3357,34 @@ tagNonRecBinder lvl usage binder binder' = setBinderOcc occ' binder usage' = usage `delDetails` binder in - usage' `seq` (usage', binder') + WithUsageDetails usage' binder' tagRecBinders :: TopLevelFlag -- At top level? -> UsageDetails -- Of body of let ONLY - -> [Details] - -> (UsageDetails, -- Adjusted details for whole scope, + -> [NodeDetails] + -> WithUsageDetails -- Adjusted details for whole scope, -- with binders removed - [IdWithOccInfo]) -- Tagged binders + [IdWithOccInfo] -- Tagged binders -- Substantially more complicated than non-recursive case. Need to adjust RHS -- details *before* tagging binders (because the tags depend on the RHSes). tagRecBinders lvl body_uds details_s = let bndrs = map nd_bndr details_s - rhs_udss = map nd_uds details_s - -- 1. Determine join-point-hood of whole group, as determined by - -- the *unadjusted* usage details - unadj_uds = foldr andUDs body_uds rhs_udss + -- 1. See Note [Join arity prediction based on joinRhsArity] + -- Determine possible join-point-hood of whole group, by testing for + -- manifest join arity M. + -- This (re-)asserts that makeNode had made tuds for that same arity M! + unadj_uds = foldr (andUDs . test_manifest_arity) body_uds details_s + test_manifest_arity ND{nd_rhs=WithTailUsageDetails tuds rhs} + = adjustTailArity (Just (joinRhsArity rhs)) tuds - -- This is only used in `mb_join_arity`, to adjust each `Details` in `details_s`, thus, - -- when `bndrs` is non-empty. So, we only write `maybe False` as `decideJoinPointHood` - -- takes a `NonEmpty CoreBndr`; the default value `False` won't affect program behavior. - will_be_joins = maybe False (decideJoinPointHood lvl unadj_uds) (nonEmpty bndrs) - - -- 2. Adjust usage details of each RHS, taking into account the - -- join-point-hood decision - rhs_udss' = [ adjustRhsUsage (mb_join_arity bndr) rhs rhs_uds - | ND { nd_bndr = bndr, nd_uds = rhs_uds - , nd_rhs = rhs } <- details_s ] + bndr_ne = expectNonEmpty "List of binders is never empty" bndrs + will_be_joins = decideJoinPointHood lvl unadj_uds bndr_ne mb_join_arity :: Id -> Maybe JoinArity + -- mb_join_arity: See Note [Join arity prediction based on joinRhsArity] + -- This is the source O mb_join_arity bndr -- Can't use willBeJoinId_maybe here because we haven't tagged -- the binder yet (the tag depends on these adjustments!) @@ -3247,6 +3396,12 @@ tagRecBinders lvl body_uds details_s = assert (not will_be_joins) -- Should be AlwaysTailCalled if Nothing -- we are making join points! + -- 2. Adjust usage details of each RHS, taking into account the + -- join-point-hood decision + rhs_udss' = [ adjustTailUsage (mb_join_arity bndr) rhs rhs_tuds -- matching occAnalLamTail in makeNode + | ND { nd_bndr = bndr, nd_rhs = WithTailUsageDetails rhs_tuds rhs } + <- details_s ] + -- 3. Compute final usage details from adjusted RHS details adj_uds = foldr andUDs body_uds rhs_udss' @@ -3257,7 +3412,7 @@ tagRecBinders lvl body_uds details_s -- 5. Drop the binders from the adjusted details and return usage' = adj_uds `delDetailsList` bndrs in - (usage', bndrs') + WithUsageDetails usage' bndrs' setBinderOcc :: OccInfo -> CoreBndr -> CoreBndr setBinderOcc occ_info bndr @@ -3271,12 +3426,13 @@ setBinderOcc occ_info bndr | otherwise = setIdOccInfo bndr occ_info --- | Decide whether some bindings should be made into join points or not. +-- | Decide whether some bindings should be made into join points or not, based +-- on its occurrences. This is -- Returns `False` if they can't be join points. Note that it's an -- all-or-nothing decision, as if multiple binders are given, they're -- assumed to be mutually recursive. -- --- It must, however, be a final decision. If we say "True" for 'f', +-- It must, however, be a final decision. If we say `True` for 'f', -- and then subsequently decide /not/ make 'f' into a join point, then -- the decision about another binding 'g' might be invalidated if (say) -- 'f' tail-calls 'g'. ===================================== compiler/GHC/Data/Graph/Directed.hs ===================================== @@ -4,6 +4,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE DeriveFunctor #-} module GHC.Data.Graph.Directed ( Graph, graphFromEdgedVerticesOrd, graphFromEdgedVerticesUniq, @@ -108,7 +109,7 @@ data Node key payload = DigraphNode { node_payload :: payload, -- ^ User data node_key :: key, -- ^ User defined node id node_dependencies :: [key] -- ^ Dependencies/successors of the node - } + } deriving Functor instance (Outputable a, Outputable b) => Outputable (Node a b) where ===================================== compiler/GHC/Utils/Misc.hs ===================================== @@ -35,7 +35,7 @@ module GHC.Utils.Misc ( equalLength, compareLength, leLength, ltLength, isSingleton, only, expectOnly, GHC.Utils.Misc.singleton, - notNull, snocView, + notNull, expectNonEmpty, snocView, chunkList, @@ -481,7 +481,6 @@ expectOnly _ (a:_) = a #endif expectOnly msg _ = panic ("expectOnly: " ++ msg) - -- | Split a list into chunks of /n/ elements chunkList :: Int -> [a] -> [[a]] chunkList _ [] = [] @@ -500,6 +499,16 @@ changeLast [] _ = panic "changeLast" changeLast [_] x = [x] changeLast (x:xs) x' = x : changeLast xs x' +-- | Like @expectJust msg . nonEmpty@; a better alternative to 'NE.fromList'. +expectNonEmpty :: HasCallStack => String -> [a] -> NonEmpty a +{-# INLINE expectNonEmpty #-} +expectNonEmpty _ (x:xs) = x:|xs +expectNonEmpty msg [] = expectNonEmptyPanic msg + +expectNonEmptyPanic :: String -> a +expectNonEmptyPanic msg = panic ("expectNonEmpty: " ++ msg) +{-# NOINLINE expectNonEmptyPanic #-} + -- | Apply an effectful function to the last list element. mapLastM :: Functor f => (a -> f a) -> NonEmpty a -> f (NonEmpty a) mapLastM f (x:|[]) = NE.singleton <$> f x ===================================== testsuite/tests/simplCore/should_compile/T22428.hs ===================================== @@ -0,0 +1,9 @@ +module T22428 where + +f :: Integer -> Integer -> Integer +f x y = go y + where + go :: Integer -> Integer + go 0 = x + go n = go (n-1) + {-# INLINE go #-} ===================================== testsuite/tests/simplCore/should_compile/T22428.stderr ===================================== @@ -0,0 +1,45 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 32, types: 14, coercions: 0, joins: 1/1} + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22428.f1 :: Integer +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22428.f1 = GHC.Num.Integer.IS 1# + +-- RHS size: {terms: 28, types: 10, coercions: 0, joins: 1/1} +f :: Integer -> Integer -> Integer +[GblId, + Arity=2, + Str=<1L>, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 0] 156 0}] +f = \ (x :: Integer) (y :: Integer) -> + joinrec { + go [InlPrag=INLINE (sat-args=1), Occ=LoopBreaker, Dmd=SC(S,L)] + :: Integer -> Integer + [LclId[JoinId(1)(Just [!])], + Arity=1, + Str=<1L>, + Unf=Unf{Src=StableUser, TopLvl=False, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=False,boring_ok=False)}] + go (ds :: Integer) + = case ds of wild { + GHC.Num.Integer.IS x1 -> + case x1 of { + __DEFAULT -> jump go (GHC.Num.Integer.integerSub wild T22428.f1); + 0# -> x + }; + GHC.Num.Integer.IP x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1); + GHC.Num.Integer.IN x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1) + }; } in + jump go y + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -451,6 +451,7 @@ test('T22375', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeab # One module, T21851_2.hs, has OPTIONS_GHC -ddump-simpl # Expecting to see $s$wwombat 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']) @@ -462,3 +463,6 @@ test('T22272', normal, multimod_compile, ['T22272', '-O -fexpose-all-unfoldings test('T22459', normal, compile, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) test('T22662', normal, compile, ['']) + +# go should become a join point +test('T22428', [grep_errmsg(r'jump go') ], compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeable-binds -dsuppress-unfoldings']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/be991556c5b1b09f70789b9930746e3783603e5f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/be991556c5b1b09f70789b9930746e3783603e5f You're receiving 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 Jan 10 11:04:11 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 10 Jan 2023 06:04:11 -0500 Subject: [Git][ghc/ghc][wip/T22428] Fix contification with stable unfoldings (#22428) Message-ID: <63bd462b1ce56_3b1bf93fcc9904612af@gitlab.mail> Sebastian Graf pushed to branch wip/T22428 at Glasgow Haskell Compiler / GHC Commits: c73f2999 by Sebastian Graf at 2023-01-10T12:03:59+01:00 Fix contification with stable unfoldings (#22428) Many functions now return a `TailUsageDetails` that adorns a `UsageDetails` with a `JoinArity` that reflects the number of join point binders around the body for which the `UsageDetails` was computed. `TailUsageDetails` is now returned by `occAnalLamTail` as well as `occAnalUnfolding` and `occAnalRules`. I adjusted `Note [Join points and unfoldings/rules]` and `Note [Adjusting right-hand sides]` to account for the new machinery. I also wrote a new `Note [Join arity prediction based on joinRhsArity]` and refer to it when we combine `TailUsageDetails` for a recursive RHS. I also renamed * `occAnalLam` to `occAnalLamTail` * `adjustRhsUsage` to `adjustTailUsage` * a few other less important functions and properly documented the that each call of `occAnalLamTail` must pair up with `adjustTailUsage`. I removed `Note [Unfoldings and join points]` because it was redundant with `Note [Occurrences in stable unfoldings]`. While in town, I refactored `mkLoopBreakerNodes` so that it returns a condensed `NodeDetails` called `SimpleNodeDetails`. Fixes #22428. Metric Decrease: T12150 T12425 T21839c T21839r T9961 - - - - - 7 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Data/Graph/Directed.hs - compiler/GHC/Utils/Misc.hs - + testsuite/tests/simplCore/should_compile/T22428.hs - + testsuite/tests/simplCore/should_compile/T22428.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -132,6 +132,9 @@ joinRhsArity :: CoreExpr -> JoinArity -- Join points are supposed to have manifestly-visible -- lambdas at the top: no ticks, no casts, nothing -- Moreover, type lambdas count in JoinArity +-- NB: For non-recursive bindings, the join arity of the binding may actually be +-- less that the number of manifestly-visible lambdas. +-- See Note [Join arity prediction based on joinRhsArity] in GHC.Core.Opt.OccurAnal joinRhsArity (Lam _ e) = 1 + joinRhsArity e joinRhsArity _ = 0 ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -59,7 +59,7 @@ import GHC.Builtin.Names( runRWKey ) import GHC.Unit.Module( Module ) import Data.List (mapAccumL, mapAccumR) -import Data.List.NonEmpty (NonEmpty (..), nonEmpty) +import Data.List.NonEmpty (NonEmpty (..)) import qualified Data.List.NonEmpty as NE {- @@ -510,6 +510,16 @@ of the file. at any of the definitions. This is done by Simplify.simplRecBind, when it calls addLetIdInfo. +Note [TailUsageDetails when forming Rec groups] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `TailUsageDetails` stored in the `nd_uds` field of a `NodeDetails` is +computed by `occAnalLamTail` applied to the RHS, not `occAnalExpr`. +That is because the binding might still become a *non-recursive join point* in +the AcyclicSCC case of dependency analysis! +Hence we do the delayed `adjustTailUsage` in `occAnalRec`/`tagRecBinders` to get +a regular, adjusted UsageDetails. +See Note [Join points and unfoldings/rules] for more details on the contract. + Note [Stable unfoldings] ~~~~~~~~~~~~~~~~~~~~~~~~ None of the above stuff about RULES applies to a stable unfolding @@ -608,6 +618,65 @@ tail call with `n` arguments (counting both value and type arguments). Otherwise 'occ_tail' will be 'NoTailCallInfo'. The tail call info flows bottom-up with the rest of 'OccInfo' until it goes on the binder. +Note [Join arity prediction based on joinRhsArity] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In general, the join arity from tail occurrences of a join point (O) may be +higher or lower than the manifest join arity of the join body (M). E.g., + + -- M > O: + let f x y = x + y -- M = 2 + in if b then f 1 else f 2 -- O = 1 + ==> { Contify for join arity 1 } + join f x = \y -> x + y + in if b then jump f 1 else jump f 2 + + -- M < O + let f = id -- M = 0 + in if ... then f 12 else f 13 -- O = 1 + ==> { Contify for join arity 1, eta-expand f } + join f x = id x + in if b then jump f 12 else jump f 13 + +But for *recursive* let, it is crucial that both arities match up, consider + + letrec f x y = if ... then f x else True + in f 42 + +Here, M=2 but O=1. If we settled for a joinrec arity of 1, the recursive jump +would not happen in a tail context! Contification is invalid here. +So indeed it is crucial to demand that M=O. + +(Side note: Actually, we could be more specific: Let O1 be the join arity of +occurrences from the letrec RHS and O2 the join arity from the let body. Then +we need M=O1 and M<=O2 and could simply eta-expand the RHS to match O2 later. +M=O is the specific case where we don't want to eta-expand. Neither the join +points paper nor GHC does this at the moment.) + +We can capitalise on this observation and conclude that *if* f could become a +joinrec (without eta-expansion), it will have join arity M. +Now, M is just the result of 'joinRhsArity', a rather simple, local analysis. +It is also the join arity inside the 'TailUsageDetails' returned by +'occAnalLamTail', so we can predict join arity without doing any fixed-point +iteration or really doing any deep traversal of let body or RHS at all. +We check for M in the 'adjustTailUsage' call inside 'tagRecBinders'. + +All this is quite apparent if you look at the contification transformation in +Fig. 5 of "Compiling without Continuations" (which does not account for +eta-expansion at all, mind you). The letrec case looks like this + + letrec f = /\as.\xs. L[us] in L'[es] + ... and a bunch of conditions establishing that f only occurs + in app heads of join arity (len as + len xs) inside us and es ... + +The syntactic form `/\as.\xs. L[us]` forces M=O iff `f` occurs in `us`. However, +for non-recursive functions, this is the definition of contification from the +paper: + + let f = /\as.\xs.u in L[es] ... conditions ... + +Note that u could be a lambda itself, as we have seen. No relationship between M +and O to exploit here. + Note [Join points and unfoldings/rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider @@ -618,8 +687,10 @@ Consider Before j is inlined, we'll have occurrences of j2 in both j's RHS and in its stable unfolding. We want to discover -j2 as a join point. So we must do the adjustRhsUsage thing -on j's RHS. That's why we pass mb_join_arity to calcUnfolding. +j2 as a join point. So 'occAnalUnfolding' returns an unadjusted +'TailUsageDetails', like 'occAnalLamTail'. We adjust the usage details of the +unfolding to the actual join arity using the same 'adjustTailArity' as for +the RHS, see Note [Adjusting right-hand sides]. Same with rules. Suppose we have: @@ -636,14 +707,31 @@ up. So provided the join-point arity of k matches the args of the rule we can allow the tail-call info from the RHS of the rule to propagate. -* Wrinkle for Rec case. In the recursive case we don't know the - join-point arity in advance, when calling occAnalUnfolding and - occAnalRules. (See makeNode.) We don't want to pass Nothing, - because then a recursive joinrec might lose its join-poin-hood - when SpecConstr adds a RULE. So we just make do with the - *current* join-poin-hood, stored in the Id. +* Note that the join arity of the RHS and that of the unfolding or RULE might + mismatch: + + let j x y = j2 (x+x) + {-# INLINE[2] j = \x. g #-} + {-# RULE forall x y z. j x y z = h 17 #-} + in j 1 2 - In the non-recursive case things are simple: see occAnalNonRecBind + So it is crucial that we adjust each TailUsageDetails individually + with the actual join arity 2 here before we combine with `andUDs`. + Here, that means losing tail call info on `g` and `h`. + +* Wrinkle for Rec case: We store one TailUsageDetails in the node Details for + RHS, unfolding and RULE combined. Clearly, if they don't agree on their join + arity, we have to do some adjusting. We choose to adjust to the join arity + of the RHS, because that is likely the join arity that the join point will + have; see Note [Join arity prediction based on joinRhsArity]. + + If the guess is correct, then tail calls in the RHS are preserved; a necessary + condition for the whole binding becoming a joinrec. + The guess can only be incorrect in the 'AcyclicSCC' case when the binding + becomes a non-recursive join point with a different join arity. But then the + eventual call to 'adjustTailUsage' in 'tagRecBinders'/'occAnalRec' will + be with a different join arity and destroy unsound tail call info with + 'markNonTail'. * Wrinkle for RULES. Suppose the example was a bit different: let j :: Int -> Int @@ -669,28 +757,21 @@ propagate. This appears to be very rare in practice. TODO Perhaps we should gather statistics to be sure. -Note [Unfoldings and join points] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We assume that anything in an unfolding occurs multiple times, since -unfoldings are often copied (that's the whole point!). But we still -need to track tail calls for the purpose of finding join points. - - ------------------------------------------------------------ Note [Adjusting right-hand sides] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There's a bit of a dance we need to do after analysing a lambda expression or a right-hand side. In particular, we need to - a) call 'markAllInsideLam' *unless* the binding is for a thunk, a one-shot - lambda, or a non-recursive join point; and - b) call 'markAllNonTail' *unless* the binding is for a join point, and - the RHS has the right arity; e.g. + a) call 'markAllNonTail' *unless* the binding is for a join point, and + the TailUsageDetails from the RHS has the right join arity; e.g. join j x y = case ... of A -> j2 p B -> j2 q in j a b Here we want the tail calls to j2 to be tail calls of the whole expression + b) call 'markAllInsideLam' *unless* the binding is for a thunk, a one-shot + lambda, or a non-recursive join point Some examples, with how the free occurrences in e (assumed not to be a value lambda) get marked: @@ -707,26 +788,39 @@ lambda) get marked: There are a few other caveats; most importantly, if we're marking a binding as 'AlwaysTailCalled', it's *going* to be a join point, so we treat it as one so that the effect cascades properly. Consequently, at the time the RHS is -analysed, we won't know what adjustments to make; thus 'occAnalLamOrRhs' must -return the unadjusted 'UsageDetails', to be adjusted by 'adjustRhsUsage' once -join-point-hood has been decided. - -Thus the overall sequence taking place in 'occAnalNonRecBind' and -'occAnalRecBind' is as follows: - - 1. Call 'occAnalLamOrRhs' to find usage information for the RHS. - 2. Call 'tagNonRecBinder' or 'tagRecBinders', which decides whether to make +analysed, we won't know what adjustments to make; thus 'occAnalLamTail' must +return the unadjusted 'TailUsageDetails', to be adjusted by 'adjustTailUsage' +once join-point-hood has been decided and eventual one-shot annotations have +been added through 'markNonRecJoinOneShots'. + +It is not so simple to see that 'occAnalNonRecBind' and 'occAnalRecBind' indeed +perform a similar sequence of steps. Thus, here is an interleaving of events +of both functions, serving as a specification: + + 1. Call 'occAnalLamTail' to find usage information for the RHS. + Recursive case: 'makeNode' + Non-recursive case: 'occAnalNonRecBind' + 2. (Analyse the binding's scope. Done in 'occAnalBind'/`occAnal Let{}`. + Same whether recursive or not.) + 3. Call 'tagNonRecBinder' or 'tagRecBinders', which decides whether to make the binding a join point. - 3. Call 'adjustRhsUsage' accordingly. (Done as part of 'tagRecBinders' when - recursive.) - -(In the recursive case, this logic is spread between 'makeNode' and -'occAnalRec'.) + Cyclic Recursive case: 'mkLoopBreakerNodes' + Acyclic Recursive case: `occAnalRec AcyclicSCC{}` + Non-recursive case: 'occAnalNonRecBind' + 4. Non-recursive join point: Call 'markNonRecJoinOneShots' so that e.g., + FloatOut sees one-shot annotations on lambdas + Acyclic Recursive case: `occAnalRec AcyclicSCC{}` calls 'adjustNonRecRhs' + Non-recursive case: 'occAnalNonRecBind' calls 'adjustNonRecRhs' + 5. Call 'adjustTailUsage' accordingly. + Cyclic Recursive case: 'tagRecBinders' + Acyclic Recursive case: 'adjustNonRecRhs' + Non-recursive case: 'adjustNonRecRhs' -} - data WithUsageDetails a = WithUsageDetails !UsageDetails !a +data WithTailUsageDetails a = WithTailUsageDetails !TailUsageDetails !a + ------------------------------------------------------------------ -- occAnalBind ------------------------------------------------------------------ @@ -754,15 +848,13 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage = WithUsageDetails body_usage [] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr rhs'] + = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr final_rhs] where - (body_usage', tagged_bndr) = tagNonRecBinder lvl body_usage bndr - final_bndr = tagged_bndr `setIdUnfolding` unf' - `setIdSpecialisation` mkRuleInfo rules' - rhs_usage = rhs_uds `andUDs` unf_uds `andUDs` rule_uds + WithUsageDetails body_usage' tagged_bndr = tagNonRecBinder lvl body_usage bndr -- Get the join info from the *new* decision -- See Note [Join points and unfoldings/rules] + -- => join arity O of Note [Join arity prediction based on joinRhsArity] mb_join_arity = willBeJoinId_maybe tagged_bndr is_join_point = isJust mb_join_arity @@ -773,17 +865,28 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- See Note [Sources of one-shot information] rhs_env = env1 { occ_one_shots = argOneShots dmd } - (WithUsageDetails rhs_uds rhs') = occAnalRhs rhs_env NonRecursive mb_join_arity rhs + -- See Note [Join arity prediction based on joinRhsArity] + -- Match join arity O from mb_join_arity with manifest join arity M as + -- returned by of occAnalLamTail. It's totally OK for them to mismatch; + -- hence adjust the UDs from the RHS + WithUsageDetails adj_rhs_uds final_rhs + = adjustNonRecRhs mb_join_arity $ occAnalLamTail rhs_env rhs + rhs_usage = adj_rhs_uds `andUDs` adj_unf_uds `andUDs` adj_rule_uds + final_bndr = tagged_bndr `setIdSpecialisation` mkRuleInfo rules' + `setIdUnfolding` unf2 --------- Unfolding --------- - -- See Note [Unfoldings and join points] + -- See Note [Join points and unfoldings/rules] unf | isId bndr = idUnfolding bndr | otherwise = NoUnfolding - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env NonRecursive mb_join_arity unf + WithTailUsageDetails unf_uds unf1 = occAnalUnfolding rhs_env unf + !unf2 = markNonRecUnfoldingOneShots mb_join_arity unf1 + adj_unf_uds = adjustTailArity mb_join_arity unf_uds --------- Rules --------- -- See Note [Rules are extra RHSs] and Note [Rule dependency info] - rules_w_uds = occAnalRules rhs_env mb_join_arity bndr + -- and Note [Join points and unfoldings/rules] + rules_w_uds = occAnalRules rhs_env bndr rules' = map fstOf3 rules_w_uds imp_rule_uds = impRulesScopeUsage (lookupImpRules imp_rule_edges bndr) -- imp_rule_uds: consider @@ -794,8 +897,9 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- that g is (since the RULE might turn g into h), so -- we make g mention h. - rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds - add_rule_uds (_, l, r) uds = l `andUDs` r `andUDs` uds + adj_rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds + add_rule_uds (_, l, r) uds + = l `andUDs` adjustTailArity mb_join_arity r `andUDs` uds ---------- occ = idOccInfo tagged_bndr @@ -820,7 +924,7 @@ occAnalRecBind :: OccEnv -> TopLevelFlag -> ImpRuleEdges -> [(Var,CoreExpr)] occAnalRecBind !env lvl imp_rule_edges pairs body_usage = foldr (occAnalRec rhs_env lvl) (WithUsageDetails body_usage []) sccs where - sccs :: [SCC Details] + sccs :: [SCC NodeDetails] sccs = {-# SCC "occAnalBind.scc" #-} stronglyConnCompFromEdgedVerticesUniq nodes @@ -832,27 +936,41 @@ occAnalRecBind !env lvl imp_rule_edges pairs body_usage bndr_set = mkVarSet bndrs rhs_env = env `addInScope` bndrs +adjustNonRecRhs :: Maybe JoinArity -> WithTailUsageDetails CoreExpr -> WithUsageDetails CoreExpr +-- ^ This function concentrates shared logic between occAnalNonRecBind and the +-- AcyclicSCC case of occAnalRec. +-- * It applies 'markNonRecJoinOneShots' to the RHS +-- * and returns the adjusted rhs UsageDetails combined with the body usage +adjustNonRecRhs mb_join_arity (WithTailUsageDetails rhs_tuds rhs) + = WithUsageDetails rhs_uds' rhs' + where + --------- Marking (non-rec) join binders one-shot --------- + !rhs' | Just ja <- mb_join_arity = markNonRecJoinOneShots ja rhs + | otherwise = rhs + --------- Adjusting right-hand side usage --------- + rhs_uds' = adjustTailUsage mb_join_arity rhs' rhs_tuds ----------------------------- occAnalRec :: OccEnv -> TopLevelFlag - -> SCC Details + -> SCC NodeDetails -> WithUsageDetails [CoreBind] -> WithUsageDetails [CoreBind] -- The NonRec case is just like a Let (NonRec ...) above -occAnalRec !_ lvl (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = rhs - , nd_uds = rhs_uds })) +occAnalRec !_ lvl + (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = wtuds })) (WithUsageDetails body_uds binds) | not (bndr `usedIn` body_uds) = WithUsageDetails body_uds binds -- See Note [Dead code] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_uds' `andUDs` rhs_uds') - (NonRec tagged_bndr rhs : binds) + = WithUsageDetails (body_uds' `andUDs` rhs_uds') (NonRec bndr' rhs' : binds) where - (body_uds', tagged_bndr) = tagNonRecBinder lvl body_uds bndr - rhs_uds' = adjustRhsUsage mb_join_arity rhs rhs_uds + WithUsageDetails body_uds' tagged_bndr = tagNonRecBinder lvl body_uds bndr mb_join_arity = willBeJoinId_maybe tagged_bndr + WithUsageDetails rhs_uds' rhs' = adjustNonRecRhs mb_join_arity wtuds + !unf' = markNonRecUnfoldingOneShots mb_join_arity (idUnfolding tagged_bndr) + !bndr' = tagged_bndr `setIdUnfolding` unf' -- The Rec case is the interesting one -- See Note [Recursive bindings: the grand plan] @@ -873,7 +991,7 @@ occAnalRec env lvl (CyclicSCC details_s) (WithUsageDetails body_uds binds) -- Make the nodes for the loop-breaker analysis -- See Note [Choosing loop breakers] for loop_breaker_nodes final_uds :: UsageDetails - loop_breaker_nodes :: [LetrecNode] + loop_breaker_nodes :: [LoopBreakerNode] (WithUsageDetails final_uds loop_breaker_nodes) = mkLoopBreakerNodes env lvl body_uds details_s ------------------------------ @@ -1102,7 +1220,7 @@ type Binding = (Id,CoreExpr) loopBreakNodes :: Int -> VarSet -- Binders whose dependencies may be "missing" -- See Note [Weak loop breakers] - -> [LetrecNode] + -> [LoopBreakerNode] -> [Binding] -- Append these to the end -> [Binding] @@ -1121,7 +1239,7 @@ loopBreakNodes depth weak_fvs nodes binds CyclicSCC nodes -> reOrderNodes depth weak_fvs nodes binds ---------------------------------- -reOrderNodes :: Int -> VarSet -> [LetrecNode] -> [Binding] -> [Binding] +reOrderNodes :: Int -> VarSet -> [LoopBreakerNode] -> [Binding] -> [Binding] -- Choose a loop breaker, mark it no-inline, -- and call loopBreakNodes on the rest reOrderNodes _ _ [] _ = panic "reOrderNodes" @@ -1133,7 +1251,7 @@ reOrderNodes depth weak_fvs (node : nodes) binds (map (nodeBinding mk_loop_breaker) chosen_nodes ++ binds) where (chosen_nodes, unchosen) = chooseLoopBreaker approximate_lb - (nd_score (node_payload node)) + (snd_score (node_payload node)) [node] [] nodes approximate_lb = depth >= 2 @@ -1142,8 +1260,8 @@ reOrderNodes depth weak_fvs (node : nodes) binds -- After two iterations (d=0, d=1) give up -- and approximate, returning to d=0 -nodeBinding :: (Id -> Id) -> LetrecNode -> Binding -nodeBinding set_id_occ (node_payload -> ND { nd_bndr = bndr, nd_rhs = rhs}) +nodeBinding :: (Id -> Id) -> LoopBreakerNode -> Binding +nodeBinding set_id_occ (node_payload -> SND { snd_bndr = bndr, snd_rhs = rhs}) = (set_id_occ bndr, rhs) mk_loop_breaker :: Id -> Id @@ -1163,13 +1281,13 @@ mk_non_loop_breaker weak_fvs bndr tail_info = tailCallInfo (idOccInfo bndr) ---------------------------------- -chooseLoopBreaker :: Bool -- True <=> Too many iterations, - -- so approximate - -> NodeScore -- Best score so far - -> [LetrecNode] -- Nodes with this score - -> [LetrecNode] -- Nodes with higher scores - -> [LetrecNode] -- Unprocessed nodes - -> ([LetrecNode], [LetrecNode]) +chooseLoopBreaker :: Bool -- True <=> Too many iterations, + -- so approximate + -> NodeScore -- Best score so far + -> [LoopBreakerNode] -- Nodes with this score + -> [LoopBreakerNode] -- Nodes with higher scores + -> [LoopBreakerNode] -- Unprocessed nodes + -> ([LoopBreakerNode], [LoopBreakerNode]) -- This loop looks for the bind with the lowest score -- to pick as the loop breaker. The rest accumulate in chooseLoopBreaker _ _ loop_nodes acc [] @@ -1189,7 +1307,7 @@ chooseLoopBreaker approx_lb loop_sc loop_nodes acc (node : nodes) | otherwise -- Worse score so don't pick it = chooseLoopBreaker approx_lb loop_sc loop_nodes (node : acc) nodes where - sc = nd_score (node_payload node) + sc = snd_score (node_payload node) {- Note [Complexity of loop breaking] @@ -1322,16 +1440,21 @@ ToDo: try using the occurrence info for the inline'd binder. ************************************************************************ -} -type LetrecNode = Node Unique Details -- Node comes from Digraph - -- The Unique key is gotten from the Id -data Details - = ND { nd_bndr :: Id -- Binder +-- | Digraph node as constructed by 'makeNode' and consumed by 'occAnalRec'. +-- The Unique key is gotten from the Id. +type LetrecNode = Node Unique NodeDetails - , nd_rhs :: CoreExpr -- RHS, already occ-analysed +-- | Node details as consumed by 'occAnalRec'. +data NodeDetails + = ND { nd_bndr :: Id -- Binder - , nd_uds :: UsageDetails -- Usage from RHS, and RULES, and stable unfoldings - -- ignoring phase (ie assuming all are active) - -- See Note [Forming Rec groups] + , nd_rhs :: !(WithTailUsageDetails CoreExpr) + -- ^ RHS, already occ-analysed + -- With TailUsageDetails from RHS, and RULES, and stable unfoldings, + -- ignoring phase (ie assuming all are active). + -- NB: Unadjusted TailUsageDetails, as if this Node becomes a + -- non-recursive join point! + -- See Note [TailUsageDetails when forming Rec groups] , nd_inl :: IdSet -- Free variables of the stable unfolding and the RHS -- but excluding any RULES @@ -1348,18 +1471,33 @@ data Details , nd_active_rule_fvs :: IdSet -- Variables bound in this Rec group that are free -- in the RHS of an active rule for this bndr -- See Note [Rules and loop breakers] - - , nd_score :: NodeScore } -instance Outputable Details where +instance Outputable NodeDetails where ppr nd = text "ND" <> braces (sep [ text "bndr =" <+> ppr (nd_bndr nd) - , text "uds =" <+> ppr (nd_uds nd) + , text "uds =" <+> ppr uds , text "inl =" <+> ppr (nd_inl nd) , text "simple =" <+> ppr (nd_simple nd) , text "active_rule_fvs =" <+> ppr (nd_active_rule_fvs nd) - , text "score =" <+> ppr (nd_score nd) + ]) + where WithTailUsageDetails uds _ = nd_rhs nd + +-- | Digraph with simplified and completely occurrence analysed +-- 'SimpleNodeDetails', retaining just the info we need for breaking loops. +type LoopBreakerNode = Node Unique SimpleNodeDetails + +-- | Condensed variant of 'NodeDetails' needed during loop breaking. +data SimpleNodeDetails + = SND { snd_bndr :: IdWithOccInfo -- OccInfo accurate + , snd_rhs :: CoreExpr -- properly occur-analysed + , snd_score :: NodeScore + } + +instance Outputable SimpleNodeDetails where + ppr nd = text "SND" <> braces + (sep [ text "bndr =" <+> ppr (snd_bndr nd) + , text "score =" <+> ppr (snd_score nd) ]) -- The NodeScore is compared lexicographically; @@ -1387,52 +1525,59 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) -- explained in Note [Deterministic SCC] in GHC.Data.Graph.Directed. where details = ND { nd_bndr = bndr' - , nd_rhs = rhs' - , nd_uds = scope_uds + , nd_rhs = WithTailUsageDetails scope_uds rhs' , nd_inl = inl_fvs , nd_simple = null rules_w_uds && null imp_rule_info , nd_weak_fvs = weak_fvs - , nd_active_rule_fvs = active_rule_fvs - , nd_score = pprPanic "makeNodeDetails" (ppr bndr) } + , nd_active_rule_fvs = active_rule_fvs } bndr' = bndr `setIdUnfolding` unf' `setIdSpecialisation` mkRuleInfo rules' - inl_uds = rhs_uds `andUDs` unf_uds - scope_uds = inl_uds `andUDs` rule_uds + -- NB: Both adj_unf_uds and adj_rule_uds have been adjusted to match the + -- JoinArity rhs_ja of unadj_rhs_uds. + unadj_inl_uds = unadj_rhs_uds `andUDs` adj_unf_uds + unadj_scope_uds = unadj_inl_uds `andUDs` adj_rule_uds + scope_uds = TUD rhs_ja unadj_scope_uds -- Note [Rules are extra RHSs] -- Note [Rule dependency info] - scope_fvs = udFreeVars bndr_set scope_uds + scope_fvs = udFreeVars bndr_set unadj_scope_uds -- scope_fvs: all occurrences from this binder: RHS, unfolding, -- and RULES, both LHS and RHS thereof, active or inactive - inl_fvs = udFreeVars bndr_set inl_uds + inl_fvs = udFreeVars bndr_set unadj_inl_uds -- inl_fvs: vars that would become free if the function was inlined. -- We conservatively approximate that by thefree vars from the RHS -- and the unfolding together. -- See Note [inl_fvs] - mb_join_arity = isJoinId_maybe bndr - -- Get join point info from the *current* decision - -- We don't know what the new decision will be! - -- Using the old decision at least allows us to - -- preserve existing join point, even RULEs are added - -- See Note [Join points and unfoldings/rules] --------- Right hand side --------- -- Constructing the edges for the main Rec computation -- See Note [Forming Rec groups] - -- Do not use occAnalRhs because we don't yet know the final - -- answer for mb_join_arity; instead, do the occAnalLam call from - -- occAnalRhs, and postpone adjustRhsUsage until occAnalRec - rhs_env = rhsCtxt env - (WithUsageDetails rhs_uds rhs') = occAnalLam rhs_env rhs + -- and Note [TailUsageDetails when forming Rec groups] + -- Compared to occAnalNonRecBind, we can't yet adjust the RHS because + -- (a) we don't yet know the final joinpointhood. It might not become a + -- join point after all! + -- (b) we don't even know whether it stays a recursive RHS after the SCC + -- analysis we are about to seed! So we can't markAllInsideLam in + -- advance, because if it ends up as a non-recursive join point we'll + -- consider it as one-shot and don't need to markAllInsideLam. + -- Instead, do the occAnalLamTail call here and postpone adjustTailUsage + -- until occAnalRec. In effect, we pretend that the RHS becomes a + -- non-recursive join point and fix up later with adjustTailUsage. + rhs_env = rhsCtxt env + WithTailUsageDetails (TUD rhs_ja unadj_rhs_uds) rhs' = occAnalLamTail rhs_env rhs + -- corresponding call to adjustTailUsage in occAnalRec and tagRecBinders --------- Unfolding --------- - -- See Note [Unfoldings and join points] + -- See Note [Join points and unfoldings/rules] unf = realIdUnfolding bndr -- realIdUnfolding: Ignore loop-breaker-ness -- here because that is what we are setting! - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env Recursive mb_join_arity unf + WithTailUsageDetails unf_tuds unf' = occAnalUnfolding rhs_env unf + adj_unf_uds = adjustTailArity (Just rhs_ja) unf_tuds + -- `rhs_ja` is `joinRhsArity rhs` and is the prediction for source M + -- of Note [Join arity prediction based on joinRhsArity] --------- IMP-RULES -------- is_active = occ_rule_act env :: Activation -> Bool @@ -1441,11 +1586,15 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) imp_rule_fvs = impRulesActiveFvs is_active bndr_set imp_rule_info --------- All rules -------- + -- See Note [Join points and unfoldings/rules] + -- `rhs_ja` is `joinRhsArity rhs'` and is the prediction for source M + -- of Note [Join arity prediction based on joinRhsArity] rules_w_uds :: [(CoreRule, UsageDetails, UsageDetails)] - rules_w_uds = occAnalRules rhs_env mb_join_arity bndr + rules_w_uds = [ (r,l,adjustTailArity (Just rhs_ja) rhs_tuds) + | (r,l,rhs_tuds) <- occAnalRules rhs_env bndr ] rules' = map fstOf3 rules_w_uds - rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds + adj_rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds add_rule_uds (_, l, r) uds = l `andUDs` r `andUDs` uds -------- active_rule_fvs ------------ @@ -1463,8 +1612,8 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) mkLoopBreakerNodes :: OccEnv -> TopLevelFlag -> UsageDetails -- for BODY of let - -> [Details] - -> WithUsageDetails [LetrecNode] -- adjusted + -> [NodeDetails] + -> WithUsageDetails [LoopBreakerNode] -- with OccInfo up-to-date -- See Note [Choosing loop breakers] -- This function primarily creates the Nodes for the -- loop-breaker SCC analysis. More specifically: @@ -1477,10 +1626,10 @@ mkLoopBreakerNodes :: OccEnv -> TopLevelFlag mkLoopBreakerNodes !env lvl body_uds details_s = WithUsageDetails final_uds (zipWithEqual "mkLoopBreakerNodes" mk_lb_node details_s bndrs') where - (final_uds, bndrs') = tagRecBinders lvl body_uds details_s + WithUsageDetails final_uds bndrs' = tagRecBinders lvl body_uds details_s mk_lb_node nd@(ND { nd_bndr = old_bndr, nd_inl = inl_fvs }) new_bndr - = DigraphNode { node_payload = new_nd + = DigraphNode { node_payload = simple_nd , node_key = varUnique old_bndr , node_dependencies = nonDetKeysUniqSet lb_deps } -- It's OK to use nonDetKeysUniqSet here as @@ -1488,7 +1637,8 @@ mkLoopBreakerNodes !env lvl body_uds details_s -- in nondeterministic order as explained in -- Note [Deterministic SCC] in GHC.Data.Graph.Directed. where - new_nd = nd { nd_bndr = new_bndr, nd_score = score } + WithTailUsageDetails _ rhs = nd_rhs nd + simple_nd = SND { snd_bndr = new_bndr, snd_rhs = rhs, snd_score = score } score = nodeScore env new_bndr lb_deps nd lb_deps = extendFvs_ rule_fv_env inl_fvs -- See Note [Loop breaker dependencies] @@ -1524,10 +1674,10 @@ group { f1 = e1; ...; fn = en } are: nodeScore :: OccEnv -> Id -- Binder with new occ-info -> VarSet -- Loop-breaker dependencies - -> Details + -> NodeDetails -> NodeScore nodeScore !env new_bndr lb_deps - (ND { nd_bndr = old_bndr, nd_rhs = bind_rhs }) + (ND { nd_bndr = old_bndr, nd_rhs = WithTailUsageDetails _ bind_rhs }) | not (isId old_bndr) -- A type or coercion variable is never a loop breaker = (100, 0, False) @@ -1748,7 +1898,7 @@ lambda and casts, e.g. * Occurrence analyser: we just mark each binder in the lambda-group (here: x,y,z) with its occurrence info in the *body* of the - lambda-group. See occAnalLam. + lambda-group. See occAnalLamTail. * Simplifier. The simplifier is careful when partially applying lambda-groups. See the call to zapLambdaBndrs in @@ -1804,25 +1954,31 @@ zapLambdaBndrs fun arg_count zap_bndr b | isTyVar b = b | otherwise = zapLamIdInfo b -occAnalLam :: OccEnv -> CoreExpr -> (WithUsageDetails CoreExpr) --- See Note [Occurrence analysis for lambda binders] +occAnalLamTail :: OccEnv -> CoreExpr -> WithTailUsageDetails CoreExpr +-- ^ See Note [Occurrence analysis for lambda binders]. -- It does the following: -- * Sets one-shot info on the lambda binder from the OccEnv, and -- removes that one-shot info from the OccEnv -- * Sets the OccEnv to OccVanilla when going under a value lambda -- * Tags each lambda with its occurrence information -- * Walks through casts +-- * Package up the analysed lambda with its manifest join arity +-- -- This function does /not/ do -- markAllInsideLam or -- markAllNonTail --- The caller does that, either in occAnal (Lam {}), or in adjustRhsUsage +-- The caller does that, via adjustTailUsage (mostly calls go through +-- adjustNonRecRhs). Every call to occAnalLamTail must ultimately call +-- adjustTailUsage to discharge the assumed join arity. +-- +-- In effect, the analysis result is for a non-recursive join point with +-- manifest arity and adjustTailUsage does the fixup. -- See Note [Adjusting right-hand sides] - -occAnalLam env (Lam bndr expr) +occAnalLamTail env (Lam bndr expr) | isTyVar bndr - = let env1 = addOneInScope env bndr - WithUsageDetails usage expr' = occAnalLam env1 expr - in WithUsageDetails usage (Lam bndr expr') + , let env1 = addOneInScope env bndr + , WithTailUsageDetails (TUD ja usage) expr' <- occAnalLamTail env1 expr + = WithTailUsageDetails (TUD (ja+1) usage) (Lam bndr expr') -- Important: Keep the 'env' unchanged so that with a RHS like -- \(@ x) -> K @x (f @x) -- we'll see that (K @x (f @x)) is in a OccRhs, and hence refrain @@ -1840,14 +1996,14 @@ occAnalLam env (Lam bndr expr) env1 = env { occ_encl = OccVanilla, occ_one_shots = env_one_shots' } env2 = addOneInScope env1 bndr - (WithUsageDetails usage expr') = occAnalLam env2 expr + WithTailUsageDetails (TUD ja usage) expr' = occAnalLamTail env2 expr (usage', bndr2) = tagLamBinder usage bndr1 - in WithUsageDetails usage' (Lam bndr2 expr') + in WithTailUsageDetails (TUD (ja+1) usage') (Lam bndr2 expr') -- For casts, keep going in the same lambda-group -- See Note [Occurrence analysis for lambda binders] -occAnalLam env (Cast expr co) - = let (WithUsageDetails usage expr') = occAnalLam env expr +occAnalLamTail env (Cast expr co) + = let WithTailUsageDetails (TUD ja usage) expr' = occAnalLamTail env expr -- usage1: see Note [Gather occurrences of coercion variables] usage1 = addManyOccs usage (coVarsOfCo co) @@ -1857,15 +2013,16 @@ occAnalLam env (Cast expr co) _ -> usage1 -- usage3: you might think this was not necessary, because of - -- the markAllNonTail in adjustRhsUsage; but not so! For a - -- join point, adjustRhsUsage doesn't do this; yet if there is + -- the markAllNonTail in adjustTailUsage; but not so! For a + -- join point, adjustTailUsage doesn't do this; yet if there is -- a cast, we must! Also: why markAllNonTail? See -- GHC.Core.Lint: Note Note [Join points and casts] usage3 = markAllNonTail usage2 - in WithUsageDetails usage3 (Cast expr' co) + in WithTailUsageDetails (TUD ja usage3) (Cast expr' co) -occAnalLam env expr = occAnal env expr +occAnalLamTail env expr = case occAnal env expr of + WithUsageDetails usage expr' -> WithTailUsageDetails (TUD 0 usage) expr' {- Note [Occ-anal and cast worker/wrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1885,8 +2042,8 @@ RHS. So it'll get a Many occ-info. (Maybe Cast w/w should create a stable unfolding, which would obviate this Note; but that seems a bit of a heavyweight solution.) -We only need to this in occAnalLam, not occAnal, because the top leve -of a right hand side is handled by occAnalLam. +We only need to this in occAnalLamTail, not occAnal, because the top leve +of a right hand side is handled by occAnalLamTail. -} @@ -1896,57 +2053,23 @@ of a right hand side is handled by occAnalLam. * * ********************************************************************* -} -occAnalRhs :: OccEnv -> RecFlag -> Maybe JoinArity - -> CoreExpr -- RHS - -> WithUsageDetails CoreExpr -occAnalRhs !env is_rec mb_join_arity rhs - = let (WithUsageDetails usage rhs1) = occAnalLam env rhs - -- We call occAnalLam here, not occAnalExpr, so that it doesn't - -- do the markAllInsideLam and markNonTailCall stuff before - -- we've had a chance to help with join points; that comes next - rhs2 = markJoinOneShots is_rec mb_join_arity rhs1 - rhs_usage = adjustRhsUsage mb_join_arity rhs2 usage - in WithUsageDetails rhs_usage rhs2 - - - -markJoinOneShots :: RecFlag -> Maybe JoinArity -> CoreExpr -> CoreExpr --- For a /non-recursive/ join point we can mark all --- its join-lambda as one-shot; and it's a good idea to do so -markJoinOneShots NonRecursive (Just join_arity) rhs - = go join_arity rhs - where - go 0 rhs = rhs - go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) - (go (n-1) rhs) - go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. - -- e.g. let j = case ... in j True - -- This will become an arity-1 join point after the - -- simplifier has eta-expanded it; but it may not have - -- enough lambdas /yet/. (Lint checks that JoinIds do - -- have enough lambdas.) -markJoinOneShots _ _ rhs - = rhs - occAnalUnfolding :: OccEnv - -> RecFlag - -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Unfolding - -> WithUsageDetails Unfolding + -> WithTailUsageDetails Unfolding -- Occurrence-analyse a stable unfolding; --- discard a non-stable one altogether. -occAnalUnfolding !env is_rec mb_join_arity unf +-- discard a non-stable one altogether and return empty usage details. +occAnalUnfolding !env unf = case unf of unf@(CoreUnfolding { uf_tmpl = rhs, uf_src = src }) | isStableSource src -> let - (WithUsageDetails usage rhs') = occAnalRhs env is_rec mb_join_arity rhs + WithTailUsageDetails (TUD rhs_ja usage) rhs' = occAnalLamTail env rhs unf' | noBinderSwaps env = unf -- Note [Unfoldings and rules] | otherwise = unf { uf_tmpl = rhs' } - in WithUsageDetails (markAllMany usage) unf' + in WithTailUsageDetails (TUD rhs_ja (markAllMany usage)) unf' -- markAllMany: see Note [Occurrences in stable unfoldings] - | otherwise -> WithUsageDetails emptyDetails unf + | otherwise -> WithTailUsageDetails (TUD 0 emptyDetails) unf -- For non-Stable unfoldings we leave them undisturbed, but -- don't count their usage because the simplifier will discard them. -- We leave them undisturbed because nodeScore uses their size info @@ -1955,29 +2078,26 @@ occAnalUnfolding !env is_rec mb_join_arity unf -- scope remain in scope; there is no cloning etc. unf@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) - -> WithUsageDetails final_usage (unf { df_args = args' }) + -> WithTailUsageDetails (TUD 0 final_usage) (unf { df_args = args' }) where env' = env `addInScope` bndrs (WithUsageDetails usage args') = occAnalList env' args - final_usage = markAllManyNonTail (delDetailsList usage bndrs) - `addLamCoVarOccs` bndrs - `delDetailsList` bndrs + final_usage = usage `addLamCoVarOccs` bndrs `delDetailsList` bndrs -- delDetailsList; no need to use tagLamBinders because we -- never inline DFuns so the occ-info on binders doesn't matter - unf -> WithUsageDetails emptyDetails unf + unf -> WithTailUsageDetails (TUD 0 emptyDetails) unf occAnalRules :: OccEnv - -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Id -- Get rules from here -> [(CoreRule, -- Each (non-built-in) rule UsageDetails, -- Usage details for LHS - UsageDetails)] -- Usage details for RHS -occAnalRules !env mb_join_arity bndr + TailUsageDetails)] -- Usage details for RHS +occAnalRules !env bndr = map occ_anal_rule (idCoreRules bndr) where occ_anal_rule rule@(Rule { ru_bndrs = bndrs, ru_args = args, ru_rhs = rhs }) - = (rule', lhs_uds', rhs_uds') + = (rule', lhs_uds', TUD rhs_ja rhs_uds') where env' = env `addInScope` bndrs rule' | noBinderSwaps env = rule -- Note [Unfoldings and rules] @@ -1990,14 +2110,11 @@ occAnalRules !env mb_join_arity bndr (WithUsageDetails rhs_uds rhs') = occAnal env' rhs -- Note [Rules are extra RHSs] -- Note [Rule dependency info] - rhs_uds' = markAllNonTailIf (not exact_join) $ - markAllMany $ + rhs_uds' = markAllMany $ rhs_uds `delDetailsList` bndrs + rhs_ja = length args -- See Note [Join points and unfoldings/rules] - exact_join = exactJoin mb_join_arity args - -- See Note [Join points and unfoldings/rules] - - occ_anal_rule other_rule = (other_rule, emptyDetails, emptyDetails) + occ_anal_rule other_rule = (other_rule, emptyDetails, TUD 0 emptyDetails) {- Note [Join point RHSs] ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2032,6 +2149,8 @@ Another way to think about it: if we inlined g as-is into multiple call sites, now there's be multiple calls to f. Bottom line: treat all occurrences in a stable unfolding as "Many". +We still leave tail call information intact, though, as to not spoil +potential join points. Note [Unfoldings and rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2209,10 +2328,7 @@ occAnal env app@(App _ _) = occAnalApp env (collectArgsTicks tickishFloatable app) occAnal env expr@(Lam {}) - = let (WithUsageDetails usage expr') = occAnalLam env expr - final_usage = markAllInsideLamIf (not (isOneShotFun expr')) $ - markAllNonTail usage - in WithUsageDetails final_usage expr' + = adjustNonRecRhs Nothing $ occAnalLamTail env expr -- mb_join_arity == Nothing <=> markAllManyNonTail occAnal env (Case scrut bndr ty alts) = let @@ -2287,7 +2403,7 @@ occAnalApp !env (Var fun, args, ticks) -- This caused #18296 | fun `hasKey` runRWKey , [t1, t2, arg] <- args - , let (WithUsageDetails usage arg') = occAnalRhs env NonRecursive (Just 1) arg + , WithUsageDetails usage arg' <- adjustNonRecRhs (Just 1) $ occAnalLamTail env arg = WithUsageDetails usage (mkTicks ticks $ mkApps (Var fun) [t1, t2, arg']) occAnalApp env (Var fun_id, args, ticks) @@ -2872,7 +2988,6 @@ lookupBndrSwap env@(OccEnv { occ_bs_env = bs_env }) bndr case lookupBndrSwap env bndr1 of (fun, fun_id) -> (mkCastMCo fun mco, fun_id) } - {- Historical note [Proxy let-bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We used to do the binder-swap transformation by introducing @@ -2998,6 +3113,19 @@ data UsageDetails instance Outputable UsageDetails where ppr ud = ppr (ud_env (flattenUsageDetails ud)) +-- | Captures the result of applying 'occAnalLamTail' to a function `\xyz.body`. +-- The TailUsageDetails records +-- * the number of lambdas (including type lambdas: a JoinArity) +-- * UsageDetails for the `body`, unadjusted by `adjustTailUsage`. +-- If the binding turns out to be a join point with the indicated join +-- arity, this unadjusted usage details is just what we need; otherwise we +-- need to discard tail calls. That's what `adjustTailUsage` does. +data TailUsageDetails = TUD !JoinArity !UsageDetails + +instance Outputable TailUsageDetails where + ppr (TUD ja uds) = lambda <> ppr ja <> ppr uds + + ------------------- -- UsageDetails API @@ -3139,24 +3267,49 @@ flattenUsageDetails ud@(UD { ud_env = env }) ------------------- -- See Note [Adjusting right-hand sides] -adjustRhsUsage :: Maybe JoinArity - -> CoreExpr -- Rhs, AFTER occ anal - -> UsageDetails -- From body of lambda +adjustTailUsage :: Maybe JoinArity + -> CoreExpr -- Rhs, AFTER occAnalLamTail + -> TailUsageDetails -- From body of lambda -> UsageDetails -adjustRhsUsage mb_join_arity rhs usage +adjustTailUsage mb_join_arity rhs (TUD rhs_ja usage) = -- c.f. occAnal (Lam {}) markAllInsideLamIf (not one_shot) $ markAllNonTailIf (not exact_join) $ usage where one_shot = isOneShotFun rhs - exact_join = exactJoin mb_join_arity bndrs - (bndrs,_) = collectBinders rhs + exact_join = mb_join_arity == Just rhs_ja + +adjustTailArity :: Maybe JoinArity -> TailUsageDetails -> UsageDetails +adjustTailArity mb_rhs_ja (TUD ud_ja usage) = + markAllNonTailIf (mb_rhs_ja /= Just ud_ja) usage + +markNonRecJoinOneShots :: JoinArity -> CoreExpr -> CoreExpr +-- For a /non-recursive/ join point we can mark all +-- its join-lambda as one-shot; and it's a good idea to do so +markNonRecJoinOneShots join_arity rhs + = go join_arity rhs + where + go 0 rhs = rhs + go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) + (go (n-1) rhs) + go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. + -- e.g. let j = case ... in j True + -- This will become an arity-1 join point after the + -- simplifier has eta-expanded it; but it may not have + -- enough lambdas /yet/. (Lint checks that JoinIds do + -- have enough lambdas.) -exactJoin :: Maybe JoinArity -> [a] -> Bool -exactJoin Nothing _ = False -exactJoin (Just join_arity) args = args `lengthIs` join_arity - -- Remember join_arity includes type binders +markNonRecUnfoldingOneShots :: Maybe JoinArity -> Unfolding -> Unfolding +-- ^ Apply 'markNonRecJoinOneShots' to a stable unfolding +markNonRecUnfoldingOneShots mb_join_arity unf + | Just ja <- mb_join_arity + , CoreUnfolding{uf_src=src,uf_tmpl=tmpl} <- unf + , isStableSource src + , let !tmpl' = markNonRecJoinOneShots ja tmpl + = unf{uf_tmpl=tmpl'} + | otherwise + = unf type IdWithOccInfo = Id @@ -3192,8 +3345,8 @@ tagLamBinder usage bndr tagNonRecBinder :: TopLevelFlag -- At top level? -> UsageDetails -- Of scope -> CoreBndr -- Binder - -> (UsageDetails, -- Details with binder removed - IdWithOccInfo) -- Tagged binder + -> WithUsageDetails -- Details with binder removed + IdWithOccInfo -- Tagged binder tagNonRecBinder lvl usage binder = let @@ -3205,37 +3358,34 @@ tagNonRecBinder lvl usage binder binder' = setBinderOcc occ' binder usage' = usage `delDetails` binder in - usage' `seq` (usage', binder') + WithUsageDetails usage' binder' tagRecBinders :: TopLevelFlag -- At top level? -> UsageDetails -- Of body of let ONLY - -> [Details] - -> (UsageDetails, -- Adjusted details for whole scope, + -> [NodeDetails] + -> WithUsageDetails -- Adjusted details for whole scope, -- with binders removed - [IdWithOccInfo]) -- Tagged binders + [IdWithOccInfo] -- Tagged binders -- Substantially more complicated than non-recursive case. Need to adjust RHS -- details *before* tagging binders (because the tags depend on the RHSes). tagRecBinders lvl body_uds details_s = let bndrs = map nd_bndr details_s - rhs_udss = map nd_uds details_s - -- 1. Determine join-point-hood of whole group, as determined by - -- the *unadjusted* usage details - unadj_uds = foldr andUDs body_uds rhs_udss + -- 1. See Note [Join arity prediction based on joinRhsArity] + -- Determine possible join-point-hood of whole group, by testing for + -- manifest join arity M. + -- This (re-)asserts that makeNode had made tuds for that same arity M! + unadj_uds = foldr (andUDs . test_manifest_arity) body_uds details_s + test_manifest_arity ND{nd_rhs=WithTailUsageDetails tuds rhs} + = adjustTailArity (Just (joinRhsArity rhs)) tuds - -- This is only used in `mb_join_arity`, to adjust each `Details` in `details_s`, thus, - -- when `bndrs` is non-empty. So, we only write `maybe False` as `decideJoinPointHood` - -- takes a `NonEmpty CoreBndr`; the default value `False` won't affect program behavior. - will_be_joins = maybe False (decideJoinPointHood lvl unadj_uds) (nonEmpty bndrs) - - -- 2. Adjust usage details of each RHS, taking into account the - -- join-point-hood decision - rhs_udss' = [ adjustRhsUsage (mb_join_arity bndr) rhs rhs_uds - | ND { nd_bndr = bndr, nd_uds = rhs_uds - , nd_rhs = rhs } <- details_s ] + bndr_ne = expectNonEmpty "List of binders is never empty" bndrs + will_be_joins = decideJoinPointHood lvl unadj_uds bndr_ne mb_join_arity :: Id -> Maybe JoinArity + -- mb_join_arity: See Note [Join arity prediction based on joinRhsArity] + -- This is the source O mb_join_arity bndr -- Can't use willBeJoinId_maybe here because we haven't tagged -- the binder yet (the tag depends on these adjustments!) @@ -3247,6 +3397,12 @@ tagRecBinders lvl body_uds details_s = assert (not will_be_joins) -- Should be AlwaysTailCalled if Nothing -- we are making join points! + -- 2. Adjust usage details of each RHS, taking into account the + -- join-point-hood decision + rhs_udss' = [ adjustTailUsage (mb_join_arity bndr) rhs rhs_tuds -- matching occAnalLamTail in makeNode + | ND { nd_bndr = bndr, nd_rhs = WithTailUsageDetails rhs_tuds rhs } + <- details_s ] + -- 3. Compute final usage details from adjusted RHS details adj_uds = foldr andUDs body_uds rhs_udss' @@ -3257,7 +3413,7 @@ tagRecBinders lvl body_uds details_s -- 5. Drop the binders from the adjusted details and return usage' = adj_uds `delDetailsList` bndrs in - (usage', bndrs') + WithUsageDetails usage' bndrs' setBinderOcc :: OccInfo -> CoreBndr -> CoreBndr setBinderOcc occ_info bndr @@ -3271,12 +3427,13 @@ setBinderOcc occ_info bndr | otherwise = setIdOccInfo bndr occ_info --- | Decide whether some bindings should be made into join points or not. +-- | Decide whether some bindings should be made into join points or not, based +-- on its occurrences. This is -- Returns `False` if they can't be join points. Note that it's an -- all-or-nothing decision, as if multiple binders are given, they're -- assumed to be mutually recursive. -- --- It must, however, be a final decision. If we say "True" for 'f', +-- It must, however, be a final decision. If we say `True` for 'f', -- and then subsequently decide /not/ make 'f' into a join point, then -- the decision about another binding 'g' might be invalidated if (say) -- 'f' tail-calls 'g'. ===================================== compiler/GHC/Data/Graph/Directed.hs ===================================== @@ -4,6 +4,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE DeriveFunctor #-} module GHC.Data.Graph.Directed ( Graph, graphFromEdgedVerticesOrd, graphFromEdgedVerticesUniq, @@ -108,7 +109,7 @@ data Node key payload = DigraphNode { node_payload :: payload, -- ^ User data node_key :: key, -- ^ User defined node id node_dependencies :: [key] -- ^ Dependencies/successors of the node - } + } deriving Functor instance (Outputable a, Outputable b) => Outputable (Node a b) where ===================================== compiler/GHC/Utils/Misc.hs ===================================== @@ -35,7 +35,7 @@ module GHC.Utils.Misc ( equalLength, compareLength, leLength, ltLength, isSingleton, only, expectOnly, GHC.Utils.Misc.singleton, - notNull, snocView, + notNull, expectNonEmpty, snocView, chunkList, @@ -481,7 +481,6 @@ expectOnly _ (a:_) = a #endif expectOnly msg _ = panic ("expectOnly: " ++ msg) - -- | Split a list into chunks of /n/ elements chunkList :: Int -> [a] -> [[a]] chunkList _ [] = [] @@ -500,6 +499,16 @@ changeLast [] _ = panic "changeLast" changeLast [_] x = [x] changeLast (x:xs) x' = x : changeLast xs x' +-- | Like @expectJust msg . nonEmpty@; a better alternative to 'NE.fromList'. +expectNonEmpty :: HasCallStack => String -> [a] -> NonEmpty a +{-# INLINE expectNonEmpty #-} +expectNonEmpty _ (x:xs) = x:|xs +expectNonEmpty msg [] = expectNonEmptyPanic msg + +expectNonEmptyPanic :: String -> a +expectNonEmptyPanic msg = panic ("expectNonEmpty: " ++ msg) +{-# NOINLINE expectNonEmptyPanic #-} + -- | Apply an effectful function to the last list element. mapLastM :: Functor f => (a -> f a) -> NonEmpty a -> f (NonEmpty a) mapLastM f (x:|[]) = NE.singleton <$> f x ===================================== testsuite/tests/simplCore/should_compile/T22428.hs ===================================== @@ -0,0 +1,9 @@ +module T22428 where + +f :: Integer -> Integer -> Integer +f x y = go y + where + go :: Integer -> Integer + go 0 = x + go n = go (n-1) + {-# INLINE go #-} ===================================== testsuite/tests/simplCore/should_compile/T22428.stderr ===================================== @@ -0,0 +1,45 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 32, types: 14, coercions: 0, joins: 1/1} + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22428.f1 :: Integer +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22428.f1 = GHC.Num.Integer.IS 1# + +-- RHS size: {terms: 28, types: 10, coercions: 0, joins: 1/1} +f :: Integer -> Integer -> Integer +[GblId, + Arity=2, + Str=<1L>, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 0] 156 0}] +f = \ (x :: Integer) (y :: Integer) -> + joinrec { + go [InlPrag=INLINE (sat-args=1), Occ=LoopBreaker, Dmd=SC(S,L)] + :: Integer -> Integer + [LclId[JoinId(1)(Just [!])], + Arity=1, + Str=<1L>, + Unf=Unf{Src=StableUser, TopLvl=False, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=False,boring_ok=False)}] + go (ds :: Integer) + = case ds of wild { + GHC.Num.Integer.IS x1 -> + case x1 of { + __DEFAULT -> jump go (GHC.Num.Integer.integerSub wild T22428.f1); + 0# -> x + }; + GHC.Num.Integer.IP x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1); + GHC.Num.Integer.IN x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1) + }; } in + jump go y + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -451,6 +451,7 @@ test('T22375', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeab # One module, T21851_2.hs, has OPTIONS_GHC -ddump-simpl # Expecting to see $s$wwombat 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']) @@ -462,3 +463,6 @@ test('T22272', normal, multimod_compile, ['T22272', '-O -fexpose-all-unfoldings test('T22459', normal, compile, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) test('T22662', normal, compile, ['']) + +# go should become a join point +test('T22428', [grep_errmsg(r'jump go') ], compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeable-binds -dsuppress-unfoldings']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c73f29991799d8f2b4295d14b3e0f248ca169115 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c73f29991799d8f2b4295d14b3e0f248ca169115 You're receiving 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 Jan 10 11:09:18 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 10 Jan 2023 06:09:18 -0500 Subject: [Git][ghc/ghc][wip/T22428] Fix contification with stable unfoldings (#22428) Message-ID: <63bd475e29931_3b1bf9526204662a@gitlab.mail> Sebastian Graf pushed to branch wip/T22428 at Glasgow Haskell Compiler / GHC Commits: de371419 by Sebastian Graf at 2023-01-10T12:09:05+01:00 Fix contification with stable unfoldings (#22428) Many functions now return a `TailUsageDetails` that adorns a `UsageDetails` with a `JoinArity` that reflects the number of join point binders around the body for which the `UsageDetails` was computed. `TailUsageDetails` is now returned by `occAnalLamTail` as well as `occAnalUnfolding` and `occAnalRules`. I adjusted `Note [Join points and unfoldings/rules]` and `Note [Adjusting right-hand sides]` to account for the new machinery. I also wrote a new `Note [Join arity prediction based on joinRhsArity]` and refer to it when we combine `TailUsageDetails` for a recursive RHS. I also renamed * `occAnalLam` to `occAnalLamTail` * `adjustRhsUsage` to `adjustTailUsage` * a few other less important functions and properly documented the that each call of `occAnalLamTail` must pair up with `adjustTailUsage`. I removed `Note [Unfoldings and join points]` because it was redundant with `Note [Occurrences in stable unfoldings]`. While in town, I refactored `mkLoopBreakerNodes` so that it returns a condensed `NodeDetails` called `SimpleNodeDetails`. Fixes #22428. Metric Decrease: T12150 T12425 T21839c T21839r T9961 - - - - - 7 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Data/Graph/Directed.hs - compiler/GHC/Utils/Misc.hs - + testsuite/tests/simplCore/should_compile/T22428.hs - + testsuite/tests/simplCore/should_compile/T22428.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -132,6 +132,9 @@ joinRhsArity :: CoreExpr -> JoinArity -- Join points are supposed to have manifestly-visible -- lambdas at the top: no ticks, no casts, nothing -- Moreover, type lambdas count in JoinArity +-- NB: For non-recursive bindings, the join arity of the binding may actually be +-- less that the number of manifestly-visible lambdas. +-- See Note [Join arity prediction based on joinRhsArity] in GHC.Core.Opt.OccurAnal joinRhsArity (Lam _ e) = 1 + joinRhsArity e joinRhsArity _ = 0 ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -59,7 +59,7 @@ import GHC.Builtin.Names( runRWKey ) import GHC.Unit.Module( Module ) import Data.List (mapAccumL, mapAccumR) -import Data.List.NonEmpty (NonEmpty (..), nonEmpty) +import Data.List.NonEmpty (NonEmpty (..)) import qualified Data.List.NonEmpty as NE {- @@ -510,6 +510,16 @@ of the file. at any of the definitions. This is done by Simplify.simplRecBind, when it calls addLetIdInfo. +Note [TailUsageDetails when forming Rec groups] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `TailUsageDetails` stored in the `nd_uds` field of a `NodeDetails` is +computed by `occAnalLamTail` applied to the RHS, not `occAnalExpr`. +That is because the binding might still become a *non-recursive join point* in +the AcyclicSCC case of dependency analysis! +Hence we do the delayed `adjustTailUsage` in `occAnalRec`/`tagRecBinders` to get +a regular, adjusted UsageDetails. +See Note [Join points and unfoldings/rules] for more details on the contract. + Note [Stable unfoldings] ~~~~~~~~~~~~~~~~~~~~~~~~ None of the above stuff about RULES applies to a stable unfolding @@ -608,6 +618,65 @@ tail call with `n` arguments (counting both value and type arguments). Otherwise 'occ_tail' will be 'NoTailCallInfo'. The tail call info flows bottom-up with the rest of 'OccInfo' until it goes on the binder. +Note [Join arity prediction based on joinRhsArity] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In general, the join arity from tail occurrences of a join point (O) may be +higher or lower than the manifest join arity of the join body (M). E.g., + + -- M > O: + let f x y = x + y -- M = 2 + in if b then f 1 else f 2 -- O = 1 + ==> { Contify for join arity 1 } + join f x = \y -> x + y + in if b then jump f 1 else jump f 2 + + -- M < O + let f = id -- M = 0 + in if ... then f 12 else f 13 -- O = 1 + ==> { Contify for join arity 1, eta-expand f } + join f x = id x + in if b then jump f 12 else jump f 13 + +But for *recursive* let, it is crucial that both arities match up, consider + + letrec f x y = if ... then f x else True + in f 42 + +Here, M=2 but O=1. If we settled for a joinrec arity of 1, the recursive jump +would not happen in a tail context! Contification is invalid here. +So indeed it is crucial to demand that M=O. + +(Side note: Actually, we could be more specific: Let O1 be the join arity of +occurrences from the letrec RHS and O2 the join arity from the let body. Then +we need M=O1 and M<=O2 and could simply eta-expand the RHS to match O2 later. +M=O is the specific case where we don't want to eta-expand. Neither the join +points paper nor GHC does this at the moment.) + +We can capitalise on this observation and conclude that *if* f could become a +joinrec (without eta-expansion), it will have join arity M. +Now, M is just the result of 'joinRhsArity', a rather simple, local analysis. +It is also the join arity inside the 'TailUsageDetails' returned by +'occAnalLamTail', so we can predict join arity without doing any fixed-point +iteration or really doing any deep traversal of let body or RHS at all. +We check for M in the 'adjustTailUsage' call inside 'tagRecBinders'. + +All this is quite apparent if you look at the contification transformation in +Fig. 5 of "Compiling without Continuations" (which does not account for +eta-expansion at all, mind you). The letrec case looks like this + + letrec f = /\as.\xs. L[us] in L'[es] + ... and a bunch of conditions establishing that f only occurs + in app heads of join arity (len as + len xs) inside us and es ... + +The syntactic form `/\as.\xs. L[us]` forces M=O iff `f` occurs in `us`. However, +for non-recursive functions, this is the definition of contification from the +paper: + + let f = /\as.\xs.u in L[es] ... conditions ... + +Note that u could be a lambda itself, as we have seen. No relationship between M +and O to exploit here. + Note [Join points and unfoldings/rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider @@ -618,8 +687,10 @@ Consider Before j is inlined, we'll have occurrences of j2 in both j's RHS and in its stable unfolding. We want to discover -j2 as a join point. So we must do the adjustRhsUsage thing -on j's RHS. That's why we pass mb_join_arity to calcUnfolding. +j2 as a join point. So 'occAnalUnfolding' returns an unadjusted +'TailUsageDetails', like 'occAnalLamTail'. We adjust the usage details of the +unfolding to the actual join arity using the same 'adjustTailArity' as for +the RHS, see Note [Adjusting right-hand sides]. Same with rules. Suppose we have: @@ -636,14 +707,31 @@ up. So provided the join-point arity of k matches the args of the rule we can allow the tail-call info from the RHS of the rule to propagate. -* Wrinkle for Rec case. In the recursive case we don't know the - join-point arity in advance, when calling occAnalUnfolding and - occAnalRules. (See makeNode.) We don't want to pass Nothing, - because then a recursive joinrec might lose its join-poin-hood - when SpecConstr adds a RULE. So we just make do with the - *current* join-poin-hood, stored in the Id. +* Note that the join arity of the RHS and that of the unfolding or RULE might + mismatch: + + let j x y = j2 (x+x) + {-# INLINE[2] j = \x. g #-} + {-# RULE forall x y z. j x y z = h 17 #-} + in j 1 2 - In the non-recursive case things are simple: see occAnalNonRecBind + So it is crucial that we adjust each TailUsageDetails individually + with the actual join arity 2 here before we combine with `andUDs`. + Here, that means losing tail call info on `g` and `h`. + +* Wrinkle for Rec case: We store one TailUsageDetails in the node Details for + RHS, unfolding and RULE combined. Clearly, if they don't agree on their join + arity, we have to do some adjusting. We choose to adjust to the join arity + of the RHS, because that is likely the join arity that the join point will + have; see Note [Join arity prediction based on joinRhsArity]. + + If the guess is correct, then tail calls in the RHS are preserved; a necessary + condition for the whole binding becoming a joinrec. + The guess can only be incorrect in the 'AcyclicSCC' case when the binding + becomes a non-recursive join point with a different join arity. But then the + eventual call to 'adjustTailUsage' in 'tagRecBinders'/'occAnalRec' will + be with a different join arity and destroy unsound tail call info with + 'markNonTail'. * Wrinkle for RULES. Suppose the example was a bit different: let j :: Int -> Int @@ -669,28 +757,21 @@ propagate. This appears to be very rare in practice. TODO Perhaps we should gather statistics to be sure. -Note [Unfoldings and join points] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We assume that anything in an unfolding occurs multiple times, since -unfoldings are often copied (that's the whole point!). But we still -need to track tail calls for the purpose of finding join points. - - ------------------------------------------------------------ Note [Adjusting right-hand sides] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There's a bit of a dance we need to do after analysing a lambda expression or a right-hand side. In particular, we need to - a) call 'markAllInsideLam' *unless* the binding is for a thunk, a one-shot - lambda, or a non-recursive join point; and - b) call 'markAllNonTail' *unless* the binding is for a join point, and - the RHS has the right arity; e.g. + a) call 'markAllNonTail' *unless* the binding is for a join point, and + the TailUsageDetails from the RHS has the right join arity; e.g. join j x y = case ... of A -> j2 p B -> j2 q in j a b Here we want the tail calls to j2 to be tail calls of the whole expression + b) call 'markAllInsideLam' *unless* the binding is for a thunk, a one-shot + lambda, or a non-recursive join point Some examples, with how the free occurrences in e (assumed not to be a value lambda) get marked: @@ -707,26 +788,39 @@ lambda) get marked: There are a few other caveats; most importantly, if we're marking a binding as 'AlwaysTailCalled', it's *going* to be a join point, so we treat it as one so that the effect cascades properly. Consequently, at the time the RHS is -analysed, we won't know what adjustments to make; thus 'occAnalLamOrRhs' must -return the unadjusted 'UsageDetails', to be adjusted by 'adjustRhsUsage' once -join-point-hood has been decided. - -Thus the overall sequence taking place in 'occAnalNonRecBind' and -'occAnalRecBind' is as follows: - - 1. Call 'occAnalLamOrRhs' to find usage information for the RHS. - 2. Call 'tagNonRecBinder' or 'tagRecBinders', which decides whether to make +analysed, we won't know what adjustments to make; thus 'occAnalLamTail' must +return the unadjusted 'TailUsageDetails', to be adjusted by 'adjustTailUsage' +once join-point-hood has been decided and eventual one-shot annotations have +been added through 'markNonRecJoinOneShots'. + +It is not so simple to see that 'occAnalNonRecBind' and 'occAnalRecBind' indeed +perform a similar sequence of steps. Thus, here is an interleaving of events +of both functions, serving as a specification: + + 1. Call 'occAnalLamTail' to find usage information for the RHS. + Recursive case: 'makeNode' + Non-recursive case: 'occAnalNonRecBind' + 2. (Analyse the binding's scope. Done in 'occAnalBind'/`occAnal Let{}`. + Same whether recursive or not.) + 3. Call 'tagNonRecBinder' or 'tagRecBinders', which decides whether to make the binding a join point. - 3. Call 'adjustRhsUsage' accordingly. (Done as part of 'tagRecBinders' when - recursive.) - -(In the recursive case, this logic is spread between 'makeNode' and -'occAnalRec'.) + Cyclic Recursive case: 'mkLoopBreakerNodes' + Acyclic Recursive case: `occAnalRec AcyclicSCC{}` + Non-recursive case: 'occAnalNonRecBind' + 4. Non-recursive join point: Call 'markNonRecJoinOneShots' so that e.g., + FloatOut sees one-shot annotations on lambdas + Acyclic Recursive case: `occAnalRec AcyclicSCC{}` calls 'adjustNonRecRhs' + Non-recursive case: 'occAnalNonRecBind' calls 'adjustNonRecRhs' + 5. Call 'adjustTailUsage' accordingly. + Cyclic Recursive case: 'tagRecBinders' + Acyclic Recursive case: 'adjustNonRecRhs' + Non-recursive case: 'adjustNonRecRhs' -} - data WithUsageDetails a = WithUsageDetails !UsageDetails !a +data WithTailUsageDetails a = WithTailUsageDetails !TailUsageDetails !a + ------------------------------------------------------------------ -- occAnalBind ------------------------------------------------------------------ @@ -750,19 +844,17 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage | isTyVar bndr -- A type let; we don't gather usage info = WithUsageDetails body_usage [NonRec bndr rhs] - | not (bndr `usedIn` body_usage) -- It's not mentioned - = WithUsageDetails body_usage [] + | not (bndr `usedIn` body_usage) + = WithUsageDetails body_usage [] -- See Note [Dead code] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr rhs'] + = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr final_rhs] where - (body_usage', tagged_bndr) = tagNonRecBinder lvl body_usage bndr - final_bndr = tagged_bndr `setIdUnfolding` unf' - `setIdSpecialisation` mkRuleInfo rules' - rhs_usage = rhs_uds `andUDs` unf_uds `andUDs` rule_uds + WithUsageDetails body_usage' tagged_bndr = tagNonRecBinder lvl body_usage bndr -- Get the join info from the *new* decision -- See Note [Join points and unfoldings/rules] + -- => join arity O of Note [Join arity prediction based on joinRhsArity] mb_join_arity = willBeJoinId_maybe tagged_bndr is_join_point = isJust mb_join_arity @@ -773,17 +865,28 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- See Note [Sources of one-shot information] rhs_env = env1 { occ_one_shots = argOneShots dmd } - (WithUsageDetails rhs_uds rhs') = occAnalRhs rhs_env NonRecursive mb_join_arity rhs + -- See Note [Join arity prediction based on joinRhsArity] + -- Match join arity O from mb_join_arity with manifest join arity M as + -- returned by of occAnalLamTail. It's totally OK for them to mismatch; + -- hence adjust the UDs from the RHS + WithUsageDetails adj_rhs_uds final_rhs + = adjustNonRecRhs mb_join_arity $ occAnalLamTail rhs_env rhs + rhs_usage = adj_rhs_uds `andUDs` adj_unf_uds `andUDs` adj_rule_uds + final_bndr = tagged_bndr `setIdSpecialisation` mkRuleInfo rules' + `setIdUnfolding` unf2 --------- Unfolding --------- - -- See Note [Unfoldings and join points] + -- See Note [Join points and unfoldings/rules] unf | isId bndr = idUnfolding bndr | otherwise = NoUnfolding - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env NonRecursive mb_join_arity unf + WithTailUsageDetails unf_uds unf1 = occAnalUnfolding rhs_env unf + !unf2 = markNonRecUnfoldingOneShots mb_join_arity unf1 + adj_unf_uds = adjustTailArity mb_join_arity unf_uds --------- Rules --------- -- See Note [Rules are extra RHSs] and Note [Rule dependency info] - rules_w_uds = occAnalRules rhs_env mb_join_arity bndr + -- and Note [Join points and unfoldings/rules] + rules_w_uds = occAnalRules rhs_env bndr rules' = map fstOf3 rules_w_uds imp_rule_uds = impRulesScopeUsage (lookupImpRules imp_rule_edges bndr) -- imp_rule_uds: consider @@ -794,8 +897,9 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- that g is (since the RULE might turn g into h), so -- we make g mention h. - rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds - add_rule_uds (_, l, r) uds = l `andUDs` r `andUDs` uds + adj_rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds + add_rule_uds (_, l, r) uds + = l `andUDs` adjustTailArity mb_join_arity r `andUDs` uds ---------- occ = idOccInfo tagged_bndr @@ -820,7 +924,7 @@ occAnalRecBind :: OccEnv -> TopLevelFlag -> ImpRuleEdges -> [(Var,CoreExpr)] occAnalRecBind !env lvl imp_rule_edges pairs body_usage = foldr (occAnalRec rhs_env lvl) (WithUsageDetails body_usage []) sccs where - sccs :: [SCC Details] + sccs :: [SCC NodeDetails] sccs = {-# SCC "occAnalBind.scc" #-} stronglyConnCompFromEdgedVerticesUniq nodes @@ -832,27 +936,44 @@ occAnalRecBind !env lvl imp_rule_edges pairs body_usage bndr_set = mkVarSet bndrs rhs_env = env `addInScope` bndrs +adjustNonRecRhs :: Maybe JoinArity -> WithTailUsageDetails CoreExpr -> WithUsageDetails CoreExpr +-- ^ This function concentrates shared logic between occAnalNonRecBind and the +-- AcyclicSCC case of occAnalRec. +-- * It applies 'markNonRecJoinOneShots' to the RHS +-- * and returns the adjusted rhs UsageDetails combined with the body usage +adjustNonRecRhs mb_join_arity (WithTailUsageDetails rhs_tuds rhs) + = WithUsageDetails rhs_uds' rhs' + where + --------- Marking (non-rec) join binders one-shot --------- + !rhs' | Just ja <- mb_join_arity = markNonRecJoinOneShots ja rhs + | otherwise = rhs + --------- Adjusting right-hand side usage --------- + rhs_uds' = adjustTailUsage mb_join_arity rhs' rhs_tuds ----------------------------- occAnalRec :: OccEnv -> TopLevelFlag - -> SCC Details + -> SCC NodeDetails -> WithUsageDetails [CoreBind] -> WithUsageDetails [CoreBind] -- The NonRec case is just like a Let (NonRec ...) above -occAnalRec !_ lvl (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = rhs - , nd_uds = rhs_uds })) +occAnalRec !_ lvl + (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = wtuds })) (WithUsageDetails body_uds binds) + | isTyVar bndr -- A type let; we don't gather usage info + = WithUsageDetails body_uds (NonRec bndr rhs : binds) + | not (bndr `usedIn` body_uds) = WithUsageDetails body_uds binds -- See Note [Dead code] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_uds' `andUDs` rhs_uds') - (NonRec tagged_bndr rhs : binds) + = WithUsageDetails (body_uds' `andUDs` rhs_uds') (NonRec bndr' rhs' : binds) where - (body_uds', tagged_bndr) = tagNonRecBinder lvl body_uds bndr - rhs_uds' = adjustRhsUsage mb_join_arity rhs rhs_uds + WithUsageDetails body_uds' tagged_bndr = tagNonRecBinder lvl body_uds bndr mb_join_arity = willBeJoinId_maybe tagged_bndr + WithUsageDetails rhs_uds' rhs' = adjustNonRecRhs mb_join_arity wtuds + !unf' = markNonRecUnfoldingOneShots mb_join_arity (idUnfolding tagged_bndr) + !bndr' = tagged_bndr `setIdUnfolding` unf' -- The Rec case is the interesting one -- See Note [Recursive bindings: the grand plan] @@ -873,7 +994,7 @@ occAnalRec env lvl (CyclicSCC details_s) (WithUsageDetails body_uds binds) -- Make the nodes for the loop-breaker analysis -- See Note [Choosing loop breakers] for loop_breaker_nodes final_uds :: UsageDetails - loop_breaker_nodes :: [LetrecNode] + loop_breaker_nodes :: [LoopBreakerNode] (WithUsageDetails final_uds loop_breaker_nodes) = mkLoopBreakerNodes env lvl body_uds details_s ------------------------------ @@ -1102,7 +1223,7 @@ type Binding = (Id,CoreExpr) loopBreakNodes :: Int -> VarSet -- Binders whose dependencies may be "missing" -- See Note [Weak loop breakers] - -> [LetrecNode] + -> [LoopBreakerNode] -> [Binding] -- Append these to the end -> [Binding] @@ -1121,7 +1242,7 @@ loopBreakNodes depth weak_fvs nodes binds CyclicSCC nodes -> reOrderNodes depth weak_fvs nodes binds ---------------------------------- -reOrderNodes :: Int -> VarSet -> [LetrecNode] -> [Binding] -> [Binding] +reOrderNodes :: Int -> VarSet -> [LoopBreakerNode] -> [Binding] -> [Binding] -- Choose a loop breaker, mark it no-inline, -- and call loopBreakNodes on the rest reOrderNodes _ _ [] _ = panic "reOrderNodes" @@ -1133,7 +1254,7 @@ reOrderNodes depth weak_fvs (node : nodes) binds (map (nodeBinding mk_loop_breaker) chosen_nodes ++ binds) where (chosen_nodes, unchosen) = chooseLoopBreaker approximate_lb - (nd_score (node_payload node)) + (snd_score (node_payload node)) [node] [] nodes approximate_lb = depth >= 2 @@ -1142,8 +1263,8 @@ reOrderNodes depth weak_fvs (node : nodes) binds -- After two iterations (d=0, d=1) give up -- and approximate, returning to d=0 -nodeBinding :: (Id -> Id) -> LetrecNode -> Binding -nodeBinding set_id_occ (node_payload -> ND { nd_bndr = bndr, nd_rhs = rhs}) +nodeBinding :: (Id -> Id) -> LoopBreakerNode -> Binding +nodeBinding set_id_occ (node_payload -> SND { snd_bndr = bndr, snd_rhs = rhs}) = (set_id_occ bndr, rhs) mk_loop_breaker :: Id -> Id @@ -1163,13 +1284,13 @@ mk_non_loop_breaker weak_fvs bndr tail_info = tailCallInfo (idOccInfo bndr) ---------------------------------- -chooseLoopBreaker :: Bool -- True <=> Too many iterations, - -- so approximate - -> NodeScore -- Best score so far - -> [LetrecNode] -- Nodes with this score - -> [LetrecNode] -- Nodes with higher scores - -> [LetrecNode] -- Unprocessed nodes - -> ([LetrecNode], [LetrecNode]) +chooseLoopBreaker :: Bool -- True <=> Too many iterations, + -- so approximate + -> NodeScore -- Best score so far + -> [LoopBreakerNode] -- Nodes with this score + -> [LoopBreakerNode] -- Nodes with higher scores + -> [LoopBreakerNode] -- Unprocessed nodes + -> ([LoopBreakerNode], [LoopBreakerNode]) -- This loop looks for the bind with the lowest score -- to pick as the loop breaker. The rest accumulate in chooseLoopBreaker _ _ loop_nodes acc [] @@ -1189,7 +1310,7 @@ chooseLoopBreaker approx_lb loop_sc loop_nodes acc (node : nodes) | otherwise -- Worse score so don't pick it = chooseLoopBreaker approx_lb loop_sc loop_nodes (node : acc) nodes where - sc = nd_score (node_payload node) + sc = snd_score (node_payload node) {- Note [Complexity of loop breaking] @@ -1322,16 +1443,21 @@ ToDo: try using the occurrence info for the inline'd binder. ************************************************************************ -} -type LetrecNode = Node Unique Details -- Node comes from Digraph - -- The Unique key is gotten from the Id -data Details - = ND { nd_bndr :: Id -- Binder +-- | Digraph node as constructed by 'makeNode' and consumed by 'occAnalRec'. +-- The Unique key is gotten from the Id. +type LetrecNode = Node Unique NodeDetails - , nd_rhs :: CoreExpr -- RHS, already occ-analysed +-- | Node details as consumed by 'occAnalRec'. +data NodeDetails + = ND { nd_bndr :: Id -- Binder - , nd_uds :: UsageDetails -- Usage from RHS, and RULES, and stable unfoldings - -- ignoring phase (ie assuming all are active) - -- See Note [Forming Rec groups] + , nd_rhs :: !(WithTailUsageDetails CoreExpr) + -- ^ RHS, already occ-analysed + -- With TailUsageDetails from RHS, and RULES, and stable unfoldings, + -- ignoring phase (ie assuming all are active). + -- NB: Unadjusted TailUsageDetails, as if this Node becomes a + -- non-recursive join point! + -- See Note [TailUsageDetails when forming Rec groups] , nd_inl :: IdSet -- Free variables of the stable unfolding and the RHS -- but excluding any RULES @@ -1348,18 +1474,33 @@ data Details , nd_active_rule_fvs :: IdSet -- Variables bound in this Rec group that are free -- in the RHS of an active rule for this bndr -- See Note [Rules and loop breakers] - - , nd_score :: NodeScore } -instance Outputable Details where +instance Outputable NodeDetails where ppr nd = text "ND" <> braces (sep [ text "bndr =" <+> ppr (nd_bndr nd) - , text "uds =" <+> ppr (nd_uds nd) + , text "uds =" <+> ppr uds , text "inl =" <+> ppr (nd_inl nd) , text "simple =" <+> ppr (nd_simple nd) , text "active_rule_fvs =" <+> ppr (nd_active_rule_fvs nd) - , text "score =" <+> ppr (nd_score nd) + ]) + where WithTailUsageDetails uds _ = nd_rhs nd + +-- | Digraph with simplified and completely occurrence analysed +-- 'SimpleNodeDetails', retaining just the info we need for breaking loops. +type LoopBreakerNode = Node Unique SimpleNodeDetails + +-- | Condensed variant of 'NodeDetails' needed during loop breaking. +data SimpleNodeDetails + = SND { snd_bndr :: IdWithOccInfo -- OccInfo accurate + , snd_rhs :: CoreExpr -- properly occur-analysed + , snd_score :: NodeScore + } + +instance Outputable SimpleNodeDetails where + ppr nd = text "SND" <> braces + (sep [ text "bndr =" <+> ppr (snd_bndr nd) + , text "score =" <+> ppr (snd_score nd) ]) -- The NodeScore is compared lexicographically; @@ -1387,52 +1528,59 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) -- explained in Note [Deterministic SCC] in GHC.Data.Graph.Directed. where details = ND { nd_bndr = bndr' - , nd_rhs = rhs' - , nd_uds = scope_uds + , nd_rhs = WithTailUsageDetails scope_uds rhs' , nd_inl = inl_fvs , nd_simple = null rules_w_uds && null imp_rule_info , nd_weak_fvs = weak_fvs - , nd_active_rule_fvs = active_rule_fvs - , nd_score = pprPanic "makeNodeDetails" (ppr bndr) } + , nd_active_rule_fvs = active_rule_fvs } bndr' = bndr `setIdUnfolding` unf' `setIdSpecialisation` mkRuleInfo rules' - inl_uds = rhs_uds `andUDs` unf_uds - scope_uds = inl_uds `andUDs` rule_uds + -- NB: Both adj_unf_uds and adj_rule_uds have been adjusted to match the + -- JoinArity rhs_ja of unadj_rhs_uds. + unadj_inl_uds = unadj_rhs_uds `andUDs` adj_unf_uds + unadj_scope_uds = unadj_inl_uds `andUDs` adj_rule_uds + scope_uds = TUD rhs_ja unadj_scope_uds -- Note [Rules are extra RHSs] -- Note [Rule dependency info] - scope_fvs = udFreeVars bndr_set scope_uds + scope_fvs = udFreeVars bndr_set unadj_scope_uds -- scope_fvs: all occurrences from this binder: RHS, unfolding, -- and RULES, both LHS and RHS thereof, active or inactive - inl_fvs = udFreeVars bndr_set inl_uds + inl_fvs = udFreeVars bndr_set unadj_inl_uds -- inl_fvs: vars that would become free if the function was inlined. -- We conservatively approximate that by thefree vars from the RHS -- and the unfolding together. -- See Note [inl_fvs] - mb_join_arity = isJoinId_maybe bndr - -- Get join point info from the *current* decision - -- We don't know what the new decision will be! - -- Using the old decision at least allows us to - -- preserve existing join point, even RULEs are added - -- See Note [Join points and unfoldings/rules] --------- Right hand side --------- -- Constructing the edges for the main Rec computation -- See Note [Forming Rec groups] - -- Do not use occAnalRhs because we don't yet know the final - -- answer for mb_join_arity; instead, do the occAnalLam call from - -- occAnalRhs, and postpone adjustRhsUsage until occAnalRec - rhs_env = rhsCtxt env - (WithUsageDetails rhs_uds rhs') = occAnalLam rhs_env rhs + -- and Note [TailUsageDetails when forming Rec groups] + -- Compared to occAnalNonRecBind, we can't yet adjust the RHS because + -- (a) we don't yet know the final joinpointhood. It might not become a + -- join point after all! + -- (b) we don't even know whether it stays a recursive RHS after the SCC + -- analysis we are about to seed! So we can't markAllInsideLam in + -- advance, because if it ends up as a non-recursive join point we'll + -- consider it as one-shot and don't need to markAllInsideLam. + -- Instead, do the occAnalLamTail call here and postpone adjustTailUsage + -- until occAnalRec. In effect, we pretend that the RHS becomes a + -- non-recursive join point and fix up later with adjustTailUsage. + rhs_env = rhsCtxt env + WithTailUsageDetails (TUD rhs_ja unadj_rhs_uds) rhs' = occAnalLamTail rhs_env rhs + -- corresponding call to adjustTailUsage in occAnalRec and tagRecBinders --------- Unfolding --------- - -- See Note [Unfoldings and join points] + -- See Note [Join points and unfoldings/rules] unf = realIdUnfolding bndr -- realIdUnfolding: Ignore loop-breaker-ness -- here because that is what we are setting! - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env Recursive mb_join_arity unf + WithTailUsageDetails unf_tuds unf' = occAnalUnfolding rhs_env unf + adj_unf_uds = adjustTailArity (Just rhs_ja) unf_tuds + -- `rhs_ja` is `joinRhsArity rhs` and is the prediction for source M + -- of Note [Join arity prediction based on joinRhsArity] --------- IMP-RULES -------- is_active = occ_rule_act env :: Activation -> Bool @@ -1441,11 +1589,15 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) imp_rule_fvs = impRulesActiveFvs is_active bndr_set imp_rule_info --------- All rules -------- + -- See Note [Join points and unfoldings/rules] + -- `rhs_ja` is `joinRhsArity rhs'` and is the prediction for source M + -- of Note [Join arity prediction based on joinRhsArity] rules_w_uds :: [(CoreRule, UsageDetails, UsageDetails)] - rules_w_uds = occAnalRules rhs_env mb_join_arity bndr + rules_w_uds = [ (r,l,adjustTailArity (Just rhs_ja) rhs_tuds) + | (r,l,rhs_tuds) <- occAnalRules rhs_env bndr ] rules' = map fstOf3 rules_w_uds - rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds + adj_rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds add_rule_uds (_, l, r) uds = l `andUDs` r `andUDs` uds -------- active_rule_fvs ------------ @@ -1463,8 +1615,8 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) mkLoopBreakerNodes :: OccEnv -> TopLevelFlag -> UsageDetails -- for BODY of let - -> [Details] - -> WithUsageDetails [LetrecNode] -- adjusted + -> [NodeDetails] + -> WithUsageDetails [LoopBreakerNode] -- with OccInfo up-to-date -- See Note [Choosing loop breakers] -- This function primarily creates the Nodes for the -- loop-breaker SCC analysis. More specifically: @@ -1477,10 +1629,10 @@ mkLoopBreakerNodes :: OccEnv -> TopLevelFlag mkLoopBreakerNodes !env lvl body_uds details_s = WithUsageDetails final_uds (zipWithEqual "mkLoopBreakerNodes" mk_lb_node details_s bndrs') where - (final_uds, bndrs') = tagRecBinders lvl body_uds details_s + WithUsageDetails final_uds bndrs' = tagRecBinders lvl body_uds details_s mk_lb_node nd@(ND { nd_bndr = old_bndr, nd_inl = inl_fvs }) new_bndr - = DigraphNode { node_payload = new_nd + = DigraphNode { node_payload = simple_nd , node_key = varUnique old_bndr , node_dependencies = nonDetKeysUniqSet lb_deps } -- It's OK to use nonDetKeysUniqSet here as @@ -1488,7 +1640,8 @@ mkLoopBreakerNodes !env lvl body_uds details_s -- in nondeterministic order as explained in -- Note [Deterministic SCC] in GHC.Data.Graph.Directed. where - new_nd = nd { nd_bndr = new_bndr, nd_score = score } + WithTailUsageDetails _ rhs = nd_rhs nd + simple_nd = SND { snd_bndr = new_bndr, snd_rhs = rhs, snd_score = score } score = nodeScore env new_bndr lb_deps nd lb_deps = extendFvs_ rule_fv_env inl_fvs -- See Note [Loop breaker dependencies] @@ -1524,10 +1677,10 @@ group { f1 = e1; ...; fn = en } are: nodeScore :: OccEnv -> Id -- Binder with new occ-info -> VarSet -- Loop-breaker dependencies - -> Details + -> NodeDetails -> NodeScore nodeScore !env new_bndr lb_deps - (ND { nd_bndr = old_bndr, nd_rhs = bind_rhs }) + (ND { nd_bndr = old_bndr, nd_rhs = WithTailUsageDetails _ bind_rhs }) | not (isId old_bndr) -- A type or coercion variable is never a loop breaker = (100, 0, False) @@ -1748,7 +1901,7 @@ lambda and casts, e.g. * Occurrence analyser: we just mark each binder in the lambda-group (here: x,y,z) with its occurrence info in the *body* of the - lambda-group. See occAnalLam. + lambda-group. See occAnalLamTail. * Simplifier. The simplifier is careful when partially applying lambda-groups. See the call to zapLambdaBndrs in @@ -1804,25 +1957,31 @@ zapLambdaBndrs fun arg_count zap_bndr b | isTyVar b = b | otherwise = zapLamIdInfo b -occAnalLam :: OccEnv -> CoreExpr -> (WithUsageDetails CoreExpr) --- See Note [Occurrence analysis for lambda binders] +occAnalLamTail :: OccEnv -> CoreExpr -> WithTailUsageDetails CoreExpr +-- ^ See Note [Occurrence analysis for lambda binders]. -- It does the following: -- * Sets one-shot info on the lambda binder from the OccEnv, and -- removes that one-shot info from the OccEnv -- * Sets the OccEnv to OccVanilla when going under a value lambda -- * Tags each lambda with its occurrence information -- * Walks through casts +-- * Package up the analysed lambda with its manifest join arity +-- -- This function does /not/ do -- markAllInsideLam or -- markAllNonTail --- The caller does that, either in occAnal (Lam {}), or in adjustRhsUsage +-- The caller does that, via adjustTailUsage (mostly calls go through +-- adjustNonRecRhs). Every call to occAnalLamTail must ultimately call +-- adjustTailUsage to discharge the assumed join arity. +-- +-- In effect, the analysis result is for a non-recursive join point with +-- manifest arity and adjustTailUsage does the fixup. -- See Note [Adjusting right-hand sides] - -occAnalLam env (Lam bndr expr) +occAnalLamTail env (Lam bndr expr) | isTyVar bndr - = let env1 = addOneInScope env bndr - WithUsageDetails usage expr' = occAnalLam env1 expr - in WithUsageDetails usage (Lam bndr expr') + , let env1 = addOneInScope env bndr + , WithTailUsageDetails (TUD ja usage) expr' <- occAnalLamTail env1 expr + = WithTailUsageDetails (TUD (ja+1) usage) (Lam bndr expr') -- Important: Keep the 'env' unchanged so that with a RHS like -- \(@ x) -> K @x (f @x) -- we'll see that (K @x (f @x)) is in a OccRhs, and hence refrain @@ -1840,14 +1999,14 @@ occAnalLam env (Lam bndr expr) env1 = env { occ_encl = OccVanilla, occ_one_shots = env_one_shots' } env2 = addOneInScope env1 bndr - (WithUsageDetails usage expr') = occAnalLam env2 expr + WithTailUsageDetails (TUD ja usage) expr' = occAnalLamTail env2 expr (usage', bndr2) = tagLamBinder usage bndr1 - in WithUsageDetails usage' (Lam bndr2 expr') + in WithTailUsageDetails (TUD (ja+1) usage') (Lam bndr2 expr') -- For casts, keep going in the same lambda-group -- See Note [Occurrence analysis for lambda binders] -occAnalLam env (Cast expr co) - = let (WithUsageDetails usage expr') = occAnalLam env expr +occAnalLamTail env (Cast expr co) + = let WithTailUsageDetails (TUD ja usage) expr' = occAnalLamTail env expr -- usage1: see Note [Gather occurrences of coercion variables] usage1 = addManyOccs usage (coVarsOfCo co) @@ -1857,15 +2016,16 @@ occAnalLam env (Cast expr co) _ -> usage1 -- usage3: you might think this was not necessary, because of - -- the markAllNonTail in adjustRhsUsage; but not so! For a - -- join point, adjustRhsUsage doesn't do this; yet if there is + -- the markAllNonTail in adjustTailUsage; but not so! For a + -- join point, adjustTailUsage doesn't do this; yet if there is -- a cast, we must! Also: why markAllNonTail? See -- GHC.Core.Lint: Note Note [Join points and casts] usage3 = markAllNonTail usage2 - in WithUsageDetails usage3 (Cast expr' co) + in WithTailUsageDetails (TUD ja usage3) (Cast expr' co) -occAnalLam env expr = occAnal env expr +occAnalLamTail env expr = case occAnal env expr of + WithUsageDetails usage expr' -> WithTailUsageDetails (TUD 0 usage) expr' {- Note [Occ-anal and cast worker/wrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1885,8 +2045,8 @@ RHS. So it'll get a Many occ-info. (Maybe Cast w/w should create a stable unfolding, which would obviate this Note; but that seems a bit of a heavyweight solution.) -We only need to this in occAnalLam, not occAnal, because the top leve -of a right hand side is handled by occAnalLam. +We only need to this in occAnalLamTail, not occAnal, because the top leve +of a right hand side is handled by occAnalLamTail. -} @@ -1896,57 +2056,23 @@ of a right hand side is handled by occAnalLam. * * ********************************************************************* -} -occAnalRhs :: OccEnv -> RecFlag -> Maybe JoinArity - -> CoreExpr -- RHS - -> WithUsageDetails CoreExpr -occAnalRhs !env is_rec mb_join_arity rhs - = let (WithUsageDetails usage rhs1) = occAnalLam env rhs - -- We call occAnalLam here, not occAnalExpr, so that it doesn't - -- do the markAllInsideLam and markNonTailCall stuff before - -- we've had a chance to help with join points; that comes next - rhs2 = markJoinOneShots is_rec mb_join_arity rhs1 - rhs_usage = adjustRhsUsage mb_join_arity rhs2 usage - in WithUsageDetails rhs_usage rhs2 - - - -markJoinOneShots :: RecFlag -> Maybe JoinArity -> CoreExpr -> CoreExpr --- For a /non-recursive/ join point we can mark all --- its join-lambda as one-shot; and it's a good idea to do so -markJoinOneShots NonRecursive (Just join_arity) rhs - = go join_arity rhs - where - go 0 rhs = rhs - go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) - (go (n-1) rhs) - go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. - -- e.g. let j = case ... in j True - -- This will become an arity-1 join point after the - -- simplifier has eta-expanded it; but it may not have - -- enough lambdas /yet/. (Lint checks that JoinIds do - -- have enough lambdas.) -markJoinOneShots _ _ rhs - = rhs - occAnalUnfolding :: OccEnv - -> RecFlag - -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Unfolding - -> WithUsageDetails Unfolding + -> WithTailUsageDetails Unfolding -- Occurrence-analyse a stable unfolding; --- discard a non-stable one altogether. -occAnalUnfolding !env is_rec mb_join_arity unf +-- discard a non-stable one altogether and return empty usage details. +occAnalUnfolding !env unf = case unf of unf@(CoreUnfolding { uf_tmpl = rhs, uf_src = src }) | isStableSource src -> let - (WithUsageDetails usage rhs') = occAnalRhs env is_rec mb_join_arity rhs + WithTailUsageDetails (TUD rhs_ja usage) rhs' = occAnalLamTail env rhs unf' | noBinderSwaps env = unf -- Note [Unfoldings and rules] | otherwise = unf { uf_tmpl = rhs' } - in WithUsageDetails (markAllMany usage) unf' + in WithTailUsageDetails (TUD rhs_ja (markAllMany usage)) unf' -- markAllMany: see Note [Occurrences in stable unfoldings] - | otherwise -> WithUsageDetails emptyDetails unf + | otherwise -> WithTailUsageDetails (TUD 0 emptyDetails) unf -- For non-Stable unfoldings we leave them undisturbed, but -- don't count their usage because the simplifier will discard them. -- We leave them undisturbed because nodeScore uses their size info @@ -1955,29 +2081,26 @@ occAnalUnfolding !env is_rec mb_join_arity unf -- scope remain in scope; there is no cloning etc. unf@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) - -> WithUsageDetails final_usage (unf { df_args = args' }) + -> WithTailUsageDetails (TUD 0 final_usage) (unf { df_args = args' }) where env' = env `addInScope` bndrs (WithUsageDetails usage args') = occAnalList env' args - final_usage = markAllManyNonTail (delDetailsList usage bndrs) - `addLamCoVarOccs` bndrs - `delDetailsList` bndrs + final_usage = usage `addLamCoVarOccs` bndrs `delDetailsList` bndrs -- delDetailsList; no need to use tagLamBinders because we -- never inline DFuns so the occ-info on binders doesn't matter - unf -> WithUsageDetails emptyDetails unf + unf -> WithTailUsageDetails (TUD 0 emptyDetails) unf occAnalRules :: OccEnv - -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Id -- Get rules from here -> [(CoreRule, -- Each (non-built-in) rule UsageDetails, -- Usage details for LHS - UsageDetails)] -- Usage details for RHS -occAnalRules !env mb_join_arity bndr + TailUsageDetails)] -- Usage details for RHS +occAnalRules !env bndr = map occ_anal_rule (idCoreRules bndr) where occ_anal_rule rule@(Rule { ru_bndrs = bndrs, ru_args = args, ru_rhs = rhs }) - = (rule', lhs_uds', rhs_uds') + = (rule', lhs_uds', TUD rhs_ja rhs_uds') where env' = env `addInScope` bndrs rule' | noBinderSwaps env = rule -- Note [Unfoldings and rules] @@ -1990,14 +2113,11 @@ occAnalRules !env mb_join_arity bndr (WithUsageDetails rhs_uds rhs') = occAnal env' rhs -- Note [Rules are extra RHSs] -- Note [Rule dependency info] - rhs_uds' = markAllNonTailIf (not exact_join) $ - markAllMany $ + rhs_uds' = markAllMany $ rhs_uds `delDetailsList` bndrs + rhs_ja = length args -- See Note [Join points and unfoldings/rules] - exact_join = exactJoin mb_join_arity args - -- See Note [Join points and unfoldings/rules] - - occ_anal_rule other_rule = (other_rule, emptyDetails, emptyDetails) + occ_anal_rule other_rule = (other_rule, emptyDetails, TUD 0 emptyDetails) {- Note [Join point RHSs] ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2032,6 +2152,8 @@ Another way to think about it: if we inlined g as-is into multiple call sites, now there's be multiple calls to f. Bottom line: treat all occurrences in a stable unfolding as "Many". +We still leave tail call information intact, though, as to not spoil +potential join points. Note [Unfoldings and rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2209,10 +2331,7 @@ occAnal env app@(App _ _) = occAnalApp env (collectArgsTicks tickishFloatable app) occAnal env expr@(Lam {}) - = let (WithUsageDetails usage expr') = occAnalLam env expr - final_usage = markAllInsideLamIf (not (isOneShotFun expr')) $ - markAllNonTail usage - in WithUsageDetails final_usage expr' + = adjustNonRecRhs Nothing $ occAnalLamTail env expr -- mb_join_arity == Nothing <=> markAllManyNonTail occAnal env (Case scrut bndr ty alts) = let @@ -2287,7 +2406,7 @@ occAnalApp !env (Var fun, args, ticks) -- This caused #18296 | fun `hasKey` runRWKey , [t1, t2, arg] <- args - , let (WithUsageDetails usage arg') = occAnalRhs env NonRecursive (Just 1) arg + , WithUsageDetails usage arg' <- adjustNonRecRhs (Just 1) $ occAnalLamTail env arg = WithUsageDetails usage (mkTicks ticks $ mkApps (Var fun) [t1, t2, arg']) occAnalApp env (Var fun_id, args, ticks) @@ -2872,7 +2991,6 @@ lookupBndrSwap env@(OccEnv { occ_bs_env = bs_env }) bndr case lookupBndrSwap env bndr1 of (fun, fun_id) -> (mkCastMCo fun mco, fun_id) } - {- Historical note [Proxy let-bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We used to do the binder-swap transformation by introducing @@ -2998,6 +3116,19 @@ data UsageDetails instance Outputable UsageDetails where ppr ud = ppr (ud_env (flattenUsageDetails ud)) +-- | Captures the result of applying 'occAnalLamTail' to a function `\xyz.body`. +-- The TailUsageDetails records +-- * the number of lambdas (including type lambdas: a JoinArity) +-- * UsageDetails for the `body`, unadjusted by `adjustTailUsage`. +-- If the binding turns out to be a join point with the indicated join +-- arity, this unadjusted usage details is just what we need; otherwise we +-- need to discard tail calls. That's what `adjustTailUsage` does. +data TailUsageDetails = TUD !JoinArity !UsageDetails + +instance Outputable TailUsageDetails where + ppr (TUD ja uds) = lambda <> ppr ja <> ppr uds + + ------------------- -- UsageDetails API @@ -3139,24 +3270,49 @@ flattenUsageDetails ud@(UD { ud_env = env }) ------------------- -- See Note [Adjusting right-hand sides] -adjustRhsUsage :: Maybe JoinArity - -> CoreExpr -- Rhs, AFTER occ anal - -> UsageDetails -- From body of lambda +adjustTailUsage :: Maybe JoinArity + -> CoreExpr -- Rhs, AFTER occAnalLamTail + -> TailUsageDetails -- From body of lambda -> UsageDetails -adjustRhsUsage mb_join_arity rhs usage +adjustTailUsage mb_join_arity rhs (TUD rhs_ja usage) = -- c.f. occAnal (Lam {}) markAllInsideLamIf (not one_shot) $ markAllNonTailIf (not exact_join) $ usage where one_shot = isOneShotFun rhs - exact_join = exactJoin mb_join_arity bndrs - (bndrs,_) = collectBinders rhs + exact_join = mb_join_arity == Just rhs_ja -exactJoin :: Maybe JoinArity -> [a] -> Bool -exactJoin Nothing _ = False -exactJoin (Just join_arity) args = args `lengthIs` join_arity - -- Remember join_arity includes type binders +adjustTailArity :: Maybe JoinArity -> TailUsageDetails -> UsageDetails +adjustTailArity mb_rhs_ja (TUD ud_ja usage) = + markAllNonTailIf (mb_rhs_ja /= Just ud_ja) usage + +markNonRecJoinOneShots :: JoinArity -> CoreExpr -> CoreExpr +-- For a /non-recursive/ join point we can mark all +-- its join-lambda as one-shot; and it's a good idea to do so +markNonRecJoinOneShots join_arity rhs + = go join_arity rhs + where + go 0 rhs = rhs + go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) + (go (n-1) rhs) + go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. + -- e.g. let j = case ... in j True + -- This will become an arity-1 join point after the + -- simplifier has eta-expanded it; but it may not have + -- enough lambdas /yet/. (Lint checks that JoinIds do + -- have enough lambdas.) + +markNonRecUnfoldingOneShots :: Maybe JoinArity -> Unfolding -> Unfolding +-- ^ Apply 'markNonRecJoinOneShots' to a stable unfolding +markNonRecUnfoldingOneShots mb_join_arity unf + | Just ja <- mb_join_arity + , CoreUnfolding{uf_src=src,uf_tmpl=tmpl} <- unf + , isStableSource src + , let !tmpl' = markNonRecJoinOneShots ja tmpl + = unf{uf_tmpl=tmpl'} + | otherwise + = unf type IdWithOccInfo = Id @@ -3192,8 +3348,8 @@ tagLamBinder usage bndr tagNonRecBinder :: TopLevelFlag -- At top level? -> UsageDetails -- Of scope -> CoreBndr -- Binder - -> (UsageDetails, -- Details with binder removed - IdWithOccInfo) -- Tagged binder + -> WithUsageDetails -- Details with binder removed + IdWithOccInfo -- Tagged binder tagNonRecBinder lvl usage binder = let @@ -3205,37 +3361,34 @@ tagNonRecBinder lvl usage binder binder' = setBinderOcc occ' binder usage' = usage `delDetails` binder in - usage' `seq` (usage', binder') + WithUsageDetails usage' binder' tagRecBinders :: TopLevelFlag -- At top level? -> UsageDetails -- Of body of let ONLY - -> [Details] - -> (UsageDetails, -- Adjusted details for whole scope, + -> [NodeDetails] + -> WithUsageDetails -- Adjusted details for whole scope, -- with binders removed - [IdWithOccInfo]) -- Tagged binders + [IdWithOccInfo] -- Tagged binders -- Substantially more complicated than non-recursive case. Need to adjust RHS -- details *before* tagging binders (because the tags depend on the RHSes). tagRecBinders lvl body_uds details_s = let bndrs = map nd_bndr details_s - rhs_udss = map nd_uds details_s - -- 1. Determine join-point-hood of whole group, as determined by - -- the *unadjusted* usage details - unadj_uds = foldr andUDs body_uds rhs_udss + -- 1. See Note [Join arity prediction based on joinRhsArity] + -- Determine possible join-point-hood of whole group, by testing for + -- manifest join arity M. + -- This (re-)asserts that makeNode had made tuds for that same arity M! + unadj_uds = foldr (andUDs . test_manifest_arity) body_uds details_s + test_manifest_arity ND{nd_rhs=WithTailUsageDetails tuds rhs} + = adjustTailArity (Just (joinRhsArity rhs)) tuds - -- This is only used in `mb_join_arity`, to adjust each `Details` in `details_s`, thus, - -- when `bndrs` is non-empty. So, we only write `maybe False` as `decideJoinPointHood` - -- takes a `NonEmpty CoreBndr`; the default value `False` won't affect program behavior. - will_be_joins = maybe False (decideJoinPointHood lvl unadj_uds) (nonEmpty bndrs) - - -- 2. Adjust usage details of each RHS, taking into account the - -- join-point-hood decision - rhs_udss' = [ adjustRhsUsage (mb_join_arity bndr) rhs rhs_uds - | ND { nd_bndr = bndr, nd_uds = rhs_uds - , nd_rhs = rhs } <- details_s ] + bndr_ne = expectNonEmpty "List of binders is never empty" bndrs + will_be_joins = decideJoinPointHood lvl unadj_uds bndr_ne mb_join_arity :: Id -> Maybe JoinArity + -- mb_join_arity: See Note [Join arity prediction based on joinRhsArity] + -- This is the source O mb_join_arity bndr -- Can't use willBeJoinId_maybe here because we haven't tagged -- the binder yet (the tag depends on these adjustments!) @@ -3247,6 +3400,12 @@ tagRecBinders lvl body_uds details_s = assert (not will_be_joins) -- Should be AlwaysTailCalled if Nothing -- we are making join points! + -- 2. Adjust usage details of each RHS, taking into account the + -- join-point-hood decision + rhs_udss' = [ adjustTailUsage (mb_join_arity bndr) rhs rhs_tuds -- matching occAnalLamTail in makeNode + | ND { nd_bndr = bndr, nd_rhs = WithTailUsageDetails rhs_tuds rhs } + <- details_s ] + -- 3. Compute final usage details from adjusted RHS details adj_uds = foldr andUDs body_uds rhs_udss' @@ -3257,7 +3416,7 @@ tagRecBinders lvl body_uds details_s -- 5. Drop the binders from the adjusted details and return usage' = adj_uds `delDetailsList` bndrs in - (usage', bndrs') + WithUsageDetails usage' bndrs' setBinderOcc :: OccInfo -> CoreBndr -> CoreBndr setBinderOcc occ_info bndr @@ -3271,12 +3430,13 @@ setBinderOcc occ_info bndr | otherwise = setIdOccInfo bndr occ_info --- | Decide whether some bindings should be made into join points or not. +-- | Decide whether some bindings should be made into join points or not, based +-- on its occurrences. This is -- Returns `False` if they can't be join points. Note that it's an -- all-or-nothing decision, as if multiple binders are given, they're -- assumed to be mutually recursive. -- --- It must, however, be a final decision. If we say "True" for 'f', +-- It must, however, be a final decision. If we say `True` for 'f', -- and then subsequently decide /not/ make 'f' into a join point, then -- the decision about another binding 'g' might be invalidated if (say) -- 'f' tail-calls 'g'. ===================================== compiler/GHC/Data/Graph/Directed.hs ===================================== @@ -4,6 +4,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE DeriveFunctor #-} module GHC.Data.Graph.Directed ( Graph, graphFromEdgedVerticesOrd, graphFromEdgedVerticesUniq, @@ -108,7 +109,7 @@ data Node key payload = DigraphNode { node_payload :: payload, -- ^ User data node_key :: key, -- ^ User defined node id node_dependencies :: [key] -- ^ Dependencies/successors of the node - } + } deriving Functor instance (Outputable a, Outputable b) => Outputable (Node a b) where ===================================== compiler/GHC/Utils/Misc.hs ===================================== @@ -35,7 +35,7 @@ module GHC.Utils.Misc ( equalLength, compareLength, leLength, ltLength, isSingleton, only, expectOnly, GHC.Utils.Misc.singleton, - notNull, snocView, + notNull, expectNonEmpty, snocView, chunkList, @@ -481,7 +481,6 @@ expectOnly _ (a:_) = a #endif expectOnly msg _ = panic ("expectOnly: " ++ msg) - -- | Split a list into chunks of /n/ elements chunkList :: Int -> [a] -> [[a]] chunkList _ [] = [] @@ -500,6 +499,16 @@ changeLast [] _ = panic "changeLast" changeLast [_] x = [x] changeLast (x:xs) x' = x : changeLast xs x' +-- | Like @expectJust msg . nonEmpty@; a better alternative to 'NE.fromList'. +expectNonEmpty :: HasCallStack => String -> [a] -> NonEmpty a +{-# INLINE expectNonEmpty #-} +expectNonEmpty _ (x:xs) = x:|xs +expectNonEmpty msg [] = expectNonEmptyPanic msg + +expectNonEmptyPanic :: String -> a +expectNonEmptyPanic msg = panic ("expectNonEmpty: " ++ msg) +{-# NOINLINE expectNonEmptyPanic #-} + -- | Apply an effectful function to the last list element. mapLastM :: Functor f => (a -> f a) -> NonEmpty a -> f (NonEmpty a) mapLastM f (x:|[]) = NE.singleton <$> f x ===================================== testsuite/tests/simplCore/should_compile/T22428.hs ===================================== @@ -0,0 +1,9 @@ +module T22428 where + +f :: Integer -> Integer -> Integer +f x y = go y + where + go :: Integer -> Integer + go 0 = x + go n = go (n-1) + {-# INLINE go #-} ===================================== testsuite/tests/simplCore/should_compile/T22428.stderr ===================================== @@ -0,0 +1,45 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 32, types: 14, coercions: 0, joins: 1/1} + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22428.f1 :: Integer +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22428.f1 = GHC.Num.Integer.IS 1# + +-- RHS size: {terms: 28, types: 10, coercions: 0, joins: 1/1} +f :: Integer -> Integer -> Integer +[GblId, + Arity=2, + Str=<1L>, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 0] 156 0}] +f = \ (x :: Integer) (y :: Integer) -> + joinrec { + go [InlPrag=INLINE (sat-args=1), Occ=LoopBreaker, Dmd=SC(S,L)] + :: Integer -> Integer + [LclId[JoinId(1)(Just [!])], + Arity=1, + Str=<1L>, + Unf=Unf{Src=StableUser, TopLvl=False, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=False,boring_ok=False)}] + go (ds :: Integer) + = case ds of wild { + GHC.Num.Integer.IS x1 -> + case x1 of { + __DEFAULT -> jump go (GHC.Num.Integer.integerSub wild T22428.f1); + 0# -> x + }; + GHC.Num.Integer.IP x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1); + GHC.Num.Integer.IN x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1) + }; } in + jump go y + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -451,6 +451,7 @@ test('T22375', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeab # One module, T21851_2.hs, has OPTIONS_GHC -ddump-simpl # Expecting to see $s$wwombat 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']) @@ -462,3 +463,6 @@ test('T22272', normal, multimod_compile, ['T22272', '-O -fexpose-all-unfoldings test('T22459', normal, compile, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) test('T22662', normal, compile, ['']) + +# go should become a join point +test('T22428', [grep_errmsg(r'jump go') ], compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeable-binds -dsuppress-unfoldings']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/de37141929c16597c6725ba8655007114730aba3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/de37141929c16597c6725ba8655007114730aba3 You're receiving 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 Jan 10 11:13:06 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 10 Jan 2023 06:13:06 -0500 Subject: [Git][ghc/ghc][wip/T22428] Fix contification with stable unfoldings (#22428) Message-ID: <63bd484217a8c_3b1bf959e704666a9@gitlab.mail> Sebastian Graf pushed to branch wip/T22428 at Glasgow Haskell Compiler / GHC Commits: 0fdcb4f9 by Sebastian Graf at 2023-01-10T12:12:53+01:00 Fix contification with stable unfoldings (#22428) Many functions now return a `TailUsageDetails` that adorns a `UsageDetails` with a `JoinArity` that reflects the number of join point binders around the body for which the `UsageDetails` was computed. `TailUsageDetails` is now returned by `occAnalLamTail` as well as `occAnalUnfolding` and `occAnalRules`. I adjusted `Note [Join points and unfoldings/rules]` and `Note [Adjusting right-hand sides]` to account for the new machinery. I also wrote a new `Note [Join arity prediction based on joinRhsArity]` and refer to it when we combine `TailUsageDetails` for a recursive RHS. I also renamed * `occAnalLam` to `occAnalLamTail` * `adjustRhsUsage` to `adjustTailUsage` * a few other less important functions and properly documented the that each call of `occAnalLamTail` must pair up with `adjustTailUsage`. I removed `Note [Unfoldings and join points]` because it was redundant with `Note [Occurrences in stable unfoldings]`. While in town, I refactored `mkLoopBreakerNodes` so that it returns a condensed `NodeDetails` called `SimpleNodeDetails`. Fixes #22428. Metric Decrease: T12150 T12425 T21839c T21839r T9961 - - - - - 7 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Data/Graph/Directed.hs - compiler/GHC/Utils/Misc.hs - + testsuite/tests/simplCore/should_compile/T22428.hs - + testsuite/tests/simplCore/should_compile/T22428.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -132,6 +132,9 @@ joinRhsArity :: CoreExpr -> JoinArity -- Join points are supposed to have manifestly-visible -- lambdas at the top: no ticks, no casts, nothing -- Moreover, type lambdas count in JoinArity +-- NB: For non-recursive bindings, the join arity of the binding may actually be +-- less that the number of manifestly-visible lambdas. +-- See Note [Join arity prediction based on joinRhsArity] in GHC.Core.Opt.OccurAnal joinRhsArity (Lam _ e) = 1 + joinRhsArity e joinRhsArity _ = 0 ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -59,7 +59,7 @@ import GHC.Builtin.Names( runRWKey ) import GHC.Unit.Module( Module ) import Data.List (mapAccumL, mapAccumR) -import Data.List.NonEmpty (NonEmpty (..), nonEmpty) +import Data.List.NonEmpty (NonEmpty (..)) import qualified Data.List.NonEmpty as NE {- @@ -510,6 +510,16 @@ of the file. at any of the definitions. This is done by Simplify.simplRecBind, when it calls addLetIdInfo. +Note [TailUsageDetails when forming Rec groups] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `TailUsageDetails` stored in the `nd_uds` field of a `NodeDetails` is +computed by `occAnalLamTail` applied to the RHS, not `occAnalExpr`. +That is because the binding might still become a *non-recursive join point* in +the AcyclicSCC case of dependency analysis! +Hence we do the delayed `adjustTailUsage` in `occAnalRec`/`tagRecBinders` to get +a regular, adjusted UsageDetails. +See Note [Join points and unfoldings/rules] for more details on the contract. + Note [Stable unfoldings] ~~~~~~~~~~~~~~~~~~~~~~~~ None of the above stuff about RULES applies to a stable unfolding @@ -608,6 +618,65 @@ tail call with `n` arguments (counting both value and type arguments). Otherwise 'occ_tail' will be 'NoTailCallInfo'. The tail call info flows bottom-up with the rest of 'OccInfo' until it goes on the binder. +Note [Join arity prediction based on joinRhsArity] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In general, the join arity from tail occurrences of a join point (O) may be +higher or lower than the manifest join arity of the join body (M). E.g., + + -- M > O: + let f x y = x + y -- M = 2 + in if b then f 1 else f 2 -- O = 1 + ==> { Contify for join arity 1 } + join f x = \y -> x + y + in if b then jump f 1 else jump f 2 + + -- M < O + let f = id -- M = 0 + in if ... then f 12 else f 13 -- O = 1 + ==> { Contify for join arity 1, eta-expand f } + join f x = id x + in if b then jump f 12 else jump f 13 + +But for *recursive* let, it is crucial that both arities match up, consider + + letrec f x y = if ... then f x else True + in f 42 + +Here, M=2 but O=1. If we settled for a joinrec arity of 1, the recursive jump +would not happen in a tail context! Contification is invalid here. +So indeed it is crucial to demand that M=O. + +(Side note: Actually, we could be more specific: Let O1 be the join arity of +occurrences from the letrec RHS and O2 the join arity from the let body. Then +we need M=O1 and M<=O2 and could simply eta-expand the RHS to match O2 later. +M=O is the specific case where we don't want to eta-expand. Neither the join +points paper nor GHC does this at the moment.) + +We can capitalise on this observation and conclude that *if* f could become a +joinrec (without eta-expansion), it will have join arity M. +Now, M is just the result of 'joinRhsArity', a rather simple, local analysis. +It is also the join arity inside the 'TailUsageDetails' returned by +'occAnalLamTail', so we can predict join arity without doing any fixed-point +iteration or really doing any deep traversal of let body or RHS at all. +We check for M in the 'adjustTailUsage' call inside 'tagRecBinders'. + +All this is quite apparent if you look at the contification transformation in +Fig. 5 of "Compiling without Continuations" (which does not account for +eta-expansion at all, mind you). The letrec case looks like this + + letrec f = /\as.\xs. L[us] in L'[es] + ... and a bunch of conditions establishing that f only occurs + in app heads of join arity (len as + len xs) inside us and es ... + +The syntactic form `/\as.\xs. L[us]` forces M=O iff `f` occurs in `us`. However, +for non-recursive functions, this is the definition of contification from the +paper: + + let f = /\as.\xs.u in L[es] ... conditions ... + +Note that u could be a lambda itself, as we have seen. No relationship between M +and O to exploit here. + Note [Join points and unfoldings/rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider @@ -618,8 +687,10 @@ Consider Before j is inlined, we'll have occurrences of j2 in both j's RHS and in its stable unfolding. We want to discover -j2 as a join point. So we must do the adjustRhsUsage thing -on j's RHS. That's why we pass mb_join_arity to calcUnfolding. +j2 as a join point. So 'occAnalUnfolding' returns an unadjusted +'TailUsageDetails', like 'occAnalLamTail'. We adjust the usage details of the +unfolding to the actual join arity using the same 'adjustTailArity' as for +the RHS, see Note [Adjusting right-hand sides]. Same with rules. Suppose we have: @@ -636,14 +707,31 @@ up. So provided the join-point arity of k matches the args of the rule we can allow the tail-call info from the RHS of the rule to propagate. -* Wrinkle for Rec case. In the recursive case we don't know the - join-point arity in advance, when calling occAnalUnfolding and - occAnalRules. (See makeNode.) We don't want to pass Nothing, - because then a recursive joinrec might lose its join-poin-hood - when SpecConstr adds a RULE. So we just make do with the - *current* join-poin-hood, stored in the Id. +* Note that the join arity of the RHS and that of the unfolding or RULE might + mismatch: + + let j x y = j2 (x+x) + {-# INLINE[2] j = \x. g #-} + {-# RULE forall x y z. j x y z = h 17 #-} + in j 1 2 - In the non-recursive case things are simple: see occAnalNonRecBind + So it is crucial that we adjust each TailUsageDetails individually + with the actual join arity 2 here before we combine with `andUDs`. + Here, that means losing tail call info on `g` and `h`. + +* Wrinkle for Rec case: We store one TailUsageDetails in the node Details for + RHS, unfolding and RULE combined. Clearly, if they don't agree on their join + arity, we have to do some adjusting. We choose to adjust to the join arity + of the RHS, because that is likely the join arity that the join point will + have; see Note [Join arity prediction based on joinRhsArity]. + + If the guess is correct, then tail calls in the RHS are preserved; a necessary + condition for the whole binding becoming a joinrec. + The guess can only be incorrect in the 'AcyclicSCC' case when the binding + becomes a non-recursive join point with a different join arity. But then the + eventual call to 'adjustTailUsage' in 'tagRecBinders'/'occAnalRec' will + be with a different join arity and destroy unsound tail call info with + 'markNonTail'. * Wrinkle for RULES. Suppose the example was a bit different: let j :: Int -> Int @@ -669,28 +757,21 @@ propagate. This appears to be very rare in practice. TODO Perhaps we should gather statistics to be sure. -Note [Unfoldings and join points] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We assume that anything in an unfolding occurs multiple times, since -unfoldings are often copied (that's the whole point!). But we still -need to track tail calls for the purpose of finding join points. - - ------------------------------------------------------------ Note [Adjusting right-hand sides] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There's a bit of a dance we need to do after analysing a lambda expression or a right-hand side. In particular, we need to - a) call 'markAllInsideLam' *unless* the binding is for a thunk, a one-shot - lambda, or a non-recursive join point; and - b) call 'markAllNonTail' *unless* the binding is for a join point, and - the RHS has the right arity; e.g. + a) call 'markAllNonTail' *unless* the binding is for a join point, and + the TailUsageDetails from the RHS has the right join arity; e.g. join j x y = case ... of A -> j2 p B -> j2 q in j a b Here we want the tail calls to j2 to be tail calls of the whole expression + b) call 'markAllInsideLam' *unless* the binding is for a thunk, a one-shot + lambda, or a non-recursive join point Some examples, with how the free occurrences in e (assumed not to be a value lambda) get marked: @@ -707,26 +788,39 @@ lambda) get marked: There are a few other caveats; most importantly, if we're marking a binding as 'AlwaysTailCalled', it's *going* to be a join point, so we treat it as one so that the effect cascades properly. Consequently, at the time the RHS is -analysed, we won't know what adjustments to make; thus 'occAnalLamOrRhs' must -return the unadjusted 'UsageDetails', to be adjusted by 'adjustRhsUsage' once -join-point-hood has been decided. - -Thus the overall sequence taking place in 'occAnalNonRecBind' and -'occAnalRecBind' is as follows: - - 1. Call 'occAnalLamOrRhs' to find usage information for the RHS. - 2. Call 'tagNonRecBinder' or 'tagRecBinders', which decides whether to make +analysed, we won't know what adjustments to make; thus 'occAnalLamTail' must +return the unadjusted 'TailUsageDetails', to be adjusted by 'adjustTailUsage' +once join-point-hood has been decided and eventual one-shot annotations have +been added through 'markNonRecJoinOneShots'. + +It is not so simple to see that 'occAnalNonRecBind' and 'occAnalRecBind' indeed +perform a similar sequence of steps. Thus, here is an interleaving of events +of both functions, serving as a specification: + + 1. Call 'occAnalLamTail' to find usage information for the RHS. + Recursive case: 'makeNode' + Non-recursive case: 'occAnalNonRecBind' + 2. (Analyse the binding's scope. Done in 'occAnalBind'/`occAnal Let{}`. + Same whether recursive or not.) + 3. Call 'tagNonRecBinder' or 'tagRecBinders', which decides whether to make the binding a join point. - 3. Call 'adjustRhsUsage' accordingly. (Done as part of 'tagRecBinders' when - recursive.) - -(In the recursive case, this logic is spread between 'makeNode' and -'occAnalRec'.) + Cyclic Recursive case: 'mkLoopBreakerNodes' + Acyclic Recursive case: `occAnalRec AcyclicSCC{}` + Non-recursive case: 'occAnalNonRecBind' + 4. Non-recursive join point: Call 'markNonRecJoinOneShots' so that e.g., + FloatOut sees one-shot annotations on lambdas + Acyclic Recursive case: `occAnalRec AcyclicSCC{}` calls 'adjustNonRecRhs' + Non-recursive case: 'occAnalNonRecBind' calls 'adjustNonRecRhs' + 5. Call 'adjustTailUsage' accordingly. + Cyclic Recursive case: 'tagRecBinders' + Acyclic Recursive case: 'adjustNonRecRhs' + Non-recursive case: 'adjustNonRecRhs' -} - data WithUsageDetails a = WithUsageDetails !UsageDetails !a +data WithTailUsageDetails a = WithTailUsageDetails !TailUsageDetails !a + ------------------------------------------------------------------ -- occAnalBind ------------------------------------------------------------------ @@ -750,19 +844,17 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage | isTyVar bndr -- A type let; we don't gather usage info = WithUsageDetails body_usage [NonRec bndr rhs] - | not (bndr `usedIn` body_usage) -- It's not mentioned - = WithUsageDetails body_usage [] + | not (bndr `usedIn` body_usage) + = WithUsageDetails body_usage [] -- See Note [Dead code] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr rhs'] + = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr final_rhs] where - (body_usage', tagged_bndr) = tagNonRecBinder lvl body_usage bndr - final_bndr = tagged_bndr `setIdUnfolding` unf' - `setIdSpecialisation` mkRuleInfo rules' - rhs_usage = rhs_uds `andUDs` unf_uds `andUDs` rule_uds + WithUsageDetails body_usage' tagged_bndr = tagNonRecBinder lvl body_usage bndr -- Get the join info from the *new* decision -- See Note [Join points and unfoldings/rules] + -- => join arity O of Note [Join arity prediction based on joinRhsArity] mb_join_arity = willBeJoinId_maybe tagged_bndr is_join_point = isJust mb_join_arity @@ -773,17 +865,28 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- See Note [Sources of one-shot information] rhs_env = env1 { occ_one_shots = argOneShots dmd } - (WithUsageDetails rhs_uds rhs') = occAnalRhs rhs_env NonRecursive mb_join_arity rhs + -- See Note [Join arity prediction based on joinRhsArity] + -- Match join arity O from mb_join_arity with manifest join arity M as + -- returned by of occAnalLamTail. It's totally OK for them to mismatch; + -- hence adjust the UDs from the RHS + WithUsageDetails adj_rhs_uds final_rhs + = adjustNonRecRhs mb_join_arity $ occAnalLamTail rhs_env rhs + rhs_usage = adj_rhs_uds `andUDs` adj_unf_uds `andUDs` adj_rule_uds + final_bndr = tagged_bndr `setIdSpecialisation` mkRuleInfo rules' + `setIdUnfolding` unf2 --------- Unfolding --------- - -- See Note [Unfoldings and join points] + -- See Note [Join points and unfoldings/rules] unf | isId bndr = idUnfolding bndr | otherwise = NoUnfolding - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env NonRecursive mb_join_arity unf + WithTailUsageDetails unf_uds unf1 = occAnalUnfolding rhs_env unf + !unf2 = markNonRecUnfoldingOneShots mb_join_arity unf1 + adj_unf_uds = adjustTailArity mb_join_arity unf_uds --------- Rules --------- -- See Note [Rules are extra RHSs] and Note [Rule dependency info] - rules_w_uds = occAnalRules rhs_env mb_join_arity bndr + -- and Note [Join points and unfoldings/rules] + rules_w_uds = occAnalRules rhs_env bndr rules' = map fstOf3 rules_w_uds imp_rule_uds = impRulesScopeUsage (lookupImpRules imp_rule_edges bndr) -- imp_rule_uds: consider @@ -794,8 +897,9 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- that g is (since the RULE might turn g into h), so -- we make g mention h. - rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds - add_rule_uds (_, l, r) uds = l `andUDs` r `andUDs` uds + adj_rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds + add_rule_uds (_, l, r) uds + = l `andUDs` adjustTailArity mb_join_arity r `andUDs` uds ---------- occ = idOccInfo tagged_bndr @@ -820,7 +924,7 @@ occAnalRecBind :: OccEnv -> TopLevelFlag -> ImpRuleEdges -> [(Var,CoreExpr)] occAnalRecBind !env lvl imp_rule_edges pairs body_usage = foldr (occAnalRec rhs_env lvl) (WithUsageDetails body_usage []) sccs where - sccs :: [SCC Details] + sccs :: [SCC NodeDetails] sccs = {-# SCC "occAnalBind.scc" #-} stronglyConnCompFromEdgedVerticesUniq nodes @@ -832,27 +936,44 @@ occAnalRecBind !env lvl imp_rule_edges pairs body_usage bndr_set = mkVarSet bndrs rhs_env = env `addInScope` bndrs +adjustNonRecRhs :: Maybe JoinArity -> WithTailUsageDetails CoreExpr -> WithUsageDetails CoreExpr +-- ^ This function concentrates shared logic between occAnalNonRecBind and the +-- AcyclicSCC case of occAnalRec. +-- * It applies 'markNonRecJoinOneShots' to the RHS +-- * and returns the adjusted rhs UsageDetails combined with the body usage +adjustNonRecRhs mb_join_arity (WithTailUsageDetails rhs_tuds rhs) + = WithUsageDetails rhs_uds' rhs' + where + --------- Marking (non-rec) join binders one-shot --------- + !rhs' | Just ja <- mb_join_arity = markNonRecJoinOneShots ja rhs + | otherwise = rhs + --------- Adjusting right-hand side usage --------- + rhs_uds' = adjustTailUsage mb_join_arity rhs' rhs_tuds ----------------------------- occAnalRec :: OccEnv -> TopLevelFlag - -> SCC Details + -> SCC NodeDetails -> WithUsageDetails [CoreBind] -> WithUsageDetails [CoreBind] -- The NonRec case is just like a Let (NonRec ...) above -occAnalRec !_ lvl (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = rhs - , nd_uds = rhs_uds })) +occAnalRec !_ lvl + (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = wtuds })) (WithUsageDetails body_uds binds) + | isTyVar bndr -- A type let; we don't gather usage info + = WithUsageDetails body_uds (NonRec bndr rhs' : binds) + | not (bndr `usedIn` body_uds) = WithUsageDetails body_uds binds -- See Note [Dead code] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_uds' `andUDs` rhs_uds') - (NonRec tagged_bndr rhs : binds) + = WithUsageDetails (body_uds' `andUDs` rhs_uds') (NonRec bndr' rhs' : binds) where - (body_uds', tagged_bndr) = tagNonRecBinder lvl body_uds bndr - rhs_uds' = adjustRhsUsage mb_join_arity rhs rhs_uds + WithUsageDetails body_uds' tagged_bndr = tagNonRecBinder lvl body_uds bndr mb_join_arity = willBeJoinId_maybe tagged_bndr + WithUsageDetails rhs_uds' rhs' = adjustNonRecRhs mb_join_arity wtuds + !unf' = markNonRecUnfoldingOneShots mb_join_arity (idUnfolding tagged_bndr) + !bndr' = tagged_bndr `setIdUnfolding` unf' -- The Rec case is the interesting one -- See Note [Recursive bindings: the grand plan] @@ -873,7 +994,7 @@ occAnalRec env lvl (CyclicSCC details_s) (WithUsageDetails body_uds binds) -- Make the nodes for the loop-breaker analysis -- See Note [Choosing loop breakers] for loop_breaker_nodes final_uds :: UsageDetails - loop_breaker_nodes :: [LetrecNode] + loop_breaker_nodes :: [LoopBreakerNode] (WithUsageDetails final_uds loop_breaker_nodes) = mkLoopBreakerNodes env lvl body_uds details_s ------------------------------ @@ -1102,7 +1223,7 @@ type Binding = (Id,CoreExpr) loopBreakNodes :: Int -> VarSet -- Binders whose dependencies may be "missing" -- See Note [Weak loop breakers] - -> [LetrecNode] + -> [LoopBreakerNode] -> [Binding] -- Append these to the end -> [Binding] @@ -1121,7 +1242,7 @@ loopBreakNodes depth weak_fvs nodes binds CyclicSCC nodes -> reOrderNodes depth weak_fvs nodes binds ---------------------------------- -reOrderNodes :: Int -> VarSet -> [LetrecNode] -> [Binding] -> [Binding] +reOrderNodes :: Int -> VarSet -> [LoopBreakerNode] -> [Binding] -> [Binding] -- Choose a loop breaker, mark it no-inline, -- and call loopBreakNodes on the rest reOrderNodes _ _ [] _ = panic "reOrderNodes" @@ -1133,7 +1254,7 @@ reOrderNodes depth weak_fvs (node : nodes) binds (map (nodeBinding mk_loop_breaker) chosen_nodes ++ binds) where (chosen_nodes, unchosen) = chooseLoopBreaker approximate_lb - (nd_score (node_payload node)) + (snd_score (node_payload node)) [node] [] nodes approximate_lb = depth >= 2 @@ -1142,8 +1263,8 @@ reOrderNodes depth weak_fvs (node : nodes) binds -- After two iterations (d=0, d=1) give up -- and approximate, returning to d=0 -nodeBinding :: (Id -> Id) -> LetrecNode -> Binding -nodeBinding set_id_occ (node_payload -> ND { nd_bndr = bndr, nd_rhs = rhs}) +nodeBinding :: (Id -> Id) -> LoopBreakerNode -> Binding +nodeBinding set_id_occ (node_payload -> SND { snd_bndr = bndr, snd_rhs = rhs}) = (set_id_occ bndr, rhs) mk_loop_breaker :: Id -> Id @@ -1163,13 +1284,13 @@ mk_non_loop_breaker weak_fvs bndr tail_info = tailCallInfo (idOccInfo bndr) ---------------------------------- -chooseLoopBreaker :: Bool -- True <=> Too many iterations, - -- so approximate - -> NodeScore -- Best score so far - -> [LetrecNode] -- Nodes with this score - -> [LetrecNode] -- Nodes with higher scores - -> [LetrecNode] -- Unprocessed nodes - -> ([LetrecNode], [LetrecNode]) +chooseLoopBreaker :: Bool -- True <=> Too many iterations, + -- so approximate + -> NodeScore -- Best score so far + -> [LoopBreakerNode] -- Nodes with this score + -> [LoopBreakerNode] -- Nodes with higher scores + -> [LoopBreakerNode] -- Unprocessed nodes + -> ([LoopBreakerNode], [LoopBreakerNode]) -- This loop looks for the bind with the lowest score -- to pick as the loop breaker. The rest accumulate in chooseLoopBreaker _ _ loop_nodes acc [] @@ -1189,7 +1310,7 @@ chooseLoopBreaker approx_lb loop_sc loop_nodes acc (node : nodes) | otherwise -- Worse score so don't pick it = chooseLoopBreaker approx_lb loop_sc loop_nodes (node : acc) nodes where - sc = nd_score (node_payload node) + sc = snd_score (node_payload node) {- Note [Complexity of loop breaking] @@ -1322,16 +1443,21 @@ ToDo: try using the occurrence info for the inline'd binder. ************************************************************************ -} -type LetrecNode = Node Unique Details -- Node comes from Digraph - -- The Unique key is gotten from the Id -data Details - = ND { nd_bndr :: Id -- Binder +-- | Digraph node as constructed by 'makeNode' and consumed by 'occAnalRec'. +-- The Unique key is gotten from the Id. +type LetrecNode = Node Unique NodeDetails - , nd_rhs :: CoreExpr -- RHS, already occ-analysed +-- | Node details as consumed by 'occAnalRec'. +data NodeDetails + = ND { nd_bndr :: Id -- Binder - , nd_uds :: UsageDetails -- Usage from RHS, and RULES, and stable unfoldings - -- ignoring phase (ie assuming all are active) - -- See Note [Forming Rec groups] + , nd_rhs :: !(WithTailUsageDetails CoreExpr) + -- ^ RHS, already occ-analysed + -- With TailUsageDetails from RHS, and RULES, and stable unfoldings, + -- ignoring phase (ie assuming all are active). + -- NB: Unadjusted TailUsageDetails, as if this Node becomes a + -- non-recursive join point! + -- See Note [TailUsageDetails when forming Rec groups] , nd_inl :: IdSet -- Free variables of the stable unfolding and the RHS -- but excluding any RULES @@ -1348,18 +1474,33 @@ data Details , nd_active_rule_fvs :: IdSet -- Variables bound in this Rec group that are free -- in the RHS of an active rule for this bndr -- See Note [Rules and loop breakers] - - , nd_score :: NodeScore } -instance Outputable Details where +instance Outputable NodeDetails where ppr nd = text "ND" <> braces (sep [ text "bndr =" <+> ppr (nd_bndr nd) - , text "uds =" <+> ppr (nd_uds nd) + , text "uds =" <+> ppr uds , text "inl =" <+> ppr (nd_inl nd) , text "simple =" <+> ppr (nd_simple nd) , text "active_rule_fvs =" <+> ppr (nd_active_rule_fvs nd) - , text "score =" <+> ppr (nd_score nd) + ]) + where WithTailUsageDetails uds _ = nd_rhs nd + +-- | Digraph with simplified and completely occurrence analysed +-- 'SimpleNodeDetails', retaining just the info we need for breaking loops. +type LoopBreakerNode = Node Unique SimpleNodeDetails + +-- | Condensed variant of 'NodeDetails' needed during loop breaking. +data SimpleNodeDetails + = SND { snd_bndr :: IdWithOccInfo -- OccInfo accurate + , snd_rhs :: CoreExpr -- properly occur-analysed + , snd_score :: NodeScore + } + +instance Outputable SimpleNodeDetails where + ppr nd = text "SND" <> braces + (sep [ text "bndr =" <+> ppr (snd_bndr nd) + , text "score =" <+> ppr (snd_score nd) ]) -- The NodeScore is compared lexicographically; @@ -1387,52 +1528,59 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) -- explained in Note [Deterministic SCC] in GHC.Data.Graph.Directed. where details = ND { nd_bndr = bndr' - , nd_rhs = rhs' - , nd_uds = scope_uds + , nd_rhs = WithTailUsageDetails scope_uds rhs' , nd_inl = inl_fvs , nd_simple = null rules_w_uds && null imp_rule_info , nd_weak_fvs = weak_fvs - , nd_active_rule_fvs = active_rule_fvs - , nd_score = pprPanic "makeNodeDetails" (ppr bndr) } + , nd_active_rule_fvs = active_rule_fvs } bndr' = bndr `setIdUnfolding` unf' `setIdSpecialisation` mkRuleInfo rules' - inl_uds = rhs_uds `andUDs` unf_uds - scope_uds = inl_uds `andUDs` rule_uds + -- NB: Both adj_unf_uds and adj_rule_uds have been adjusted to match the + -- JoinArity rhs_ja of unadj_rhs_uds. + unadj_inl_uds = unadj_rhs_uds `andUDs` adj_unf_uds + unadj_scope_uds = unadj_inl_uds `andUDs` adj_rule_uds + scope_uds = TUD rhs_ja unadj_scope_uds -- Note [Rules are extra RHSs] -- Note [Rule dependency info] - scope_fvs = udFreeVars bndr_set scope_uds + scope_fvs = udFreeVars bndr_set unadj_scope_uds -- scope_fvs: all occurrences from this binder: RHS, unfolding, -- and RULES, both LHS and RHS thereof, active or inactive - inl_fvs = udFreeVars bndr_set inl_uds + inl_fvs = udFreeVars bndr_set unadj_inl_uds -- inl_fvs: vars that would become free if the function was inlined. -- We conservatively approximate that by thefree vars from the RHS -- and the unfolding together. -- See Note [inl_fvs] - mb_join_arity = isJoinId_maybe bndr - -- Get join point info from the *current* decision - -- We don't know what the new decision will be! - -- Using the old decision at least allows us to - -- preserve existing join point, even RULEs are added - -- See Note [Join points and unfoldings/rules] --------- Right hand side --------- -- Constructing the edges for the main Rec computation -- See Note [Forming Rec groups] - -- Do not use occAnalRhs because we don't yet know the final - -- answer for mb_join_arity; instead, do the occAnalLam call from - -- occAnalRhs, and postpone adjustRhsUsage until occAnalRec - rhs_env = rhsCtxt env - (WithUsageDetails rhs_uds rhs') = occAnalLam rhs_env rhs + -- and Note [TailUsageDetails when forming Rec groups] + -- Compared to occAnalNonRecBind, we can't yet adjust the RHS because + -- (a) we don't yet know the final joinpointhood. It might not become a + -- join point after all! + -- (b) we don't even know whether it stays a recursive RHS after the SCC + -- analysis we are about to seed! So we can't markAllInsideLam in + -- advance, because if it ends up as a non-recursive join point we'll + -- consider it as one-shot and don't need to markAllInsideLam. + -- Instead, do the occAnalLamTail call here and postpone adjustTailUsage + -- until occAnalRec. In effect, we pretend that the RHS becomes a + -- non-recursive join point and fix up later with adjustTailUsage. + rhs_env = rhsCtxt env + WithTailUsageDetails (TUD rhs_ja unadj_rhs_uds) rhs' = occAnalLamTail rhs_env rhs + -- corresponding call to adjustTailUsage in occAnalRec and tagRecBinders --------- Unfolding --------- - -- See Note [Unfoldings and join points] + -- See Note [Join points and unfoldings/rules] unf = realIdUnfolding bndr -- realIdUnfolding: Ignore loop-breaker-ness -- here because that is what we are setting! - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env Recursive mb_join_arity unf + WithTailUsageDetails unf_tuds unf' = occAnalUnfolding rhs_env unf + adj_unf_uds = adjustTailArity (Just rhs_ja) unf_tuds + -- `rhs_ja` is `joinRhsArity rhs` and is the prediction for source M + -- of Note [Join arity prediction based on joinRhsArity] --------- IMP-RULES -------- is_active = occ_rule_act env :: Activation -> Bool @@ -1441,11 +1589,15 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) imp_rule_fvs = impRulesActiveFvs is_active bndr_set imp_rule_info --------- All rules -------- + -- See Note [Join points and unfoldings/rules] + -- `rhs_ja` is `joinRhsArity rhs'` and is the prediction for source M + -- of Note [Join arity prediction based on joinRhsArity] rules_w_uds :: [(CoreRule, UsageDetails, UsageDetails)] - rules_w_uds = occAnalRules rhs_env mb_join_arity bndr + rules_w_uds = [ (r,l,adjustTailArity (Just rhs_ja) rhs_tuds) + | (r,l,rhs_tuds) <- occAnalRules rhs_env bndr ] rules' = map fstOf3 rules_w_uds - rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds + adj_rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds add_rule_uds (_, l, r) uds = l `andUDs` r `andUDs` uds -------- active_rule_fvs ------------ @@ -1463,8 +1615,8 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) mkLoopBreakerNodes :: OccEnv -> TopLevelFlag -> UsageDetails -- for BODY of let - -> [Details] - -> WithUsageDetails [LetrecNode] -- adjusted + -> [NodeDetails] + -> WithUsageDetails [LoopBreakerNode] -- with OccInfo up-to-date -- See Note [Choosing loop breakers] -- This function primarily creates the Nodes for the -- loop-breaker SCC analysis. More specifically: @@ -1477,10 +1629,10 @@ mkLoopBreakerNodes :: OccEnv -> TopLevelFlag mkLoopBreakerNodes !env lvl body_uds details_s = WithUsageDetails final_uds (zipWithEqual "mkLoopBreakerNodes" mk_lb_node details_s bndrs') where - (final_uds, bndrs') = tagRecBinders lvl body_uds details_s + WithUsageDetails final_uds bndrs' = tagRecBinders lvl body_uds details_s mk_lb_node nd@(ND { nd_bndr = old_bndr, nd_inl = inl_fvs }) new_bndr - = DigraphNode { node_payload = new_nd + = DigraphNode { node_payload = simple_nd , node_key = varUnique old_bndr , node_dependencies = nonDetKeysUniqSet lb_deps } -- It's OK to use nonDetKeysUniqSet here as @@ -1488,7 +1640,8 @@ mkLoopBreakerNodes !env lvl body_uds details_s -- in nondeterministic order as explained in -- Note [Deterministic SCC] in GHC.Data.Graph.Directed. where - new_nd = nd { nd_bndr = new_bndr, nd_score = score } + WithTailUsageDetails _ rhs = nd_rhs nd + simple_nd = SND { snd_bndr = new_bndr, snd_rhs = rhs, snd_score = score } score = nodeScore env new_bndr lb_deps nd lb_deps = extendFvs_ rule_fv_env inl_fvs -- See Note [Loop breaker dependencies] @@ -1524,10 +1677,10 @@ group { f1 = e1; ...; fn = en } are: nodeScore :: OccEnv -> Id -- Binder with new occ-info -> VarSet -- Loop-breaker dependencies - -> Details + -> NodeDetails -> NodeScore nodeScore !env new_bndr lb_deps - (ND { nd_bndr = old_bndr, nd_rhs = bind_rhs }) + (ND { nd_bndr = old_bndr, nd_rhs = WithTailUsageDetails _ bind_rhs }) | not (isId old_bndr) -- A type or coercion variable is never a loop breaker = (100, 0, False) @@ -1748,7 +1901,7 @@ lambda and casts, e.g. * Occurrence analyser: we just mark each binder in the lambda-group (here: x,y,z) with its occurrence info in the *body* of the - lambda-group. See occAnalLam. + lambda-group. See occAnalLamTail. * Simplifier. The simplifier is careful when partially applying lambda-groups. See the call to zapLambdaBndrs in @@ -1804,25 +1957,31 @@ zapLambdaBndrs fun arg_count zap_bndr b | isTyVar b = b | otherwise = zapLamIdInfo b -occAnalLam :: OccEnv -> CoreExpr -> (WithUsageDetails CoreExpr) --- See Note [Occurrence analysis for lambda binders] +occAnalLamTail :: OccEnv -> CoreExpr -> WithTailUsageDetails CoreExpr +-- ^ See Note [Occurrence analysis for lambda binders]. -- It does the following: -- * Sets one-shot info on the lambda binder from the OccEnv, and -- removes that one-shot info from the OccEnv -- * Sets the OccEnv to OccVanilla when going under a value lambda -- * Tags each lambda with its occurrence information -- * Walks through casts +-- * Package up the analysed lambda with its manifest join arity +-- -- This function does /not/ do -- markAllInsideLam or -- markAllNonTail --- The caller does that, either in occAnal (Lam {}), or in adjustRhsUsage +-- The caller does that, via adjustTailUsage (mostly calls go through +-- adjustNonRecRhs). Every call to occAnalLamTail must ultimately call +-- adjustTailUsage to discharge the assumed join arity. +-- +-- In effect, the analysis result is for a non-recursive join point with +-- manifest arity and adjustTailUsage does the fixup. -- See Note [Adjusting right-hand sides] - -occAnalLam env (Lam bndr expr) +occAnalLamTail env (Lam bndr expr) | isTyVar bndr - = let env1 = addOneInScope env bndr - WithUsageDetails usage expr' = occAnalLam env1 expr - in WithUsageDetails usage (Lam bndr expr') + , let env1 = addOneInScope env bndr + , WithTailUsageDetails (TUD ja usage) expr' <- occAnalLamTail env1 expr + = WithTailUsageDetails (TUD (ja+1) usage) (Lam bndr expr') -- Important: Keep the 'env' unchanged so that with a RHS like -- \(@ x) -> K @x (f @x) -- we'll see that (K @x (f @x)) is in a OccRhs, and hence refrain @@ -1840,14 +1999,14 @@ occAnalLam env (Lam bndr expr) env1 = env { occ_encl = OccVanilla, occ_one_shots = env_one_shots' } env2 = addOneInScope env1 bndr - (WithUsageDetails usage expr') = occAnalLam env2 expr + WithTailUsageDetails (TUD ja usage) expr' = occAnalLamTail env2 expr (usage', bndr2) = tagLamBinder usage bndr1 - in WithUsageDetails usage' (Lam bndr2 expr') + in WithTailUsageDetails (TUD (ja+1) usage') (Lam bndr2 expr') -- For casts, keep going in the same lambda-group -- See Note [Occurrence analysis for lambda binders] -occAnalLam env (Cast expr co) - = let (WithUsageDetails usage expr') = occAnalLam env expr +occAnalLamTail env (Cast expr co) + = let WithTailUsageDetails (TUD ja usage) expr' = occAnalLamTail env expr -- usage1: see Note [Gather occurrences of coercion variables] usage1 = addManyOccs usage (coVarsOfCo co) @@ -1857,15 +2016,16 @@ occAnalLam env (Cast expr co) _ -> usage1 -- usage3: you might think this was not necessary, because of - -- the markAllNonTail in adjustRhsUsage; but not so! For a - -- join point, adjustRhsUsage doesn't do this; yet if there is + -- the markAllNonTail in adjustTailUsage; but not so! For a + -- join point, adjustTailUsage doesn't do this; yet if there is -- a cast, we must! Also: why markAllNonTail? See -- GHC.Core.Lint: Note Note [Join points and casts] usage3 = markAllNonTail usage2 - in WithUsageDetails usage3 (Cast expr' co) + in WithTailUsageDetails (TUD ja usage3) (Cast expr' co) -occAnalLam env expr = occAnal env expr +occAnalLamTail env expr = case occAnal env expr of + WithUsageDetails usage expr' -> WithTailUsageDetails (TUD 0 usage) expr' {- Note [Occ-anal and cast worker/wrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1885,8 +2045,8 @@ RHS. So it'll get a Many occ-info. (Maybe Cast w/w should create a stable unfolding, which would obviate this Note; but that seems a bit of a heavyweight solution.) -We only need to this in occAnalLam, not occAnal, because the top leve -of a right hand side is handled by occAnalLam. +We only need to this in occAnalLamTail, not occAnal, because the top leve +of a right hand side is handled by occAnalLamTail. -} @@ -1896,57 +2056,23 @@ of a right hand side is handled by occAnalLam. * * ********************************************************************* -} -occAnalRhs :: OccEnv -> RecFlag -> Maybe JoinArity - -> CoreExpr -- RHS - -> WithUsageDetails CoreExpr -occAnalRhs !env is_rec mb_join_arity rhs - = let (WithUsageDetails usage rhs1) = occAnalLam env rhs - -- We call occAnalLam here, not occAnalExpr, so that it doesn't - -- do the markAllInsideLam and markNonTailCall stuff before - -- we've had a chance to help with join points; that comes next - rhs2 = markJoinOneShots is_rec mb_join_arity rhs1 - rhs_usage = adjustRhsUsage mb_join_arity rhs2 usage - in WithUsageDetails rhs_usage rhs2 - - - -markJoinOneShots :: RecFlag -> Maybe JoinArity -> CoreExpr -> CoreExpr --- For a /non-recursive/ join point we can mark all --- its join-lambda as one-shot; and it's a good idea to do so -markJoinOneShots NonRecursive (Just join_arity) rhs - = go join_arity rhs - where - go 0 rhs = rhs - go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) - (go (n-1) rhs) - go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. - -- e.g. let j = case ... in j True - -- This will become an arity-1 join point after the - -- simplifier has eta-expanded it; but it may not have - -- enough lambdas /yet/. (Lint checks that JoinIds do - -- have enough lambdas.) -markJoinOneShots _ _ rhs - = rhs - occAnalUnfolding :: OccEnv - -> RecFlag - -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Unfolding - -> WithUsageDetails Unfolding + -> WithTailUsageDetails Unfolding -- Occurrence-analyse a stable unfolding; --- discard a non-stable one altogether. -occAnalUnfolding !env is_rec mb_join_arity unf +-- discard a non-stable one altogether and return empty usage details. +occAnalUnfolding !env unf = case unf of unf@(CoreUnfolding { uf_tmpl = rhs, uf_src = src }) | isStableSource src -> let - (WithUsageDetails usage rhs') = occAnalRhs env is_rec mb_join_arity rhs + WithTailUsageDetails (TUD rhs_ja usage) rhs' = occAnalLamTail env rhs unf' | noBinderSwaps env = unf -- Note [Unfoldings and rules] | otherwise = unf { uf_tmpl = rhs' } - in WithUsageDetails (markAllMany usage) unf' + in WithTailUsageDetails (TUD rhs_ja (markAllMany usage)) unf' -- markAllMany: see Note [Occurrences in stable unfoldings] - | otherwise -> WithUsageDetails emptyDetails unf + | otherwise -> WithTailUsageDetails (TUD 0 emptyDetails) unf -- For non-Stable unfoldings we leave them undisturbed, but -- don't count their usage because the simplifier will discard them. -- We leave them undisturbed because nodeScore uses their size info @@ -1955,29 +2081,26 @@ occAnalUnfolding !env is_rec mb_join_arity unf -- scope remain in scope; there is no cloning etc. unf@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) - -> WithUsageDetails final_usage (unf { df_args = args' }) + -> WithTailUsageDetails (TUD 0 final_usage) (unf { df_args = args' }) where env' = env `addInScope` bndrs (WithUsageDetails usage args') = occAnalList env' args - final_usage = markAllManyNonTail (delDetailsList usage bndrs) - `addLamCoVarOccs` bndrs - `delDetailsList` bndrs + final_usage = usage `addLamCoVarOccs` bndrs `delDetailsList` bndrs -- delDetailsList; no need to use tagLamBinders because we -- never inline DFuns so the occ-info on binders doesn't matter - unf -> WithUsageDetails emptyDetails unf + unf -> WithTailUsageDetails (TUD 0 emptyDetails) unf occAnalRules :: OccEnv - -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Id -- Get rules from here -> [(CoreRule, -- Each (non-built-in) rule UsageDetails, -- Usage details for LHS - UsageDetails)] -- Usage details for RHS -occAnalRules !env mb_join_arity bndr + TailUsageDetails)] -- Usage details for RHS +occAnalRules !env bndr = map occ_anal_rule (idCoreRules bndr) where occ_anal_rule rule@(Rule { ru_bndrs = bndrs, ru_args = args, ru_rhs = rhs }) - = (rule', lhs_uds', rhs_uds') + = (rule', lhs_uds', TUD rhs_ja rhs_uds') where env' = env `addInScope` bndrs rule' | noBinderSwaps env = rule -- Note [Unfoldings and rules] @@ -1990,14 +2113,11 @@ occAnalRules !env mb_join_arity bndr (WithUsageDetails rhs_uds rhs') = occAnal env' rhs -- Note [Rules are extra RHSs] -- Note [Rule dependency info] - rhs_uds' = markAllNonTailIf (not exact_join) $ - markAllMany $ + rhs_uds' = markAllMany $ rhs_uds `delDetailsList` bndrs + rhs_ja = length args -- See Note [Join points and unfoldings/rules] - exact_join = exactJoin mb_join_arity args - -- See Note [Join points and unfoldings/rules] - - occ_anal_rule other_rule = (other_rule, emptyDetails, emptyDetails) + occ_anal_rule other_rule = (other_rule, emptyDetails, TUD 0 emptyDetails) {- Note [Join point RHSs] ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2032,6 +2152,8 @@ Another way to think about it: if we inlined g as-is into multiple call sites, now there's be multiple calls to f. Bottom line: treat all occurrences in a stable unfolding as "Many". +We still leave tail call information intact, though, as to not spoil +potential join points. Note [Unfoldings and rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2209,10 +2331,7 @@ occAnal env app@(App _ _) = occAnalApp env (collectArgsTicks tickishFloatable app) occAnal env expr@(Lam {}) - = let (WithUsageDetails usage expr') = occAnalLam env expr - final_usage = markAllInsideLamIf (not (isOneShotFun expr')) $ - markAllNonTail usage - in WithUsageDetails final_usage expr' + = adjustNonRecRhs Nothing $ occAnalLamTail env expr -- mb_join_arity == Nothing <=> markAllManyNonTail occAnal env (Case scrut bndr ty alts) = let @@ -2287,7 +2406,7 @@ occAnalApp !env (Var fun, args, ticks) -- This caused #18296 | fun `hasKey` runRWKey , [t1, t2, arg] <- args - , let (WithUsageDetails usage arg') = occAnalRhs env NonRecursive (Just 1) arg + , WithUsageDetails usage arg' <- adjustNonRecRhs (Just 1) $ occAnalLamTail env arg = WithUsageDetails usage (mkTicks ticks $ mkApps (Var fun) [t1, t2, arg']) occAnalApp env (Var fun_id, args, ticks) @@ -2872,7 +2991,6 @@ lookupBndrSwap env@(OccEnv { occ_bs_env = bs_env }) bndr case lookupBndrSwap env bndr1 of (fun, fun_id) -> (mkCastMCo fun mco, fun_id) } - {- Historical note [Proxy let-bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We used to do the binder-swap transformation by introducing @@ -2998,6 +3116,19 @@ data UsageDetails instance Outputable UsageDetails where ppr ud = ppr (ud_env (flattenUsageDetails ud)) +-- | Captures the result of applying 'occAnalLamTail' to a function `\xyz.body`. +-- The TailUsageDetails records +-- * the number of lambdas (including type lambdas: a JoinArity) +-- * UsageDetails for the `body`, unadjusted by `adjustTailUsage`. +-- If the binding turns out to be a join point with the indicated join +-- arity, this unadjusted usage details is just what we need; otherwise we +-- need to discard tail calls. That's what `adjustTailUsage` does. +data TailUsageDetails = TUD !JoinArity !UsageDetails + +instance Outputable TailUsageDetails where + ppr (TUD ja uds) = lambda <> ppr ja <> ppr uds + + ------------------- -- UsageDetails API @@ -3139,24 +3270,49 @@ flattenUsageDetails ud@(UD { ud_env = env }) ------------------- -- See Note [Adjusting right-hand sides] -adjustRhsUsage :: Maybe JoinArity - -> CoreExpr -- Rhs, AFTER occ anal - -> UsageDetails -- From body of lambda +adjustTailUsage :: Maybe JoinArity + -> CoreExpr -- Rhs, AFTER occAnalLamTail + -> TailUsageDetails -- From body of lambda -> UsageDetails -adjustRhsUsage mb_join_arity rhs usage +adjustTailUsage mb_join_arity rhs (TUD rhs_ja usage) = -- c.f. occAnal (Lam {}) markAllInsideLamIf (not one_shot) $ markAllNonTailIf (not exact_join) $ usage where one_shot = isOneShotFun rhs - exact_join = exactJoin mb_join_arity bndrs - (bndrs,_) = collectBinders rhs + exact_join = mb_join_arity == Just rhs_ja -exactJoin :: Maybe JoinArity -> [a] -> Bool -exactJoin Nothing _ = False -exactJoin (Just join_arity) args = args `lengthIs` join_arity - -- Remember join_arity includes type binders +adjustTailArity :: Maybe JoinArity -> TailUsageDetails -> UsageDetails +adjustTailArity mb_rhs_ja (TUD ud_ja usage) = + markAllNonTailIf (mb_rhs_ja /= Just ud_ja) usage + +markNonRecJoinOneShots :: JoinArity -> CoreExpr -> CoreExpr +-- For a /non-recursive/ join point we can mark all +-- its join-lambda as one-shot; and it's a good idea to do so +markNonRecJoinOneShots join_arity rhs + = go join_arity rhs + where + go 0 rhs = rhs + go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) + (go (n-1) rhs) + go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. + -- e.g. let j = case ... in j True + -- This will become an arity-1 join point after the + -- simplifier has eta-expanded it; but it may not have + -- enough lambdas /yet/. (Lint checks that JoinIds do + -- have enough lambdas.) + +markNonRecUnfoldingOneShots :: Maybe JoinArity -> Unfolding -> Unfolding +-- ^ Apply 'markNonRecJoinOneShots' to a stable unfolding +markNonRecUnfoldingOneShots mb_join_arity unf + | Just ja <- mb_join_arity + , CoreUnfolding{uf_src=src,uf_tmpl=tmpl} <- unf + , isStableSource src + , let !tmpl' = markNonRecJoinOneShots ja tmpl + = unf{uf_tmpl=tmpl'} + | otherwise + = unf type IdWithOccInfo = Id @@ -3192,8 +3348,8 @@ tagLamBinder usage bndr tagNonRecBinder :: TopLevelFlag -- At top level? -> UsageDetails -- Of scope -> CoreBndr -- Binder - -> (UsageDetails, -- Details with binder removed - IdWithOccInfo) -- Tagged binder + -> WithUsageDetails -- Details with binder removed + IdWithOccInfo -- Tagged binder tagNonRecBinder lvl usage binder = let @@ -3205,37 +3361,34 @@ tagNonRecBinder lvl usage binder binder' = setBinderOcc occ' binder usage' = usage `delDetails` binder in - usage' `seq` (usage', binder') + WithUsageDetails usage' binder' tagRecBinders :: TopLevelFlag -- At top level? -> UsageDetails -- Of body of let ONLY - -> [Details] - -> (UsageDetails, -- Adjusted details for whole scope, + -> [NodeDetails] + -> WithUsageDetails -- Adjusted details for whole scope, -- with binders removed - [IdWithOccInfo]) -- Tagged binders + [IdWithOccInfo] -- Tagged binders -- Substantially more complicated than non-recursive case. Need to adjust RHS -- details *before* tagging binders (because the tags depend on the RHSes). tagRecBinders lvl body_uds details_s = let bndrs = map nd_bndr details_s - rhs_udss = map nd_uds details_s - -- 1. Determine join-point-hood of whole group, as determined by - -- the *unadjusted* usage details - unadj_uds = foldr andUDs body_uds rhs_udss + -- 1. See Note [Join arity prediction based on joinRhsArity] + -- Determine possible join-point-hood of whole group, by testing for + -- manifest join arity M. + -- This (re-)asserts that makeNode had made tuds for that same arity M! + unadj_uds = foldr (andUDs . test_manifest_arity) body_uds details_s + test_manifest_arity ND{nd_rhs=WithTailUsageDetails tuds rhs} + = adjustTailArity (Just (joinRhsArity rhs)) tuds - -- This is only used in `mb_join_arity`, to adjust each `Details` in `details_s`, thus, - -- when `bndrs` is non-empty. So, we only write `maybe False` as `decideJoinPointHood` - -- takes a `NonEmpty CoreBndr`; the default value `False` won't affect program behavior. - will_be_joins = maybe False (decideJoinPointHood lvl unadj_uds) (nonEmpty bndrs) - - -- 2. Adjust usage details of each RHS, taking into account the - -- join-point-hood decision - rhs_udss' = [ adjustRhsUsage (mb_join_arity bndr) rhs rhs_uds - | ND { nd_bndr = bndr, nd_uds = rhs_uds - , nd_rhs = rhs } <- details_s ] + bndr_ne = expectNonEmpty "List of binders is never empty" bndrs + will_be_joins = decideJoinPointHood lvl unadj_uds bndr_ne mb_join_arity :: Id -> Maybe JoinArity + -- mb_join_arity: See Note [Join arity prediction based on joinRhsArity] + -- This is the source O mb_join_arity bndr -- Can't use willBeJoinId_maybe here because we haven't tagged -- the binder yet (the tag depends on these adjustments!) @@ -3247,6 +3400,12 @@ tagRecBinders lvl body_uds details_s = assert (not will_be_joins) -- Should be AlwaysTailCalled if Nothing -- we are making join points! + -- 2. Adjust usage details of each RHS, taking into account the + -- join-point-hood decision + rhs_udss' = [ adjustTailUsage (mb_join_arity bndr) rhs rhs_tuds -- matching occAnalLamTail in makeNode + | ND { nd_bndr = bndr, nd_rhs = WithTailUsageDetails rhs_tuds rhs } + <- details_s ] + -- 3. Compute final usage details from adjusted RHS details adj_uds = foldr andUDs body_uds rhs_udss' @@ -3257,7 +3416,7 @@ tagRecBinders lvl body_uds details_s -- 5. Drop the binders from the adjusted details and return usage' = adj_uds `delDetailsList` bndrs in - (usage', bndrs') + WithUsageDetails usage' bndrs' setBinderOcc :: OccInfo -> CoreBndr -> CoreBndr setBinderOcc occ_info bndr @@ -3271,12 +3430,13 @@ setBinderOcc occ_info bndr | otherwise = setIdOccInfo bndr occ_info --- | Decide whether some bindings should be made into join points or not. +-- | Decide whether some bindings should be made into join points or not, based +-- on its occurrences. This is -- Returns `False` if they can't be join points. Note that it's an -- all-or-nothing decision, as if multiple binders are given, they're -- assumed to be mutually recursive. -- --- It must, however, be a final decision. If we say "True" for 'f', +-- It must, however, be a final decision. If we say `True` for 'f', -- and then subsequently decide /not/ make 'f' into a join point, then -- the decision about another binding 'g' might be invalidated if (say) -- 'f' tail-calls 'g'. ===================================== compiler/GHC/Data/Graph/Directed.hs ===================================== @@ -4,6 +4,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE DeriveFunctor #-} module GHC.Data.Graph.Directed ( Graph, graphFromEdgedVerticesOrd, graphFromEdgedVerticesUniq, @@ -108,7 +109,7 @@ data Node key payload = DigraphNode { node_payload :: payload, -- ^ User data node_key :: key, -- ^ User defined node id node_dependencies :: [key] -- ^ Dependencies/successors of the node - } + } deriving Functor instance (Outputable a, Outputable b) => Outputable (Node a b) where ===================================== compiler/GHC/Utils/Misc.hs ===================================== @@ -35,7 +35,7 @@ module GHC.Utils.Misc ( equalLength, compareLength, leLength, ltLength, isSingleton, only, expectOnly, GHC.Utils.Misc.singleton, - notNull, snocView, + notNull, expectNonEmpty, snocView, chunkList, @@ -481,7 +481,6 @@ expectOnly _ (a:_) = a #endif expectOnly msg _ = panic ("expectOnly: " ++ msg) - -- | Split a list into chunks of /n/ elements chunkList :: Int -> [a] -> [[a]] chunkList _ [] = [] @@ -500,6 +499,16 @@ changeLast [] _ = panic "changeLast" changeLast [_] x = [x] changeLast (x:xs) x' = x : changeLast xs x' +-- | Like @expectJust msg . nonEmpty@; a better alternative to 'NE.fromList'. +expectNonEmpty :: HasCallStack => String -> [a] -> NonEmpty a +{-# INLINE expectNonEmpty #-} +expectNonEmpty _ (x:xs) = x:|xs +expectNonEmpty msg [] = expectNonEmptyPanic msg + +expectNonEmptyPanic :: String -> a +expectNonEmptyPanic msg = panic ("expectNonEmpty: " ++ msg) +{-# NOINLINE expectNonEmptyPanic #-} + -- | Apply an effectful function to the last list element. mapLastM :: Functor f => (a -> f a) -> NonEmpty a -> f (NonEmpty a) mapLastM f (x:|[]) = NE.singleton <$> f x ===================================== testsuite/tests/simplCore/should_compile/T22428.hs ===================================== @@ -0,0 +1,9 @@ +module T22428 where + +f :: Integer -> Integer -> Integer +f x y = go y + where + go :: Integer -> Integer + go 0 = x + go n = go (n-1) + {-# INLINE go #-} ===================================== testsuite/tests/simplCore/should_compile/T22428.stderr ===================================== @@ -0,0 +1,45 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 32, types: 14, coercions: 0, joins: 1/1} + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22428.f1 :: Integer +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22428.f1 = GHC.Num.Integer.IS 1# + +-- RHS size: {terms: 28, types: 10, coercions: 0, joins: 1/1} +f :: Integer -> Integer -> Integer +[GblId, + Arity=2, + Str=<1L>, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 0] 156 0}] +f = \ (x :: Integer) (y :: Integer) -> + joinrec { + go [InlPrag=INLINE (sat-args=1), Occ=LoopBreaker, Dmd=SC(S,L)] + :: Integer -> Integer + [LclId[JoinId(1)(Just [!])], + Arity=1, + Str=<1L>, + Unf=Unf{Src=StableUser, TopLvl=False, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=False,boring_ok=False)}] + go (ds :: Integer) + = case ds of wild { + GHC.Num.Integer.IS x1 -> + case x1 of { + __DEFAULT -> jump go (GHC.Num.Integer.integerSub wild T22428.f1); + 0# -> x + }; + GHC.Num.Integer.IP x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1); + GHC.Num.Integer.IN x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1) + }; } in + jump go y + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -451,6 +451,7 @@ test('T22375', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeab # One module, T21851_2.hs, has OPTIONS_GHC -ddump-simpl # Expecting to see $s$wwombat 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']) @@ -462,3 +463,6 @@ test('T22272', normal, multimod_compile, ['T22272', '-O -fexpose-all-unfoldings test('T22459', normal, compile, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) test('T22662', normal, compile, ['']) + +# go should become a join point +test('T22428', [grep_errmsg(r'jump go') ], compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeable-binds -dsuppress-unfoldings']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0fdcb4f94b4a6b853680e49ce0e9defde32f967b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0fdcb4f94b4a6b853680e49ce0e9defde32f967b You're receiving 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 Jan 10 11:41:46 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 10 Jan 2023 06:41:46 -0500 Subject: [Git][ghc/ghc][wip/T22725] Fix void-arg-adding mechanism for worker/wrapper Message-ID: <63bd4efa82f3_3b1bf93fcc990471695@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22725 at Glasgow Haskell Compiler / GHC Commits: 109aa2b4 by Simon Peyton Jones at 2023-01-10T11:42:02+00:00 Fix void-arg-adding mechanism for worker/wrapper As #22725 shows, in worker/wrapper we must add the void argument /last/, not first. See GHC.Core.Opt.WorkWrap.Utils Note [Worker/wrapper needs to add void arg last]. That led me to to study GHC.Core.Opt.SpecConstr Note [SpecConstr needs to add void args first] which suggests the opposite! And indeed I think it's the other way round for SpecConstr -- or more precisely the void arg must precede the "extra_bndrs". That led me to some refactoring of GHC.Core.Opt.SpecConstr.calcSpecInfo. - - - - - 8 changed files: - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/simplCore/should_compile/T18328.stderr - + testsuite/tests/simplCore/should_compile/T22725.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -53,6 +53,7 @@ import GHC.Unit.Module.ModGuts import GHC.Types.Literal ( litIsLifted ) import GHC.Types.Id import GHC.Types.Id.Info ( IdDetails(..) ) +import GHC.Types.Id.Make ( voidArgId, voidPrimId ) import GHC.Types.Var.Env import GHC.Types.Var.Set import GHC.Types.Name @@ -1924,24 +1925,13 @@ spec_one env fn arg_bndrs body (call_pat, rule_number) -- And build the results ; (qvars', pats') <- generaliseDictPats qvars pats - ; let spec_body_ty = exprType spec_body - (spec_lam_args1, spec_sig, spec_arity1, spec_join_arity1) - = calcSpecInfo fn call_pat extra_bndrs - -- Annotate the variables with the strictness information from - -- the function (see Note [Strictness information in worker binders]) - add_void_arg = needsVoidWorkerArg fn arg_bndrs spec_lam_args1 - (spec_lam_args, spec_call_args, spec_arity, spec_join_arity) - | add_void_arg - -- See Note [SpecConstr needs to add void args first] - , (spec_lam_args, spec_call_args, _) <- addVoidWorkerArg spec_lam_args1 [] - -- needsVoidWorkerArg: usual w/w hack to avoid generating - -- a spec_rhs of unlifted type and no args. - , !spec_arity <- spec_arity1 + 1 - , !spec_join_arity <- fmap (+ 1) spec_join_arity1 - = (spec_lam_args, spec_call_args, spec_arity, spec_join_arity) - | otherwise - = (spec_lam_args1, spec_lam_args1, spec_arity1, spec_join_arity1) + ; let spec_body_ty = exprType spec_body + (spec_lam_args, spec_call_args, spec_sig) + = calcSpecInfo fn arg_bndrs call_pat extra_bndrs + spec_arity = count isId spec_lam_args + spec_join_arity | isJoinId fn = Just (length spec_call_args) + | otherwise = Nothing spec_id = asWorkerLikeId $ mkLocalId spec_name ManyTy (mkLamTypes spec_lam_args spec_body_ty) @@ -1953,11 +1943,7 @@ spec_one env fn arg_bndrs body (call_pat, rule_number) -- Conditionally use result of new worker-wrapper transform spec_rhs = mkLams spec_lam_args (mkSeqs cbv_args spec_body_ty spec_body) - rule_rhs = mkVarApps (Var spec_id) $ - -- This will give us all the arguments we quantify over - -- in the rule plus the void argument if present - -- since `length(qvars) + void + length(extra_bndrs) = length spec_call_args` - dropTail (length extra_bndrs) spec_call_args + rule_rhs = mkVarApps (Var spec_id) spec_call_args inline_act = idInlineActivation fn this_mod = sc_module $ sc_opts env rule = mkRule this_mod True {- Auto -} True {- Local -} @@ -2023,30 +2009,41 @@ mkSeqs seqees res_ty rhs = {- Note [SpecConstr needs to add void args first] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider a function + f :: Bool -> forall t. blah f start @t = e We want to specialize for a partially applied call `f True`. See also Note [SpecConstr call patterns], second Wrinkle. Naively we would expect to get + $sf :: forall t. blah $sf @t = $se RULE: f True = $sf -The specialized function only takes a single type argument -so we add a void argument to prevent it from turning into -a thunk. See Note [Protecting the last value argument] for details -why. Normally we would add the void argument after the -type argument giving us: +The specialized function only takes a single type argument so we add a +void argument to prevent it from turning into a thunk. See Note +[Protecting the last value argument] for details why. Normally we +would add the void argument after the type argument giving us: + $sf :: forall t. Void# -> bla $sf @t void = $se RULE: f True = $sf void# (wrong) -But if you look closely this wouldn't typecheck! -If we substitute `f True` with `$sf void#` we expect the type argument to be applied first -but we apply void# first. -The easiest fix seems to be just to add the void argument to the front of the arguments. -Now we get: + +But if you look closely this wouldn't typecheck! If we substitute `f +True` with `$sf void#` we expect the type argument to be applied first +but we apply void# first. The easiest fix seems to be just to add the +void argument to the front of the arguments. Now we get: + $sf :: Void# -> forall t. bla $sf void @t = $se RULE: f True = $sf void# + And now we can substitute `f True` with `$sf void#` with everything working out nicely! +More preisely, we need the void arg to precede the `extra_bndrs` in +calcSpecInfo, but it's fine it put it before /all/ the arguments. + +Note that putting the extra arg first is exactly from what is needed +in worker/wrapper; see Note [Worker/wrapper needs to add void arg last] +in GHC.Core.Opt.WorkWrap.Utils. + Note [generaliseDictPats] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider these two rules (#21831, item 2): @@ -2075,36 +2072,45 @@ And /now/ "SPEC:foo" is clearly more specific: we can instantiate the new "SC:foo" to match the (prefix of) "SPEC:foo". -} -calcSpecInfo :: Id -- The original function - -> CallPat -- Call pattern - -> [Var] -- Extra bndrs - -> ( [Var] -- Demand-decorated binders - , DmdSig -- Strictness of specialised thing - , Arity, Maybe JoinArity ) -- Arities of specialised thing +calcSpecInfo :: Id -- The original function + -> [InVar] -- Lambda binders of original RHS + -> CallPat -- Call pattern + -> [Var] -- Extra bndrs + -> ( [Var] -- Demand-decorated lambda binders + -- for RHS of specialised function + , [Var] -- Args for call site + , DmdSig ) -- Strictness of specialised thing -- Calculate bits of IdInfo for the specialised function -- See Note [Transfer strictness] -- See Note [Strictness information in worker binders] -calcSpecInfo fn (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs - | isJoinId fn -- Join points have strictness and arity for LHS only - = ( bndrs_w_dmds - , mkClosedDmdSig qvar_dmds div - , count isId qvars - , Just (length qvars) ) - | otherwise - = ( bndrs_w_dmds - , mkClosedDmdSig (qvar_dmds ++ extra_dmds) div - , count isId qvars + count isId extra_bndrs - , Nothing ) +calcSpecInfo fn arg_bndrs (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs + = ( spec_lam_bndrs_w_dmds + , spec_call_args + , mkClosedDmdSig (map idDemandInfo spec_lam_bndrs_w_dmds) div ) where DmdSig (DmdType _ fn_dmds div) = idDmdSig fn - val_pats = filterOut isTypeArg pats -- value args at call sites, used to determine how many demands to drop - -- from the original functions demand and for setting up dmd_env. + val_pats = filterOut isTypeArg pats + -- Value args at call sites, used to determine how many demands to drop + -- from the original functions demand and for setting up dmd_env. + dmd_env = go emptyVarEnv fn_dmds val_pats qvar_dmds = [ lookupVarEnv dmd_env qv `orElse` topDmd | qv <- qvars, isId qv ] extra_dmds = dropList val_pats fn_dmds - bndrs_w_dmds = set_dmds qvars qvar_dmds - ++ set_dmds extra_bndrs extra_dmds + -- Annotate the variables with the strictness information from + -- the function (see Note [Strictness information in worker binders]) + qvars_w_dmds = set_dmds qvars qvar_dmds + extras_w_dmds = set_dmds extra_bndrs extra_dmds + spec_lam_bndrs_w_dmds = final_qvars_w_dmds ++ extras_w_dmds + + (final_qvars_w_dmds, spec_call_args) + | needsVoidWorkerArg fn arg_bndrs (qvars ++ extra_bndrs) + -- Usual w/w hack to avoid generating + -- a spec_rhs of unlifted type and no args. + -- See Note [SpecConstr needs to add void args first] + = ( qvars_w_dmds ++ [voidArgId], qvars ++ [voidPrimId] ) + | otherwise + = ( qvars_w_dmds, qvars ) set_dmds :: [Var] -> [Demand] -> [Var] set_dmds [] _ = [] @@ -2112,8 +2118,6 @@ calcSpecInfo fn (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs set_dmds (v:vs) ds@(d:ds') | isTyVar v = v : set_dmds vs ds | otherwise = setIdDemandInfo v d : set_dmds vs ds' - dmd_env = go emptyVarEnv fn_dmds val_pats - go :: DmdEnv -> [Demand] -> [CoreExpr] -> DmdEnv -- We've filtered out all the type patterns already go env (d:ds) (pat : pats) = go (go_one env d pat) ds pats @@ -2127,7 +2131,6 @@ calcSpecInfo fn (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs = go env ds args go_one env _ _ = env - {- Note [spec_usg includes rhs_usg] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -9,7 +9,7 @@ A library for the ``worker\/wrapper'' back-end to the strictness analyser module GHC.Core.Opt.WorkWrap.Utils ( WwOpts(..), mkWwBodies, mkWWstr, mkWWstr_one - , needsVoidWorkerArg, addVoidWorkerArg + , needsVoidWorkerArg , DataConPatContext(..) , UnboxingDecision(..), canUnboxArg , findTypeShape, IsRecDataConResult(..), isRecDataCon @@ -377,25 +377,34 @@ We use the state-token type which generates no code. -- Note [Preserving float barriers]. needsVoidWorkerArg :: Id -> [Var] -> [Var] -> Bool needsVoidWorkerArg fn_id wrap_args work_args - = not (isJoinId fn_id) && no_value_arg -- See Note [Protecting the last value argument] - || needs_float_barrier -- See Note [Preserving float barriers] + = thunk_problem -- See Note [Protecting the last value argument] + || needs_float_barrier -- See Note [Preserving float barriers] where - no_value_arg = all (not . isId) work_args + -- thunk_problem: see Note [Protecting the last value argument] + -- For join points we are only worried about (4), not (1-4). + -- And (4) can't happen if (null work_args) + -- (We could be more clever, by looking at the result type, but + -- this approach is simple and conservative.) + thunk_problem | isJoinId fn_id = no_value_arg && not (null work_args) + | otherwise = no_value_arg + no_value_arg = not (any isId work_args) + + -- needs_float_barrier: see Note [Preserving float barriers] + needs_float_barrier = wrap_had_barrier && not work_has_barrier is_float_barrier v = isId v && hasNoOneShotInfo (idOneShotInfo v) wrap_had_barrier = any is_float_barrier wrap_args work_has_barrier = any is_float_barrier work_args - needs_float_barrier = wrap_had_barrier && not work_has_barrier --- | Inserts a `Void#` arg before the first argument. --- --- Why as the first argument? See Note [SpecConstr needs to add void args first] --- in SpecConstr. +-- | Inserts a `Void#` arg as the last argument. +-- Why last? See Note [Worker/wrapper needs to add void arg last] addVoidWorkerArg :: [Var] -> [StrictnessMark] - -> ([Var], -- Lambda bound args - [Var], -- Args at call site - [StrictnessMark]) -- str semantics for the worker args. + -> ( [Var] -- Lambda bound args + , [Var] -- Args at call site + , [StrictnessMark]) -- str semantics for the worker args addVoidWorkerArg work_args str_marks - = (voidArgId : work_args, voidPrimId:work_args, NotMarkedStrict:str_marks) + = ( work_args ++ [voidArgId] + , work_args ++ [voidPrimId] + , str_marks ++ [NotMarkedStrict] ) {- Note [Protecting the last value argument] @@ -403,8 +412,8 @@ Note [Protecting the last value argument] If the user writes (\_ -> E), they might be intentionally disallowing the sharing of E. Since absence analysis and worker-wrapper are keen to remove such unused arguments, we add in a void argument to prevent -the function from becoming a thunk. Three reasons why turning a function -into a thunk might be bad: +the function from becoming a thunk. Here are several reasons why turning +a function into a thunk might be bad: 1) It can create a space leak. e.g. f x = let y () = [1..x] @@ -423,7 +432,19 @@ into a thunk might be bad: g = \x. 30# Removing the \x would leave an unlifted binding. -NB: none of these apply to a join point. +4) It can create a worker of ill-kinded type (#22275). Consider + f :: forall r (a :: TYPE r). () -> a + f x = f x + Here `x` is absent, but if we simply drop it we'd end up with + $wf :: forall r (a :: TYPE r). a + But alas $wf's type is ill-kinded: the kind of (/\r (a::TYPE r).a) + is (TYPE r), which mentions the bound variable `r`. See also + Note [Worker/wrapper needs to add void arg last] + +See also Note [Preserving float barriers] + +NB: Of these, only (1-3) don't apply to a join point, which can be +unlifted even if the RHS is not ok-for-speculation. Note [Preserving float barriers] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -457,7 +478,7 @@ which some are absent or one-shot and the resulting worker arguments: * \a{Abs}.\b{os}.\c{os}... ==> \b{os}.\c{os}.\(_::Void#)... Wrapper arg `a` was the only float barrier and had been dropped. Hence Void# - * \a{Abs,os}.\b{os}.\c... ==> \b{os}.\c... +p * \a{Abs,os}.\b{os}.\c... ==> \b{os}.\c... Worker arg `c` is a float barrier. * \a.\b{Abs}.\c{os}... ==> \a.\c{os}... Worker arg `a` is a float barrier. @@ -469,6 +490,28 @@ which some are absent or one-shot and the resulting worker arguments: Executable examples in T21150. +Note [Worker/wrapper needs to add void arg last] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider point (4) of Note [Protecting the last value argument] + + f :: forall r (a :: TYPE r). () -> a + f x = f x + +As pointed out in (4) we need to add a void argument. But if we add +it /first/ we'd get + + $wf :: Void# -> forall r (a :: TYPE r). a + $wf = ... + +But alas $wf's type is /still/ still-kinded, just as before in (4). +Solution is simple: put the void argument /last/: + + $wf :: forall r (a :: TYPE r). Void# -> a + $wf = ... + +Notice that this is exactly backwards from GHC.Core.Opt.SpecConstr +Note [SpecConstr needs to add void args first]. + Note [Join points and beta-redexes] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Originally, the worker would invoke the original function by calling it with ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1337,7 +1337,7 @@ ty_con_app_fun_maybe many_ty_co tc args | otherwise = Nothing -mkFunctionType :: Mult -> Type -> Type -> Type +mkFunctionType :: HasDebugCallStack => Mult -> Type -> Type -> Type -- ^ This one works out the FunTyFlag from the argument type -- See GHC.Types.Var Note [FunTyFlag] mkFunctionType mult arg_ty res_ty ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -158,7 +158,7 @@ coreAltsType :: [CoreAlt] -> Type coreAltsType (alt:_) = coreAltType alt coreAltsType [] = panic "coreAltsType" -mkLamType :: Var -> Type -> Type +mkLamType :: HasDebugCallStack => Var -> Type -> Type -- ^ Makes a @(->)@ type or an implicit forall type, depending -- on whether it is given a type variable or a term variable. -- This is used, for example, when producing the type of a lambda. ===================================== testsuite/tests/simplCore/should_compile/T13143.stderr ===================================== @@ -1,14 +1,14 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 71, types: 41, coercions: 0, joins: 0/0} + = {terms: 71, types: 40, coercions: 0, joins: 0/0} Rec { -- RHS size: {terms: 4, types: 3, coercions: 0, joins: 0/0} T13143.$wf [InlPrag=NOINLINE, Occ=LoopBreaker] - :: (# #) -> forall {a}. a + :: forall {a}. (# #) -> a [GblId, Arity=1, Str=b, Cpr=b, Unf=OtherCon []] -T13143.$wf = \ _ [Occ=Dead] (@a) -> T13143.$wf GHC.Prim.(##) @a +T13143.$wf = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##) end Rec } -- RHS size: {terms: 4, types: 3, coercions: 0, joins: 0/0} @@ -17,55 +17,60 @@ f [InlPrag=NOINLINE[final]] :: forall a. Int -> a Arity=1, Str=b, Cpr=b, - 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=True) - Tmpl= \ (@a) _ [Occ=Dead] -> T13143.$wf GHC.Prim.(##) @a}] -f = \ (@a) _ [Occ=Dead] -> T13143.$wf GHC.Prim.(##) @a + Tmpl= \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##)}] +f = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##) -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T13143.$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}] T13143.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T13143.$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}] T13143.$trModule3 = GHC.Types.TrNameS T13143.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T13143.$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}] T13143.$trModule2 = "T13143"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T13143.$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}] 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}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T13143.$trModule = GHC.Types.Module T13143.$trModule3 T13143.$trModule1 --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -lvl :: forall {a}. a +-- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} +lvl :: Int [GblId, Str=b, Cpr=b] -lvl = T13143.$wf GHC.Prim.(##) +lvl = T13143.$wf @Int GHC.Prim.(##) Rec { --- RHS size: {terms: 28, types: 8, coercions: 0, joins: 0/0} +-- RHS size: {terms: 28, types: 7, coercions: 0, joins: 0/0} T13143.$wg [InlPrag=[2], Occ=LoopBreaker] :: Bool -> Bool -> GHC.Prim.Int# -> GHC.Prim.Int# [GblId[StrictWorker([!, !])], @@ -94,8 +99,8 @@ g [InlPrag=[2]] :: Bool -> Bool -> Int -> Int Arity=3, Str=<1L><1L><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=3,unsat_ok=True,boring_ok=False) Tmpl= \ (ds [Occ=Once1] :: Bool) (ds1 [Occ=Once1] :: Bool) ===================================== testsuite/tests/simplCore/should_compile/T18328.stderr ===================================== @@ -1,84 +1,90 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 65, types: 53, coercions: 0, joins: 1/1} + = {terms: 69, types: 55, coercions: 0, joins: 1/1} --- RHS size: {terms: 38, types: 23, coercions: 0, joins: 1/1} +-- RHS size: {terms: 42, types: 25, coercions: 0, joins: 1/1} T18328.$wf [InlPrag=[2]] :: forall {a}. GHC.Prim.Int# -> [a] -> [a] -> [a] -[GblId, +[GblId[StrictWorker([~, !])], Arity=3, Str=, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [176 0 0] 306 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [176 0 0] 306 0}] T18328.$wf - = \ (@a) (ww :: GHC.Prim.Int#) (w :: [a]) (w1 :: [a]) -> + = \ (@a) (ww :: GHC.Prim.Int#) (ys :: [a]) (eta :: [a]) -> join { - $wj [InlPrag=NOINLINE, Dmd=ML] :: forall {p}. [a] - [LclId[JoinId(1)]] - $wj (@p) + $wj [InlPrag=NOINLINE, Dmd=MC(1,L)] :: forall {p}. (# #) -> [a] + [LclId[JoinId(2)(Nothing)], Arity=1, Str=, Unf=OtherCon []] + $wj (@p) _ [Occ=Dead, OS=OneShot] = case ww of { - __DEFAULT -> ++ @a w (++ @a w (++ @a w w1)); - 3# -> ++ @a w (++ @a w (++ @a w (++ @a w w1))) + __DEFAULT -> ++ @a ys (++ @a ys (++ @a ys eta)); + 3# -> ++ @a ys (++ @a ys (++ @a ys (++ @a ys eta))) } } in case ww of { - __DEFAULT -> ++ @a w w1; - 1# -> jump $wj @Integer; - 2# -> jump $wj @Integer; - 3# -> jump $wj @Integer + __DEFAULT -> ++ @a ys eta; + 1# -> jump $wj @Integer GHC.Prim.(##); + 2# -> jump $wj @Integer GHC.Prim.(##); + 3# -> jump $wj @Integer GHC.Prim.(##) } -- RHS size: {terms: 11, types: 9, coercions: 0, joins: 0/0} f [InlPrag=[2]] :: forall a. Int -> [a] -> [a] -> [a] [GblId, Arity=3, - Str=<1P(SL)>, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Str=<1!P(SL)>, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) Tmpl= \ (@a) - (w [Occ=Once1!] :: Int) - (w1 [Occ=Once1] :: [a]) - (w2 [Occ=Once1] :: [a]) -> - case w of { GHC.Types.I# ww [Occ=Once1] -> - T18328.$wf @a ww w1 w2 + (x [Occ=Once1!] :: Int) + (ys [Occ=Once1] :: [a]) + (eta [Occ=Once1] :: [a]) -> + case x of { GHC.Types.I# ww [Occ=Once1] -> + T18328.$wf @a ww ys eta }}] -f = \ (@a) (w :: Int) (w1 :: [a]) (w2 :: [a]) -> - case w of { GHC.Types.I# ww -> T18328.$wf @a ww w1 w2 } +f = \ (@a) (x :: Int) (ys :: [a]) (eta :: [a]) -> + case x of { GHC.Types.I# ww -> T18328.$wf @a ww ys eta } -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule3 = GHC.Types.TrNameS T18328.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule2 = "T18328"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule1 = GHC.Types.TrNameS T18328.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T18328.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T18328.$trModule = GHC.Types.Module T18328.$trModule3 T18328.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T22725.hs ===================================== @@ -0,0 +1,6 @@ +module M where + +import GHC.Exts (TYPE) + +f :: forall r (a :: TYPE r). () -> a +f x = f x ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -462,3 +462,4 @@ test('T22272', normal, multimod_compile, ['T22272', '-O -fexpose-all-unfoldings test('T22459', normal, compile, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) test('T22662', normal, compile, ['']) +test('T22725', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/109aa2b4f5fd45c858e430cc9c770ed767bb801d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/109aa2b4f5fd45c858e430cc9c770ed767bb801d You're receiving 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 Jan 10 11:59:05 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 10 Jan 2023 06:59:05 -0500 Subject: [Git][ghc/ghc][wip/T22725] Fix void-arg-adding mechanism for worker/wrapper Message-ID: <63bd53099b616_3b1bf98fe52c4486046@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22725 at Glasgow Haskell Compiler / GHC Commits: 8e58c4c4 by Simon Peyton Jones at 2023-01-10T11:59:27+00:00 Fix void-arg-adding mechanism for worker/wrapper As #22725 shows, in worker/wrapper we must add the void argument /last/, not first. See GHC.Core.Opt.WorkWrap.Utils Note [Worker/wrapper needs to add void arg last]. That led me to to study GHC.Core.Opt.SpecConstr Note [SpecConstr needs to add void args first] which suggests the opposite! And indeed I think it's the other way round for SpecConstr -- or more precisely the void arg must precede the "extra_bndrs". That led me to some refactoring of GHC.Core.Opt.SpecConstr.calcSpecInfo. - - - - - 8 changed files: - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/simplCore/should_compile/T18328.stderr - + testsuite/tests/simplCore/should_compile/T22725.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -53,6 +53,7 @@ import GHC.Unit.Module.ModGuts import GHC.Types.Literal ( litIsLifted ) import GHC.Types.Id import GHC.Types.Id.Info ( IdDetails(..) ) +import GHC.Types.Id.Make ( voidArgId, voidPrimId ) import GHC.Types.Var.Env import GHC.Types.Var.Set import GHC.Types.Name @@ -1924,24 +1925,13 @@ spec_one env fn arg_bndrs body (call_pat, rule_number) -- And build the results ; (qvars', pats') <- generaliseDictPats qvars pats - ; let spec_body_ty = exprType spec_body - (spec_lam_args1, spec_sig, spec_arity1, spec_join_arity1) - = calcSpecInfo fn call_pat extra_bndrs - -- Annotate the variables with the strictness information from - -- the function (see Note [Strictness information in worker binders]) - add_void_arg = needsVoidWorkerArg fn arg_bndrs spec_lam_args1 - (spec_lam_args, spec_call_args, spec_arity, spec_join_arity) - | add_void_arg - -- See Note [SpecConstr needs to add void args first] - , (spec_lam_args, spec_call_args, _) <- addVoidWorkerArg spec_lam_args1 [] - -- needsVoidWorkerArg: usual w/w hack to avoid generating - -- a spec_rhs of unlifted type and no args. - , !spec_arity <- spec_arity1 + 1 - , !spec_join_arity <- fmap (+ 1) spec_join_arity1 - = (spec_lam_args, spec_call_args, spec_arity, spec_join_arity) - | otherwise - = (spec_lam_args1, spec_lam_args1, spec_arity1, spec_join_arity1) + ; let spec_body_ty = exprType spec_body + (spec_lam_args, spec_call_args, spec_sig) + = calcSpecInfo fn arg_bndrs call_pat extra_bndrs + spec_arity = count isId spec_lam_args + spec_join_arity | isJoinId fn = Just (length spec_call_args) + | otherwise = Nothing spec_id = asWorkerLikeId $ mkLocalId spec_name ManyTy (mkLamTypes spec_lam_args spec_body_ty) @@ -1953,11 +1943,7 @@ spec_one env fn arg_bndrs body (call_pat, rule_number) -- Conditionally use result of new worker-wrapper transform spec_rhs = mkLams spec_lam_args (mkSeqs cbv_args spec_body_ty spec_body) - rule_rhs = mkVarApps (Var spec_id) $ - -- This will give us all the arguments we quantify over - -- in the rule plus the void argument if present - -- since `length(qvars) + void + length(extra_bndrs) = length spec_call_args` - dropTail (length extra_bndrs) spec_call_args + rule_rhs = mkVarApps (Var spec_id) spec_call_args inline_act = idInlineActivation fn this_mod = sc_module $ sc_opts env rule = mkRule this_mod True {- Auto -} True {- Local -} @@ -2020,33 +2006,55 @@ mkSeqs seqees res_ty rhs = = rhs -{- Note [SpecConstr needs to add void args first] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- Note [SpecConstr void argument insertion] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider a function + f :: Bool -> forall t. blah f start @t = e We want to specialize for a partially applied call `f True`. See also Note [SpecConstr call patterns], second Wrinkle. Naively we would expect to get + $sf :: forall t. blah $sf @t = $se RULE: f True = $sf -The specialized function only takes a single type argument -so we add a void argument to prevent it from turning into -a thunk. See Note [Protecting the last value argument] for details -why. Normally we would add the void argument after the -type argument giving us: +The specialized function only takes a single type argument so we add a +void argument to prevent it from turning into a thunk. See Note +[Protecting the last value argument] for details why. Normally we +would add the void argument after the type argument giving us: + $sf :: forall t. Void# -> bla $sf @t void = $se RULE: f True = $sf void# (wrong) -But if you look closely this wouldn't typecheck! -If we substitute `f True` with `$sf void#` we expect the type argument to be applied first -but we apply void# first. -The easiest fix seems to be just to add the void argument to the front of the arguments. -Now we get: + +But if you look closely this wouldn't typecheck! If we substitute `f +True` with `$sf void#` we expect the type argument to be applied first +but we apply void# first. The easiest fix seems to be just to add the +void argument to the front of the arguments. Now we get: + $sf :: Void# -> forall t. bla $sf void @t = $se RULE: f True = $sf void# + And now we can substitute `f True` with `$sf void#` with everything working out nicely! +More precisely, in `calcSpecInfo` +(i) we need the void arg to /precede/ the `extra_bndrs`, but +(ii) it must still /follow/ `qvar_bndrs`. + +Example to illustrate (ii): + f :: forall r (a :: TYPE r). Bool -> a + f = /\r. /\(a::TYPE r). \b. body + + {- Specialise for f _ _ True -} + + $sf :: forall r (a :: TYPE r). Void# -> a + $sf = /\r. /\(a::TYPE r). \v. body[True/b] + RULE: forall r (a :: TYPE r). f @r @a True = $sf @r @a void# + +The void argument must follow the foralls, lest the forall be +ill-kinded. See Note [Worker/wrapper needs to add void arg last] in +GHC.Core.Opt.WorkWrap.Utils. + Note [generaliseDictPats] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider these two rules (#21831, item 2): @@ -2075,36 +2083,45 @@ And /now/ "SPEC:foo" is clearly more specific: we can instantiate the new "SC:foo" to match the (prefix of) "SPEC:foo". -} -calcSpecInfo :: Id -- The original function - -> CallPat -- Call pattern - -> [Var] -- Extra bndrs - -> ( [Var] -- Demand-decorated binders - , DmdSig -- Strictness of specialised thing - , Arity, Maybe JoinArity ) -- Arities of specialised thing +calcSpecInfo :: Id -- The original function + -> [InVar] -- Lambda binders of original RHS + -> CallPat -- Call pattern + -> [Var] -- Extra bndrs + -> ( [Var] -- Demand-decorated lambda binders + -- for RHS of specialised function + , [Var] -- Args for call site + , DmdSig ) -- Strictness of specialised thing -- Calculate bits of IdInfo for the specialised function -- See Note [Transfer strictness] -- See Note [Strictness information in worker binders] -calcSpecInfo fn (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs - | isJoinId fn -- Join points have strictness and arity for LHS only - = ( bndrs_w_dmds - , mkClosedDmdSig qvar_dmds div - , count isId qvars - , Just (length qvars) ) - | otherwise - = ( bndrs_w_dmds - , mkClosedDmdSig (qvar_dmds ++ extra_dmds) div - , count isId qvars + count isId extra_bndrs - , Nothing ) +calcSpecInfo fn arg_bndrs (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs + = ( spec_lam_bndrs_w_dmds + , spec_call_args + , mkClosedDmdSig (map idDemandInfo spec_lam_bndrs_w_dmds) div ) where DmdSig (DmdType _ fn_dmds div) = idDmdSig fn - val_pats = filterOut isTypeArg pats -- value args at call sites, used to determine how many demands to drop - -- from the original functions demand and for setting up dmd_env. + val_pats = filterOut isTypeArg pats + -- Value args at call sites, used to determine how many demands to drop + -- from the original functions demand and for setting up dmd_env. + dmd_env = go emptyVarEnv fn_dmds val_pats qvar_dmds = [ lookupVarEnv dmd_env qv `orElse` topDmd | qv <- qvars, isId qv ] extra_dmds = dropList val_pats fn_dmds - bndrs_w_dmds = set_dmds qvars qvar_dmds - ++ set_dmds extra_bndrs extra_dmds + -- Annotate the variables with the strictness information from + -- the function (see Note [Strictness information in worker binders]) + qvars_w_dmds = set_dmds qvars qvar_dmds + extras_w_dmds = set_dmds extra_bndrs extra_dmds + spec_lam_bndrs_w_dmds = final_qvars_w_dmds ++ extras_w_dmds + + (final_qvars_w_dmds, spec_call_args) + | needsVoidWorkerArg fn arg_bndrs (qvars ++ extra_bndrs) + -- Usual w/w hack to avoid generating + -- a spec_rhs of unlifted or ill-kinded type and no args. + -- See Note [SpecConstr void argument insertion] + = ( qvars_w_dmds ++ [voidArgId], qvars ++ [voidPrimId] ) + | otherwise + = ( qvars_w_dmds, qvars ) set_dmds :: [Var] -> [Demand] -> [Var] set_dmds [] _ = [] @@ -2112,8 +2129,6 @@ calcSpecInfo fn (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs set_dmds (v:vs) ds@(d:ds') | isTyVar v = v : set_dmds vs ds | otherwise = setIdDemandInfo v d : set_dmds vs ds' - dmd_env = go emptyVarEnv fn_dmds val_pats - go :: DmdEnv -> [Demand] -> [CoreExpr] -> DmdEnv -- We've filtered out all the type patterns already go env (d:ds) (pat : pats) = go (go_one env d pat) ds pats @@ -2127,7 +2142,6 @@ calcSpecInfo fn (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs = go env ds args go_one env _ _ = env - {- Note [spec_usg includes rhs_usg] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -9,7 +9,7 @@ A library for the ``worker\/wrapper'' back-end to the strictness analyser module GHC.Core.Opt.WorkWrap.Utils ( WwOpts(..), mkWwBodies, mkWWstr, mkWWstr_one - , needsVoidWorkerArg, addVoidWorkerArg + , needsVoidWorkerArg , DataConPatContext(..) , UnboxingDecision(..), canUnboxArg , findTypeShape, IsRecDataConResult(..), isRecDataCon @@ -377,25 +377,34 @@ We use the state-token type which generates no code. -- Note [Preserving float barriers]. needsVoidWorkerArg :: Id -> [Var] -> [Var] -> Bool needsVoidWorkerArg fn_id wrap_args work_args - = not (isJoinId fn_id) && no_value_arg -- See Note [Protecting the last value argument] - || needs_float_barrier -- See Note [Preserving float barriers] + = thunk_problem -- See Note [Protecting the last value argument] + || needs_float_barrier -- See Note [Preserving float barriers] where - no_value_arg = all (not . isId) work_args + -- thunk_problem: see Note [Protecting the last value argument] + -- For join points we are only worried about (4), not (1-4). + -- And (4) can't happen if (null work_args) + -- (We could be more clever, by looking at the result type, but + -- this approach is simple and conservative.) + thunk_problem | isJoinId fn_id = no_value_arg && not (null work_args) + | otherwise = no_value_arg + no_value_arg = not (any isId work_args) + + -- needs_float_barrier: see Note [Preserving float barriers] + needs_float_barrier = wrap_had_barrier && not work_has_barrier is_float_barrier v = isId v && hasNoOneShotInfo (idOneShotInfo v) wrap_had_barrier = any is_float_barrier wrap_args work_has_barrier = any is_float_barrier work_args - needs_float_barrier = wrap_had_barrier && not work_has_barrier --- | Inserts a `Void#` arg before the first argument. --- --- Why as the first argument? See Note [SpecConstr needs to add void args first] --- in SpecConstr. +-- | Inserts a `Void#` arg as the last argument. +-- Why last? See Note [Worker/wrapper needs to add void arg last] addVoidWorkerArg :: [Var] -> [StrictnessMark] - -> ([Var], -- Lambda bound args - [Var], -- Args at call site - [StrictnessMark]) -- str semantics for the worker args. + -> ( [Var] -- Lambda bound args + , [Var] -- Args at call site + , [StrictnessMark]) -- str semantics for the worker args addVoidWorkerArg work_args str_marks - = (voidArgId : work_args, voidPrimId:work_args, NotMarkedStrict:str_marks) + = ( work_args ++ [voidArgId] + , work_args ++ [voidPrimId] + , str_marks ++ [NotMarkedStrict] ) {- Note [Protecting the last value argument] @@ -403,8 +412,8 @@ Note [Protecting the last value argument] If the user writes (\_ -> E), they might be intentionally disallowing the sharing of E. Since absence analysis and worker-wrapper are keen to remove such unused arguments, we add in a void argument to prevent -the function from becoming a thunk. Three reasons why turning a function -into a thunk might be bad: +the function from becoming a thunk. Here are several reasons why turning +a function into a thunk might be bad: 1) It can create a space leak. e.g. f x = let y () = [1..x] @@ -423,7 +432,19 @@ into a thunk might be bad: g = \x. 30# Removing the \x would leave an unlifted binding. -NB: none of these apply to a join point. +4) It can create a worker of ill-kinded type (#22275). Consider + f :: forall r (a :: TYPE r). () -> a + f x = f x + Here `x` is absent, but if we simply drop it we'd end up with + $wf :: forall r (a :: TYPE r). a + But alas $wf's type is ill-kinded: the kind of (/\r (a::TYPE r).a) + is (TYPE r), which mentions the bound variable `r`. See also + Note [Worker/wrapper needs to add void arg last] + +See also Note [Preserving float barriers] + +NB: Of these, only (1-3) don't apply to a join point, which can be +unlifted even if the RHS is not ok-for-speculation. Note [Preserving float barriers] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -457,7 +478,7 @@ which some are absent or one-shot and the resulting worker arguments: * \a{Abs}.\b{os}.\c{os}... ==> \b{os}.\c{os}.\(_::Void#)... Wrapper arg `a` was the only float barrier and had been dropped. Hence Void# - * \a{Abs,os}.\b{os}.\c... ==> \b{os}.\c... +p * \a{Abs,os}.\b{os}.\c... ==> \b{os}.\c... Worker arg `c` is a float barrier. * \a.\b{Abs}.\c{os}... ==> \a.\c{os}... Worker arg `a` is a float barrier. @@ -469,6 +490,28 @@ which some are absent or one-shot and the resulting worker arguments: Executable examples in T21150. +Note [Worker/wrapper needs to add void arg last] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider point (4) of Note [Protecting the last value argument] + + f :: forall r (a :: TYPE r). () -> a + f x = f x + +As pointed out in (4) we need to add a void argument. But if we add +it /first/ we'd get + + $wf :: Void# -> forall r (a :: TYPE r). a + $wf = ... + +But alas $wf's type is /still/ still-kinded, just as before in (4). +Solution is simple: put the void argument /last/: + + $wf :: forall r (a :: TYPE r). Void# -> a + $wf = ... + +Notice that this is exactly backwards from GHC.Core.Opt.SpecConstr +Note [SpecConstr needs to add void args first]. + Note [Join points and beta-redexes] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Originally, the worker would invoke the original function by calling it with ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1337,7 +1337,7 @@ ty_con_app_fun_maybe many_ty_co tc args | otherwise = Nothing -mkFunctionType :: Mult -> Type -> Type -> Type +mkFunctionType :: HasDebugCallStack => Mult -> Type -> Type -> Type -- ^ This one works out the FunTyFlag from the argument type -- See GHC.Types.Var Note [FunTyFlag] mkFunctionType mult arg_ty res_ty ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -158,7 +158,7 @@ coreAltsType :: [CoreAlt] -> Type coreAltsType (alt:_) = coreAltType alt coreAltsType [] = panic "coreAltsType" -mkLamType :: Var -> Type -> Type +mkLamType :: HasDebugCallStack => Var -> Type -> Type -- ^ Makes a @(->)@ type or an implicit forall type, depending -- on whether it is given a type variable or a term variable. -- This is used, for example, when producing the type of a lambda. ===================================== testsuite/tests/simplCore/should_compile/T13143.stderr ===================================== @@ -1,14 +1,14 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 71, types: 41, coercions: 0, joins: 0/0} + = {terms: 71, types: 40, coercions: 0, joins: 0/0} Rec { -- RHS size: {terms: 4, types: 3, coercions: 0, joins: 0/0} T13143.$wf [InlPrag=NOINLINE, Occ=LoopBreaker] - :: (# #) -> forall {a}. a + :: forall {a}. (# #) -> a [GblId, Arity=1, Str=b, Cpr=b, Unf=OtherCon []] -T13143.$wf = \ _ [Occ=Dead] (@a) -> T13143.$wf GHC.Prim.(##) @a +T13143.$wf = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##) end Rec } -- RHS size: {terms: 4, types: 3, coercions: 0, joins: 0/0} @@ -17,55 +17,60 @@ f [InlPrag=NOINLINE[final]] :: forall a. Int -> a Arity=1, Str=b, Cpr=b, - 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=True) - Tmpl= \ (@a) _ [Occ=Dead] -> T13143.$wf GHC.Prim.(##) @a}] -f = \ (@a) _ [Occ=Dead] -> T13143.$wf GHC.Prim.(##) @a + Tmpl= \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##)}] +f = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##) -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T13143.$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}] T13143.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T13143.$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}] T13143.$trModule3 = GHC.Types.TrNameS T13143.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T13143.$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}] T13143.$trModule2 = "T13143"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T13143.$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}] 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}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T13143.$trModule = GHC.Types.Module T13143.$trModule3 T13143.$trModule1 --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -lvl :: forall {a}. a +-- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} +lvl :: Int [GblId, Str=b, Cpr=b] -lvl = T13143.$wf GHC.Prim.(##) +lvl = T13143.$wf @Int GHC.Prim.(##) Rec { --- RHS size: {terms: 28, types: 8, coercions: 0, joins: 0/0} +-- RHS size: {terms: 28, types: 7, coercions: 0, joins: 0/0} T13143.$wg [InlPrag=[2], Occ=LoopBreaker] :: Bool -> Bool -> GHC.Prim.Int# -> GHC.Prim.Int# [GblId[StrictWorker([!, !])], @@ -94,8 +99,8 @@ g [InlPrag=[2]] :: Bool -> Bool -> Int -> Int Arity=3, Str=<1L><1L><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=3,unsat_ok=True,boring_ok=False) Tmpl= \ (ds [Occ=Once1] :: Bool) (ds1 [Occ=Once1] :: Bool) ===================================== testsuite/tests/simplCore/should_compile/T18328.stderr ===================================== @@ -1,84 +1,90 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 65, types: 53, coercions: 0, joins: 1/1} + = {terms: 69, types: 55, coercions: 0, joins: 1/1} --- RHS size: {terms: 38, types: 23, coercions: 0, joins: 1/1} +-- RHS size: {terms: 42, types: 25, coercions: 0, joins: 1/1} T18328.$wf [InlPrag=[2]] :: forall {a}. GHC.Prim.Int# -> [a] -> [a] -> [a] -[GblId, +[GblId[StrictWorker([~, !])], Arity=3, Str=, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [176 0 0] 306 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [176 0 0] 306 0}] T18328.$wf - = \ (@a) (ww :: GHC.Prim.Int#) (w :: [a]) (w1 :: [a]) -> + = \ (@a) (ww :: GHC.Prim.Int#) (ys :: [a]) (eta :: [a]) -> join { - $wj [InlPrag=NOINLINE, Dmd=ML] :: forall {p}. [a] - [LclId[JoinId(1)]] - $wj (@p) + $wj [InlPrag=NOINLINE, Dmd=MC(1,L)] :: forall {p}. (# #) -> [a] + [LclId[JoinId(2)(Nothing)], Arity=1, Str=, Unf=OtherCon []] + $wj (@p) _ [Occ=Dead, OS=OneShot] = case ww of { - __DEFAULT -> ++ @a w (++ @a w (++ @a w w1)); - 3# -> ++ @a w (++ @a w (++ @a w (++ @a w w1))) + __DEFAULT -> ++ @a ys (++ @a ys (++ @a ys eta)); + 3# -> ++ @a ys (++ @a ys (++ @a ys (++ @a ys eta))) } } in case ww of { - __DEFAULT -> ++ @a w w1; - 1# -> jump $wj @Integer; - 2# -> jump $wj @Integer; - 3# -> jump $wj @Integer + __DEFAULT -> ++ @a ys eta; + 1# -> jump $wj @Integer GHC.Prim.(##); + 2# -> jump $wj @Integer GHC.Prim.(##); + 3# -> jump $wj @Integer GHC.Prim.(##) } -- RHS size: {terms: 11, types: 9, coercions: 0, joins: 0/0} f [InlPrag=[2]] :: forall a. Int -> [a] -> [a] -> [a] [GblId, Arity=3, - Str=<1P(SL)>, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Str=<1!P(SL)>, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) Tmpl= \ (@a) - (w [Occ=Once1!] :: Int) - (w1 [Occ=Once1] :: [a]) - (w2 [Occ=Once1] :: [a]) -> - case w of { GHC.Types.I# ww [Occ=Once1] -> - T18328.$wf @a ww w1 w2 + (x [Occ=Once1!] :: Int) + (ys [Occ=Once1] :: [a]) + (eta [Occ=Once1] :: [a]) -> + case x of { GHC.Types.I# ww [Occ=Once1] -> + T18328.$wf @a ww ys eta }}] -f = \ (@a) (w :: Int) (w1 :: [a]) (w2 :: [a]) -> - case w of { GHC.Types.I# ww -> T18328.$wf @a ww w1 w2 } +f = \ (@a) (x :: Int) (ys :: [a]) (eta :: [a]) -> + case x of { GHC.Types.I# ww -> T18328.$wf @a ww ys eta } -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule3 = GHC.Types.TrNameS T18328.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule2 = "T18328"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule1 = GHC.Types.TrNameS T18328.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T18328.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T18328.$trModule = GHC.Types.Module T18328.$trModule3 T18328.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T22725.hs ===================================== @@ -0,0 +1,6 @@ +module M where + +import GHC.Exts (TYPE) + +f :: forall r (a :: TYPE r). () -> a +f x = f x ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -462,3 +462,4 @@ test('T22272', normal, multimod_compile, ['T22272', '-O -fexpose-all-unfoldings test('T22459', normal, compile, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) test('T22662', normal, compile, ['']) +test('T22725', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8e58c4c4f18f3af9160d4d10568b9516ea4b3236 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8e58c4c4f18f3af9160d4d10568b9516ea4b3236 You're receiving 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 Jan 10 12:14:16 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 10 Jan 2023 07:14:16 -0500 Subject: [Git][ghc/ghc][wip/T22428] Fix contification with stable unfoldings (#22428) Message-ID: <63bd569888f2f_3b1bf952634489299@gitlab.mail> Sebastian Graf pushed to branch wip/T22428 at Glasgow Haskell Compiler / GHC Commits: f3bcc3b5 by Sebastian Graf at 2023-01-10T13:14:01+01:00 Fix contification with stable unfoldings (#22428) Many functions now return a `TailUsageDetails` that adorns a `UsageDetails` with a `JoinArity` that reflects the number of join point binders around the body for which the `UsageDetails` was computed. `TailUsageDetails` is now returned by `occAnalLamTail` as well as `occAnalUnfolding` and `occAnalRules`. I adjusted `Note [Join points and unfoldings/rules]` and `Note [Adjusting right-hand sides]` to account for the new machinery. I also wrote a new `Note [Join arity prediction based on joinRhsArity]` and refer to it when we combine `TailUsageDetails` for a recursive RHS. I also renamed * `occAnalLam` to `occAnalLamTail` * `adjustRhsUsage` to `adjustTailUsage` * a few other less important functions and properly documented the that each call of `occAnalLamTail` must pair up with `adjustTailUsage`. I removed `Note [Unfoldings and join points]` because it was redundant with `Note [Occurrences in stable unfoldings]`. While in town, I refactored `mkLoopBreakerNodes` so that it returns a condensed `NodeDetails` called `SimpleNodeDetails`. Fixes #22428. Metric Decrease: T12150 T12425 T21839c T21839r T9961 - - - - - 7 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Data/Graph/Directed.hs - compiler/GHC/Utils/Misc.hs - + testsuite/tests/simplCore/should_compile/T22428.hs - + testsuite/tests/simplCore/should_compile/T22428.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -132,6 +132,9 @@ joinRhsArity :: CoreExpr -> JoinArity -- Join points are supposed to have manifestly-visible -- lambdas at the top: no ticks, no casts, nothing -- Moreover, type lambdas count in JoinArity +-- NB: For non-recursive bindings, the join arity of the binding may actually be +-- less that the number of manifestly-visible lambdas. +-- See Note [Join arity prediction based on joinRhsArity] in GHC.Core.Opt.OccurAnal joinRhsArity (Lam _ e) = 1 + joinRhsArity e joinRhsArity _ = 0 ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -59,7 +59,7 @@ import GHC.Builtin.Names( runRWKey ) import GHC.Unit.Module( Module ) import Data.List (mapAccumL, mapAccumR) -import Data.List.NonEmpty (NonEmpty (..), nonEmpty) +import Data.List.NonEmpty (NonEmpty (..)) import qualified Data.List.NonEmpty as NE {- @@ -510,6 +510,16 @@ of the file. at any of the definitions. This is done by Simplify.simplRecBind, when it calls addLetIdInfo. +Note [TailUsageDetails when forming Rec groups] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `TailUsageDetails` stored in the `nd_uds` field of a `NodeDetails` is +computed by `occAnalLamTail` applied to the RHS, not `occAnalExpr`. +That is because the binding might still become a *non-recursive join point* in +the AcyclicSCC case of dependency analysis! +Hence we do the delayed `adjustTailUsage` in `occAnalRec`/`tagRecBinders` to get +a regular, adjusted UsageDetails. +See Note [Join points and unfoldings/rules] for more details on the contract. + Note [Stable unfoldings] ~~~~~~~~~~~~~~~~~~~~~~~~ None of the above stuff about RULES applies to a stable unfolding @@ -608,6 +618,65 @@ tail call with `n` arguments (counting both value and type arguments). Otherwise 'occ_tail' will be 'NoTailCallInfo'. The tail call info flows bottom-up with the rest of 'OccInfo' until it goes on the binder. +Note [Join arity prediction based on joinRhsArity] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In general, the join arity from tail occurrences of a join point (O) may be +higher or lower than the manifest join arity of the join body (M). E.g., + + -- M > O: + let f x y = x + y -- M = 2 + in if b then f 1 else f 2 -- O = 1 + ==> { Contify for join arity 1 } + join f x = \y -> x + y + in if b then jump f 1 else jump f 2 + + -- M < O + let f = id -- M = 0 + in if ... then f 12 else f 13 -- O = 1 + ==> { Contify for join arity 1, eta-expand f } + join f x = id x + in if b then jump f 12 else jump f 13 + +But for *recursive* let, it is crucial that both arities match up, consider + + letrec f x y = if ... then f x else True + in f 42 + +Here, M=2 but O=1. If we settled for a joinrec arity of 1, the recursive jump +would not happen in a tail context! Contification is invalid here. +So indeed it is crucial to demand that M=O. + +(Side note: Actually, we could be more specific: Let O1 be the join arity of +occurrences from the letrec RHS and O2 the join arity from the let body. Then +we need M=O1 and M<=O2 and could simply eta-expand the RHS to match O2 later. +M=O is the specific case where we don't want to eta-expand. Neither the join +points paper nor GHC does this at the moment.) + +We can capitalise on this observation and conclude that *if* f could become a +joinrec (without eta-expansion), it will have join arity M. +Now, M is just the result of 'joinRhsArity', a rather simple, local analysis. +It is also the join arity inside the 'TailUsageDetails' returned by +'occAnalLamTail', so we can predict join arity without doing any fixed-point +iteration or really doing any deep traversal of let body or RHS at all. +We check for M in the 'adjustTailUsage' call inside 'tagRecBinders'. + +All this is quite apparent if you look at the contification transformation in +Fig. 5 of "Compiling without Continuations" (which does not account for +eta-expansion at all, mind you). The letrec case looks like this + + letrec f = /\as.\xs. L[us] in L'[es] + ... and a bunch of conditions establishing that f only occurs + in app heads of join arity (len as + len xs) inside us and es ... + +The syntactic form `/\as.\xs. L[us]` forces M=O iff `f` occurs in `us`. However, +for non-recursive functions, this is the definition of contification from the +paper: + + let f = /\as.\xs.u in L[es] ... conditions ... + +Note that u could be a lambda itself, as we have seen. No relationship between M +and O to exploit here. + Note [Join points and unfoldings/rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider @@ -618,8 +687,10 @@ Consider Before j is inlined, we'll have occurrences of j2 in both j's RHS and in its stable unfolding. We want to discover -j2 as a join point. So we must do the adjustRhsUsage thing -on j's RHS. That's why we pass mb_join_arity to calcUnfolding. +j2 as a join point. So 'occAnalUnfolding' returns an unadjusted +'TailUsageDetails', like 'occAnalLamTail'. We adjust the usage details of the +unfolding to the actual join arity using the same 'adjustTailArity' as for +the RHS, see Note [Adjusting right-hand sides]. Same with rules. Suppose we have: @@ -636,14 +707,31 @@ up. So provided the join-point arity of k matches the args of the rule we can allow the tail-call info from the RHS of the rule to propagate. -* Wrinkle for Rec case. In the recursive case we don't know the - join-point arity in advance, when calling occAnalUnfolding and - occAnalRules. (See makeNode.) We don't want to pass Nothing, - because then a recursive joinrec might lose its join-poin-hood - when SpecConstr adds a RULE. So we just make do with the - *current* join-poin-hood, stored in the Id. +* Note that the join arity of the RHS and that of the unfolding or RULE might + mismatch: + + let j x y = j2 (x+x) + {-# INLINE[2] j = \x. g #-} + {-# RULE forall x y z. j x y z = h 17 #-} + in j 1 2 - In the non-recursive case things are simple: see occAnalNonRecBind + So it is crucial that we adjust each TailUsageDetails individually + with the actual join arity 2 here before we combine with `andUDs`. + Here, that means losing tail call info on `g` and `h`. + +* Wrinkle for Rec case: We store one TailUsageDetails in the node Details for + RHS, unfolding and RULE combined. Clearly, if they don't agree on their join + arity, we have to do some adjusting. We choose to adjust to the join arity + of the RHS, because that is likely the join arity that the join point will + have; see Note [Join arity prediction based on joinRhsArity]. + + If the guess is correct, then tail calls in the RHS are preserved; a necessary + condition for the whole binding becoming a joinrec. + The guess can only be incorrect in the 'AcyclicSCC' case when the binding + becomes a non-recursive join point with a different join arity. But then the + eventual call to 'adjustTailUsage' in 'tagRecBinders'/'occAnalRec' will + be with a different join arity and destroy unsound tail call info with + 'markNonTail'. * Wrinkle for RULES. Suppose the example was a bit different: let j :: Int -> Int @@ -669,28 +757,21 @@ propagate. This appears to be very rare in practice. TODO Perhaps we should gather statistics to be sure. -Note [Unfoldings and join points] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We assume that anything in an unfolding occurs multiple times, since -unfoldings are often copied (that's the whole point!). But we still -need to track tail calls for the purpose of finding join points. - - ------------------------------------------------------------ Note [Adjusting right-hand sides] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There's a bit of a dance we need to do after analysing a lambda expression or a right-hand side. In particular, we need to - a) call 'markAllInsideLam' *unless* the binding is for a thunk, a one-shot - lambda, or a non-recursive join point; and - b) call 'markAllNonTail' *unless* the binding is for a join point, and - the RHS has the right arity; e.g. + a) call 'markAllNonTail' *unless* the binding is for a join point, and + the TailUsageDetails from the RHS has the right join arity; e.g. join j x y = case ... of A -> j2 p B -> j2 q in j a b Here we want the tail calls to j2 to be tail calls of the whole expression + b) call 'markAllInsideLam' *unless* the binding is for a thunk, a one-shot + lambda, or a non-recursive join point Some examples, with how the free occurrences in e (assumed not to be a value lambda) get marked: @@ -707,26 +788,39 @@ lambda) get marked: There are a few other caveats; most importantly, if we're marking a binding as 'AlwaysTailCalled', it's *going* to be a join point, so we treat it as one so that the effect cascades properly. Consequently, at the time the RHS is -analysed, we won't know what adjustments to make; thus 'occAnalLamOrRhs' must -return the unadjusted 'UsageDetails', to be adjusted by 'adjustRhsUsage' once -join-point-hood has been decided. - -Thus the overall sequence taking place in 'occAnalNonRecBind' and -'occAnalRecBind' is as follows: - - 1. Call 'occAnalLamOrRhs' to find usage information for the RHS. - 2. Call 'tagNonRecBinder' or 'tagRecBinders', which decides whether to make +analysed, we won't know what adjustments to make; thus 'occAnalLamTail' must +return the unadjusted 'TailUsageDetails', to be adjusted by 'adjustTailUsage' +once join-point-hood has been decided and eventual one-shot annotations have +been added through 'markNonRecJoinOneShots'. + +It is not so simple to see that 'occAnalNonRecBind' and 'occAnalRecBind' indeed +perform a similar sequence of steps. Thus, here is an interleaving of events +of both functions, serving as a specification: + + 1. Call 'occAnalLamTail' to find usage information for the RHS. + Recursive case: 'makeNode' + Non-recursive case: 'occAnalNonRecBind' + 2. (Analyse the binding's scope. Done in 'occAnalBind'/`occAnal Let{}`. + Same whether recursive or not.) + 3. Call 'tagNonRecBinder' or 'tagRecBinders', which decides whether to make the binding a join point. - 3. Call 'adjustRhsUsage' accordingly. (Done as part of 'tagRecBinders' when - recursive.) - -(In the recursive case, this logic is spread between 'makeNode' and -'occAnalRec'.) + Cyclic Recursive case: 'mkLoopBreakerNodes' + Acyclic Recursive case: `occAnalRec AcyclicSCC{}` + Non-recursive case: 'occAnalNonRecBind' + 4. Non-recursive join point: Call 'markNonRecJoinOneShots' so that e.g., + FloatOut sees one-shot annotations on lambdas + Acyclic Recursive case: `occAnalRec AcyclicSCC{}` calls 'adjustNonRecRhs' + Non-recursive case: 'occAnalNonRecBind' calls 'adjustNonRecRhs' + 5. Call 'adjustTailUsage' accordingly. + Cyclic Recursive case: 'tagRecBinders' + Acyclic Recursive case: 'adjustNonRecRhs' + Non-recursive case: 'adjustNonRecRhs' -} - data WithUsageDetails a = WithUsageDetails !UsageDetails !a +data WithTailUsageDetails a = WithTailUsageDetails !TailUsageDetails !a + ------------------------------------------------------------------ -- occAnalBind ------------------------------------------------------------------ @@ -750,19 +844,17 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage | isTyVar bndr -- A type let; we don't gather usage info = WithUsageDetails body_usage [NonRec bndr rhs] - | not (bndr `usedIn` body_usage) -- It's not mentioned - = WithUsageDetails body_usage [] + | not (bndr `usedIn` body_usage) + = WithUsageDetails body_usage [] -- See Note [Dead code] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr rhs'] + = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr final_rhs] where - (body_usage', tagged_bndr) = tagNonRecBinder lvl body_usage bndr - final_bndr = tagged_bndr `setIdUnfolding` unf' - `setIdSpecialisation` mkRuleInfo rules' - rhs_usage = rhs_uds `andUDs` unf_uds `andUDs` rule_uds + WithUsageDetails body_usage' tagged_bndr = tagNonRecBinder lvl body_usage bndr -- Get the join info from the *new* decision -- See Note [Join points and unfoldings/rules] + -- => join arity O of Note [Join arity prediction based on joinRhsArity] mb_join_arity = willBeJoinId_maybe tagged_bndr is_join_point = isJust mb_join_arity @@ -773,17 +865,28 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- See Note [Sources of one-shot information] rhs_env = env1 { occ_one_shots = argOneShots dmd } - (WithUsageDetails rhs_uds rhs') = occAnalRhs rhs_env NonRecursive mb_join_arity rhs + -- See Note [Join arity prediction based on joinRhsArity] + -- Match join arity O from mb_join_arity with manifest join arity M as + -- returned by of occAnalLamTail. It's totally OK for them to mismatch; + -- hence adjust the UDs from the RHS + WithUsageDetails adj_rhs_uds final_rhs + = adjustNonRecRhs mb_join_arity $ occAnalLamTail rhs_env rhs + rhs_usage = adj_rhs_uds `andUDs` adj_unf_uds `andUDs` adj_rule_uds + final_bndr = tagged_bndr `setIdSpecialisation` mkRuleInfo rules' + `setIdUnfolding` unf2 --------- Unfolding --------- - -- See Note [Unfoldings and join points] + -- See Note [Join points and unfoldings/rules] unf | isId bndr = idUnfolding bndr | otherwise = NoUnfolding - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env NonRecursive mb_join_arity unf + WithTailUsageDetails unf_uds unf1 = occAnalUnfolding rhs_env unf + !unf2 = markNonRecUnfoldingOneShots mb_join_arity unf1 + adj_unf_uds = adjustTailArity mb_join_arity unf_uds --------- Rules --------- -- See Note [Rules are extra RHSs] and Note [Rule dependency info] - rules_w_uds = occAnalRules rhs_env mb_join_arity bndr + -- and Note [Join points and unfoldings/rules] + rules_w_uds = occAnalRules rhs_env bndr rules' = map fstOf3 rules_w_uds imp_rule_uds = impRulesScopeUsage (lookupImpRules imp_rule_edges bndr) -- imp_rule_uds: consider @@ -794,8 +897,9 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- that g is (since the RULE might turn g into h), so -- we make g mention h. - rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds - add_rule_uds (_, l, r) uds = l `andUDs` r `andUDs` uds + adj_rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds + add_rule_uds (_, l, r) uds + = l `andUDs` adjustTailArity mb_join_arity r `andUDs` uds ---------- occ = idOccInfo tagged_bndr @@ -820,7 +924,7 @@ occAnalRecBind :: OccEnv -> TopLevelFlag -> ImpRuleEdges -> [(Var,CoreExpr)] occAnalRecBind !env lvl imp_rule_edges pairs body_usage = foldr (occAnalRec rhs_env lvl) (WithUsageDetails body_usage []) sccs where - sccs :: [SCC Details] + sccs :: [SCC NodeDetails] sccs = {-# SCC "occAnalBind.scc" #-} stronglyConnCompFromEdgedVerticesUniq nodes @@ -832,27 +936,44 @@ occAnalRecBind !env lvl imp_rule_edges pairs body_usage bndr_set = mkVarSet bndrs rhs_env = env `addInScope` bndrs +adjustNonRecRhs :: Maybe JoinArity -> WithTailUsageDetails CoreExpr -> WithUsageDetails CoreExpr +-- ^ This function concentrates shared logic between occAnalNonRecBind and the +-- AcyclicSCC case of occAnalRec. +-- * It applies 'markNonRecJoinOneShots' to the RHS +-- * and returns the adjusted rhs UsageDetails combined with the body usage +adjustNonRecRhs mb_join_arity (WithTailUsageDetails rhs_tuds rhs) + = WithUsageDetails rhs_uds' rhs' + where + --------- Marking (non-rec) join binders one-shot --------- + !rhs' | Just ja <- mb_join_arity = markNonRecJoinOneShots ja rhs + | otherwise = rhs + --------- Adjusting right-hand side usage --------- + rhs_uds' = adjustTailUsage mb_join_arity rhs' rhs_tuds ----------------------------- occAnalRec :: OccEnv -> TopLevelFlag - -> SCC Details + -> SCC NodeDetails -> WithUsageDetails [CoreBind] -> WithUsageDetails [CoreBind] -- The NonRec case is just like a Let (NonRec ...) above -occAnalRec !_ lvl (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = rhs - , nd_uds = rhs_uds })) +occAnalRec !_ lvl + (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = wtuds })) (WithUsageDetails body_uds binds) + | isTyVar bndr -- A type let; we don't gather usage info + = WithUsageDetails body_uds (NonRec bndr rhs' : binds) + | not (bndr `usedIn` body_uds) = WithUsageDetails body_uds binds -- See Note [Dead code] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_uds' `andUDs` rhs_uds') - (NonRec tagged_bndr rhs : binds) + = WithUsageDetails (body_uds' `andUDs` rhs_uds') (NonRec bndr' rhs' : binds) where - (body_uds', tagged_bndr) = tagNonRecBinder lvl body_uds bndr - rhs_uds' = adjustRhsUsage mb_join_arity rhs rhs_uds + WithUsageDetails body_uds' tagged_bndr = tagNonRecBinder lvl body_uds bndr mb_join_arity = willBeJoinId_maybe tagged_bndr + WithUsageDetails rhs_uds' rhs' = adjustNonRecRhs mb_join_arity wtuds + !unf' = markNonRecUnfoldingOneShots mb_join_arity (idUnfolding tagged_bndr) + !bndr' = tagged_bndr `setIdUnfolding` unf' -- The Rec case is the interesting one -- See Note [Recursive bindings: the grand plan] @@ -873,7 +994,7 @@ occAnalRec env lvl (CyclicSCC details_s) (WithUsageDetails body_uds binds) -- Make the nodes for the loop-breaker analysis -- See Note [Choosing loop breakers] for loop_breaker_nodes final_uds :: UsageDetails - loop_breaker_nodes :: [LetrecNode] + loop_breaker_nodes :: [LoopBreakerNode] (WithUsageDetails final_uds loop_breaker_nodes) = mkLoopBreakerNodes env lvl body_uds details_s ------------------------------ @@ -1102,7 +1223,7 @@ type Binding = (Id,CoreExpr) loopBreakNodes :: Int -> VarSet -- Binders whose dependencies may be "missing" -- See Note [Weak loop breakers] - -> [LetrecNode] + -> [LoopBreakerNode] -> [Binding] -- Append these to the end -> [Binding] @@ -1121,7 +1242,7 @@ loopBreakNodes depth weak_fvs nodes binds CyclicSCC nodes -> reOrderNodes depth weak_fvs nodes binds ---------------------------------- -reOrderNodes :: Int -> VarSet -> [LetrecNode] -> [Binding] -> [Binding] +reOrderNodes :: Int -> VarSet -> [LoopBreakerNode] -> [Binding] -> [Binding] -- Choose a loop breaker, mark it no-inline, -- and call loopBreakNodes on the rest reOrderNodes _ _ [] _ = panic "reOrderNodes" @@ -1133,7 +1254,7 @@ reOrderNodes depth weak_fvs (node : nodes) binds (map (nodeBinding mk_loop_breaker) chosen_nodes ++ binds) where (chosen_nodes, unchosen) = chooseLoopBreaker approximate_lb - (nd_score (node_payload node)) + (snd_score (node_payload node)) [node] [] nodes approximate_lb = depth >= 2 @@ -1142,8 +1263,8 @@ reOrderNodes depth weak_fvs (node : nodes) binds -- After two iterations (d=0, d=1) give up -- and approximate, returning to d=0 -nodeBinding :: (Id -> Id) -> LetrecNode -> Binding -nodeBinding set_id_occ (node_payload -> ND { nd_bndr = bndr, nd_rhs = rhs}) +nodeBinding :: (Id -> Id) -> LoopBreakerNode -> Binding +nodeBinding set_id_occ (node_payload -> SND { snd_bndr = bndr, snd_rhs = rhs}) = (set_id_occ bndr, rhs) mk_loop_breaker :: Id -> Id @@ -1163,13 +1284,13 @@ mk_non_loop_breaker weak_fvs bndr tail_info = tailCallInfo (idOccInfo bndr) ---------------------------------- -chooseLoopBreaker :: Bool -- True <=> Too many iterations, - -- so approximate - -> NodeScore -- Best score so far - -> [LetrecNode] -- Nodes with this score - -> [LetrecNode] -- Nodes with higher scores - -> [LetrecNode] -- Unprocessed nodes - -> ([LetrecNode], [LetrecNode]) +chooseLoopBreaker :: Bool -- True <=> Too many iterations, + -- so approximate + -> NodeScore -- Best score so far + -> [LoopBreakerNode] -- Nodes with this score + -> [LoopBreakerNode] -- Nodes with higher scores + -> [LoopBreakerNode] -- Unprocessed nodes + -> ([LoopBreakerNode], [LoopBreakerNode]) -- This loop looks for the bind with the lowest score -- to pick as the loop breaker. The rest accumulate in chooseLoopBreaker _ _ loop_nodes acc [] @@ -1189,7 +1310,7 @@ chooseLoopBreaker approx_lb loop_sc loop_nodes acc (node : nodes) | otherwise -- Worse score so don't pick it = chooseLoopBreaker approx_lb loop_sc loop_nodes (node : acc) nodes where - sc = nd_score (node_payload node) + sc = snd_score (node_payload node) {- Note [Complexity of loop breaking] @@ -1322,16 +1443,21 @@ ToDo: try using the occurrence info for the inline'd binder. ************************************************************************ -} -type LetrecNode = Node Unique Details -- Node comes from Digraph - -- The Unique key is gotten from the Id -data Details - = ND { nd_bndr :: Id -- Binder +-- | Digraph node as constructed by 'makeNode' and consumed by 'occAnalRec'. +-- The Unique key is gotten from the Id. +type LetrecNode = Node Unique NodeDetails - , nd_rhs :: CoreExpr -- RHS, already occ-analysed +-- | Node details as consumed by 'occAnalRec'. +data NodeDetails + = ND { nd_bndr :: Id -- Binder - , nd_uds :: UsageDetails -- Usage from RHS, and RULES, and stable unfoldings - -- ignoring phase (ie assuming all are active) - -- See Note [Forming Rec groups] + , nd_rhs :: !(WithTailUsageDetails CoreExpr) + -- ^ RHS, already occ-analysed + -- With TailUsageDetails from RHS, and RULES, and stable unfoldings, + -- ignoring phase (ie assuming all are active). + -- NB: Unadjusted TailUsageDetails, as if this Node becomes a + -- non-recursive join point! + -- See Note [TailUsageDetails when forming Rec groups] , nd_inl :: IdSet -- Free variables of the stable unfolding and the RHS -- but excluding any RULES @@ -1348,18 +1474,33 @@ data Details , nd_active_rule_fvs :: IdSet -- Variables bound in this Rec group that are free -- in the RHS of an active rule for this bndr -- See Note [Rules and loop breakers] - - , nd_score :: NodeScore } -instance Outputable Details where +instance Outputable NodeDetails where ppr nd = text "ND" <> braces (sep [ text "bndr =" <+> ppr (nd_bndr nd) - , text "uds =" <+> ppr (nd_uds nd) + , text "uds =" <+> ppr uds , text "inl =" <+> ppr (nd_inl nd) , text "simple =" <+> ppr (nd_simple nd) , text "active_rule_fvs =" <+> ppr (nd_active_rule_fvs nd) - , text "score =" <+> ppr (nd_score nd) + ]) + where WithTailUsageDetails uds _ = nd_rhs nd + +-- | Digraph with simplified and completely occurrence analysed +-- 'SimpleNodeDetails', retaining just the info we need for breaking loops. +type LoopBreakerNode = Node Unique SimpleNodeDetails + +-- | Condensed variant of 'NodeDetails' needed during loop breaking. +data SimpleNodeDetails + = SND { snd_bndr :: IdWithOccInfo -- OccInfo accurate + , snd_rhs :: CoreExpr -- properly occur-analysed + , snd_score :: NodeScore + } + +instance Outputable SimpleNodeDetails where + ppr nd = text "SND" <> braces + (sep [ text "bndr =" <+> ppr (snd_bndr nd) + , text "score =" <+> ppr (snd_score nd) ]) -- The NodeScore is compared lexicographically; @@ -1387,52 +1528,60 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) -- explained in Note [Deterministic SCC] in GHC.Data.Graph.Directed. where details = ND { nd_bndr = bndr' - , nd_rhs = rhs' - , nd_uds = scope_uds + , nd_rhs = WithTailUsageDetails scope_uds rhs' , nd_inl = inl_fvs , nd_simple = null rules_w_uds && null imp_rule_info , nd_weak_fvs = weak_fvs - , nd_active_rule_fvs = active_rule_fvs - , nd_score = pprPanic "makeNodeDetails" (ppr bndr) } + , nd_active_rule_fvs = active_rule_fvs } - bndr' = bndr `setIdUnfolding` unf' - `setIdSpecialisation` mkRuleInfo rules' + bndr' | isTyVar bndr = bndr + | otherwise = bndr `setIdUnfolding` unf' + `setIdSpecialisation` mkRuleInfo rules' - inl_uds = rhs_uds `andUDs` unf_uds - scope_uds = inl_uds `andUDs` rule_uds + -- NB: Both adj_unf_uds and adj_rule_uds have been adjusted to match the + -- JoinArity rhs_ja of unadj_rhs_uds. + unadj_inl_uds = unadj_rhs_uds `andUDs` adj_unf_uds + unadj_scope_uds = unadj_inl_uds `andUDs` adj_rule_uds + scope_uds = TUD rhs_ja unadj_scope_uds -- Note [Rules are extra RHSs] -- Note [Rule dependency info] - scope_fvs = udFreeVars bndr_set scope_uds + scope_fvs = udFreeVars bndr_set unadj_scope_uds -- scope_fvs: all occurrences from this binder: RHS, unfolding, -- and RULES, both LHS and RHS thereof, active or inactive - inl_fvs = udFreeVars bndr_set inl_uds + inl_fvs = udFreeVars bndr_set unadj_inl_uds -- inl_fvs: vars that would become free if the function was inlined. -- We conservatively approximate that by thefree vars from the RHS -- and the unfolding together. -- See Note [inl_fvs] - mb_join_arity = isJoinId_maybe bndr - -- Get join point info from the *current* decision - -- We don't know what the new decision will be! - -- Using the old decision at least allows us to - -- preserve existing join point, even RULEs are added - -- See Note [Join points and unfoldings/rules] --------- Right hand side --------- -- Constructing the edges for the main Rec computation -- See Note [Forming Rec groups] - -- Do not use occAnalRhs because we don't yet know the final - -- answer for mb_join_arity; instead, do the occAnalLam call from - -- occAnalRhs, and postpone adjustRhsUsage until occAnalRec - rhs_env = rhsCtxt env - (WithUsageDetails rhs_uds rhs') = occAnalLam rhs_env rhs + -- and Note [TailUsageDetails when forming Rec groups] + -- Compared to occAnalNonRecBind, we can't yet adjust the RHS because + -- (a) we don't yet know the final joinpointhood. It might not become a + -- join point after all! + -- (b) we don't even know whether it stays a recursive RHS after the SCC + -- analysis we are about to seed! So we can't markAllInsideLam in + -- advance, because if it ends up as a non-recursive join point we'll + -- consider it as one-shot and don't need to markAllInsideLam. + -- Instead, do the occAnalLamTail call here and postpone adjustTailUsage + -- until occAnalRec. In effect, we pretend that the RHS becomes a + -- non-recursive join point and fix up later with adjustTailUsage. + rhs_env = rhsCtxt env + WithTailUsageDetails (TUD rhs_ja unadj_rhs_uds) rhs' = occAnalLamTail rhs_env rhs + -- corresponding call to adjustTailUsage in occAnalRec and tagRecBinders --------- Unfolding --------- - -- See Note [Unfoldings and join points] + -- See Note [Join points and unfoldings/rules] unf = realIdUnfolding bndr -- realIdUnfolding: Ignore loop-breaker-ness -- here because that is what we are setting! - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env Recursive mb_join_arity unf + WithTailUsageDetails unf_tuds unf' = occAnalUnfolding rhs_env unf + adj_unf_uds = adjustTailArity (Just rhs_ja) unf_tuds + -- `rhs_ja` is `joinRhsArity rhs` and is the prediction for source M + -- of Note [Join arity prediction based on joinRhsArity] --------- IMP-RULES -------- is_active = occ_rule_act env :: Activation -> Bool @@ -1441,11 +1590,15 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) imp_rule_fvs = impRulesActiveFvs is_active bndr_set imp_rule_info --------- All rules -------- + -- See Note [Join points and unfoldings/rules] + -- `rhs_ja` is `joinRhsArity rhs'` and is the prediction for source M + -- of Note [Join arity prediction based on joinRhsArity] rules_w_uds :: [(CoreRule, UsageDetails, UsageDetails)] - rules_w_uds = occAnalRules rhs_env mb_join_arity bndr + rules_w_uds = [ (r,l,adjustTailArity (Just rhs_ja) rhs_tuds) + | (r,l,rhs_tuds) <- occAnalRules rhs_env bndr ] rules' = map fstOf3 rules_w_uds - rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds + adj_rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds add_rule_uds (_, l, r) uds = l `andUDs` r `andUDs` uds -------- active_rule_fvs ------------ @@ -1463,8 +1616,8 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) mkLoopBreakerNodes :: OccEnv -> TopLevelFlag -> UsageDetails -- for BODY of let - -> [Details] - -> WithUsageDetails [LetrecNode] -- adjusted + -> [NodeDetails] + -> WithUsageDetails [LoopBreakerNode] -- with OccInfo up-to-date -- See Note [Choosing loop breakers] -- This function primarily creates the Nodes for the -- loop-breaker SCC analysis. More specifically: @@ -1477,10 +1630,10 @@ mkLoopBreakerNodes :: OccEnv -> TopLevelFlag mkLoopBreakerNodes !env lvl body_uds details_s = WithUsageDetails final_uds (zipWithEqual "mkLoopBreakerNodes" mk_lb_node details_s bndrs') where - (final_uds, bndrs') = tagRecBinders lvl body_uds details_s + WithUsageDetails final_uds bndrs' = tagRecBinders lvl body_uds details_s mk_lb_node nd@(ND { nd_bndr = old_bndr, nd_inl = inl_fvs }) new_bndr - = DigraphNode { node_payload = new_nd + = DigraphNode { node_payload = simple_nd , node_key = varUnique old_bndr , node_dependencies = nonDetKeysUniqSet lb_deps } -- It's OK to use nonDetKeysUniqSet here as @@ -1488,7 +1641,8 @@ mkLoopBreakerNodes !env lvl body_uds details_s -- in nondeterministic order as explained in -- Note [Deterministic SCC] in GHC.Data.Graph.Directed. where - new_nd = nd { nd_bndr = new_bndr, nd_score = score } + WithTailUsageDetails _ rhs = nd_rhs nd + simple_nd = SND { snd_bndr = new_bndr, snd_rhs = rhs, snd_score = score } score = nodeScore env new_bndr lb_deps nd lb_deps = extendFvs_ rule_fv_env inl_fvs -- See Note [Loop breaker dependencies] @@ -1524,10 +1678,10 @@ group { f1 = e1; ...; fn = en } are: nodeScore :: OccEnv -> Id -- Binder with new occ-info -> VarSet -- Loop-breaker dependencies - -> Details + -> NodeDetails -> NodeScore nodeScore !env new_bndr lb_deps - (ND { nd_bndr = old_bndr, nd_rhs = bind_rhs }) + (ND { nd_bndr = old_bndr, nd_rhs = WithTailUsageDetails _ bind_rhs }) | not (isId old_bndr) -- A type or coercion variable is never a loop breaker = (100, 0, False) @@ -1748,7 +1902,7 @@ lambda and casts, e.g. * Occurrence analyser: we just mark each binder in the lambda-group (here: x,y,z) with its occurrence info in the *body* of the - lambda-group. See occAnalLam. + lambda-group. See occAnalLamTail. * Simplifier. The simplifier is careful when partially applying lambda-groups. See the call to zapLambdaBndrs in @@ -1804,25 +1958,31 @@ zapLambdaBndrs fun arg_count zap_bndr b | isTyVar b = b | otherwise = zapLamIdInfo b -occAnalLam :: OccEnv -> CoreExpr -> (WithUsageDetails CoreExpr) --- See Note [Occurrence analysis for lambda binders] +occAnalLamTail :: OccEnv -> CoreExpr -> WithTailUsageDetails CoreExpr +-- ^ See Note [Occurrence analysis for lambda binders]. -- It does the following: -- * Sets one-shot info on the lambda binder from the OccEnv, and -- removes that one-shot info from the OccEnv -- * Sets the OccEnv to OccVanilla when going under a value lambda -- * Tags each lambda with its occurrence information -- * Walks through casts +-- * Package up the analysed lambda with its manifest join arity +-- -- This function does /not/ do -- markAllInsideLam or -- markAllNonTail --- The caller does that, either in occAnal (Lam {}), or in adjustRhsUsage +-- The caller does that, via adjustTailUsage (mostly calls go through +-- adjustNonRecRhs). Every call to occAnalLamTail must ultimately call +-- adjustTailUsage to discharge the assumed join arity. +-- +-- In effect, the analysis result is for a non-recursive join point with +-- manifest arity and adjustTailUsage does the fixup. -- See Note [Adjusting right-hand sides] - -occAnalLam env (Lam bndr expr) +occAnalLamTail env (Lam bndr expr) | isTyVar bndr - = let env1 = addOneInScope env bndr - WithUsageDetails usage expr' = occAnalLam env1 expr - in WithUsageDetails usage (Lam bndr expr') + , let env1 = addOneInScope env bndr + , WithTailUsageDetails (TUD ja usage) expr' <- occAnalLamTail env1 expr + = WithTailUsageDetails (TUD (ja+1) usage) (Lam bndr expr') -- Important: Keep the 'env' unchanged so that with a RHS like -- \(@ x) -> K @x (f @x) -- we'll see that (K @x (f @x)) is in a OccRhs, and hence refrain @@ -1840,14 +2000,14 @@ occAnalLam env (Lam bndr expr) env1 = env { occ_encl = OccVanilla, occ_one_shots = env_one_shots' } env2 = addOneInScope env1 bndr - (WithUsageDetails usage expr') = occAnalLam env2 expr + WithTailUsageDetails (TUD ja usage) expr' = occAnalLamTail env2 expr (usage', bndr2) = tagLamBinder usage bndr1 - in WithUsageDetails usage' (Lam bndr2 expr') + in WithTailUsageDetails (TUD (ja+1) usage') (Lam bndr2 expr') -- For casts, keep going in the same lambda-group -- See Note [Occurrence analysis for lambda binders] -occAnalLam env (Cast expr co) - = let (WithUsageDetails usage expr') = occAnalLam env expr +occAnalLamTail env (Cast expr co) + = let WithTailUsageDetails (TUD ja usage) expr' = occAnalLamTail env expr -- usage1: see Note [Gather occurrences of coercion variables] usage1 = addManyOccs usage (coVarsOfCo co) @@ -1857,15 +2017,16 @@ occAnalLam env (Cast expr co) _ -> usage1 -- usage3: you might think this was not necessary, because of - -- the markAllNonTail in adjustRhsUsage; but not so! For a - -- join point, adjustRhsUsage doesn't do this; yet if there is + -- the markAllNonTail in adjustTailUsage; but not so! For a + -- join point, adjustTailUsage doesn't do this; yet if there is -- a cast, we must! Also: why markAllNonTail? See -- GHC.Core.Lint: Note Note [Join points and casts] usage3 = markAllNonTail usage2 - in WithUsageDetails usage3 (Cast expr' co) + in WithTailUsageDetails (TUD ja usage3) (Cast expr' co) -occAnalLam env expr = occAnal env expr +occAnalLamTail env expr = case occAnal env expr of + WithUsageDetails usage expr' -> WithTailUsageDetails (TUD 0 usage) expr' {- Note [Occ-anal and cast worker/wrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1885,8 +2046,8 @@ RHS. So it'll get a Many occ-info. (Maybe Cast w/w should create a stable unfolding, which would obviate this Note; but that seems a bit of a heavyweight solution.) -We only need to this in occAnalLam, not occAnal, because the top leve -of a right hand side is handled by occAnalLam. +We only need to this in occAnalLamTail, not occAnal, because the top leve +of a right hand side is handled by occAnalLamTail. -} @@ -1896,57 +2057,23 @@ of a right hand side is handled by occAnalLam. * * ********************************************************************* -} -occAnalRhs :: OccEnv -> RecFlag -> Maybe JoinArity - -> CoreExpr -- RHS - -> WithUsageDetails CoreExpr -occAnalRhs !env is_rec mb_join_arity rhs - = let (WithUsageDetails usage rhs1) = occAnalLam env rhs - -- We call occAnalLam here, not occAnalExpr, so that it doesn't - -- do the markAllInsideLam and markNonTailCall stuff before - -- we've had a chance to help with join points; that comes next - rhs2 = markJoinOneShots is_rec mb_join_arity rhs1 - rhs_usage = adjustRhsUsage mb_join_arity rhs2 usage - in WithUsageDetails rhs_usage rhs2 - - - -markJoinOneShots :: RecFlag -> Maybe JoinArity -> CoreExpr -> CoreExpr --- For a /non-recursive/ join point we can mark all --- its join-lambda as one-shot; and it's a good idea to do so -markJoinOneShots NonRecursive (Just join_arity) rhs - = go join_arity rhs - where - go 0 rhs = rhs - go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) - (go (n-1) rhs) - go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. - -- e.g. let j = case ... in j True - -- This will become an arity-1 join point after the - -- simplifier has eta-expanded it; but it may not have - -- enough lambdas /yet/. (Lint checks that JoinIds do - -- have enough lambdas.) -markJoinOneShots _ _ rhs - = rhs - occAnalUnfolding :: OccEnv - -> RecFlag - -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Unfolding - -> WithUsageDetails Unfolding + -> WithTailUsageDetails Unfolding -- Occurrence-analyse a stable unfolding; --- discard a non-stable one altogether. -occAnalUnfolding !env is_rec mb_join_arity unf +-- discard a non-stable one altogether and return empty usage details. +occAnalUnfolding !env unf = case unf of unf@(CoreUnfolding { uf_tmpl = rhs, uf_src = src }) | isStableSource src -> let - (WithUsageDetails usage rhs') = occAnalRhs env is_rec mb_join_arity rhs + WithTailUsageDetails (TUD rhs_ja usage) rhs' = occAnalLamTail env rhs unf' | noBinderSwaps env = unf -- Note [Unfoldings and rules] | otherwise = unf { uf_tmpl = rhs' } - in WithUsageDetails (markAllMany usage) unf' + in WithTailUsageDetails (TUD rhs_ja (markAllMany usage)) unf' -- markAllMany: see Note [Occurrences in stable unfoldings] - | otherwise -> WithUsageDetails emptyDetails unf + | otherwise -> WithTailUsageDetails (TUD 0 emptyDetails) unf -- For non-Stable unfoldings we leave them undisturbed, but -- don't count their usage because the simplifier will discard them. -- We leave them undisturbed because nodeScore uses their size info @@ -1955,29 +2082,26 @@ occAnalUnfolding !env is_rec mb_join_arity unf -- scope remain in scope; there is no cloning etc. unf@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) - -> WithUsageDetails final_usage (unf { df_args = args' }) + -> WithTailUsageDetails (TUD 0 final_usage) (unf { df_args = args' }) where env' = env `addInScope` bndrs (WithUsageDetails usage args') = occAnalList env' args - final_usage = markAllManyNonTail (delDetailsList usage bndrs) - `addLamCoVarOccs` bndrs - `delDetailsList` bndrs + final_usage = usage `addLamCoVarOccs` bndrs `delDetailsList` bndrs -- delDetailsList; no need to use tagLamBinders because we -- never inline DFuns so the occ-info on binders doesn't matter - unf -> WithUsageDetails emptyDetails unf + unf -> WithTailUsageDetails (TUD 0 emptyDetails) unf occAnalRules :: OccEnv - -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Id -- Get rules from here -> [(CoreRule, -- Each (non-built-in) rule UsageDetails, -- Usage details for LHS - UsageDetails)] -- Usage details for RHS -occAnalRules !env mb_join_arity bndr + TailUsageDetails)] -- Usage details for RHS +occAnalRules !env bndr = map occ_anal_rule (idCoreRules bndr) where occ_anal_rule rule@(Rule { ru_bndrs = bndrs, ru_args = args, ru_rhs = rhs }) - = (rule', lhs_uds', rhs_uds') + = (rule', lhs_uds', TUD rhs_ja rhs_uds') where env' = env `addInScope` bndrs rule' | noBinderSwaps env = rule -- Note [Unfoldings and rules] @@ -1990,14 +2114,11 @@ occAnalRules !env mb_join_arity bndr (WithUsageDetails rhs_uds rhs') = occAnal env' rhs -- Note [Rules are extra RHSs] -- Note [Rule dependency info] - rhs_uds' = markAllNonTailIf (not exact_join) $ - markAllMany $ + rhs_uds' = markAllMany $ rhs_uds `delDetailsList` bndrs + rhs_ja = length args -- See Note [Join points and unfoldings/rules] - exact_join = exactJoin mb_join_arity args - -- See Note [Join points and unfoldings/rules] - - occ_anal_rule other_rule = (other_rule, emptyDetails, emptyDetails) + occ_anal_rule other_rule = (other_rule, emptyDetails, TUD 0 emptyDetails) {- Note [Join point RHSs] ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2032,6 +2153,8 @@ Another way to think about it: if we inlined g as-is into multiple call sites, now there's be multiple calls to f. Bottom line: treat all occurrences in a stable unfolding as "Many". +We still leave tail call information intact, though, as to not spoil +potential join points. Note [Unfoldings and rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2209,10 +2332,7 @@ occAnal env app@(App _ _) = occAnalApp env (collectArgsTicks tickishFloatable app) occAnal env expr@(Lam {}) - = let (WithUsageDetails usage expr') = occAnalLam env expr - final_usage = markAllInsideLamIf (not (isOneShotFun expr')) $ - markAllNonTail usage - in WithUsageDetails final_usage expr' + = adjustNonRecRhs Nothing $ occAnalLamTail env expr -- mb_join_arity == Nothing <=> markAllManyNonTail occAnal env (Case scrut bndr ty alts) = let @@ -2287,7 +2407,7 @@ occAnalApp !env (Var fun, args, ticks) -- This caused #18296 | fun `hasKey` runRWKey , [t1, t2, arg] <- args - , let (WithUsageDetails usage arg') = occAnalRhs env NonRecursive (Just 1) arg + , WithUsageDetails usage arg' <- adjustNonRecRhs (Just 1) $ occAnalLamTail env arg = WithUsageDetails usage (mkTicks ticks $ mkApps (Var fun) [t1, t2, arg']) occAnalApp env (Var fun_id, args, ticks) @@ -2872,7 +2992,6 @@ lookupBndrSwap env@(OccEnv { occ_bs_env = bs_env }) bndr case lookupBndrSwap env bndr1 of (fun, fun_id) -> (mkCastMCo fun mco, fun_id) } - {- Historical note [Proxy let-bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We used to do the binder-swap transformation by introducing @@ -2998,6 +3117,19 @@ data UsageDetails instance Outputable UsageDetails where ppr ud = ppr (ud_env (flattenUsageDetails ud)) +-- | Captures the result of applying 'occAnalLamTail' to a function `\xyz.body`. +-- The TailUsageDetails records +-- * the number of lambdas (including type lambdas: a JoinArity) +-- * UsageDetails for the `body`, unadjusted by `adjustTailUsage`. +-- If the binding turns out to be a join point with the indicated join +-- arity, this unadjusted usage details is just what we need; otherwise we +-- need to discard tail calls. That's what `adjustTailUsage` does. +data TailUsageDetails = TUD !JoinArity !UsageDetails + +instance Outputable TailUsageDetails where + ppr (TUD ja uds) = lambda <> ppr ja <> ppr uds + + ------------------- -- UsageDetails API @@ -3139,24 +3271,49 @@ flattenUsageDetails ud@(UD { ud_env = env }) ------------------- -- See Note [Adjusting right-hand sides] -adjustRhsUsage :: Maybe JoinArity - -> CoreExpr -- Rhs, AFTER occ anal - -> UsageDetails -- From body of lambda +adjustTailUsage :: Maybe JoinArity + -> CoreExpr -- Rhs, AFTER occAnalLamTail + -> TailUsageDetails -- From body of lambda -> UsageDetails -adjustRhsUsage mb_join_arity rhs usage +adjustTailUsage mb_join_arity rhs (TUD rhs_ja usage) = -- c.f. occAnal (Lam {}) markAllInsideLamIf (not one_shot) $ markAllNonTailIf (not exact_join) $ usage where one_shot = isOneShotFun rhs - exact_join = exactJoin mb_join_arity bndrs - (bndrs,_) = collectBinders rhs + exact_join = mb_join_arity == Just rhs_ja -exactJoin :: Maybe JoinArity -> [a] -> Bool -exactJoin Nothing _ = False -exactJoin (Just join_arity) args = args `lengthIs` join_arity - -- Remember join_arity includes type binders +adjustTailArity :: Maybe JoinArity -> TailUsageDetails -> UsageDetails +adjustTailArity mb_rhs_ja (TUD ud_ja usage) = + markAllNonTailIf (mb_rhs_ja /= Just ud_ja) usage + +markNonRecJoinOneShots :: JoinArity -> CoreExpr -> CoreExpr +-- For a /non-recursive/ join point we can mark all +-- its join-lambda as one-shot; and it's a good idea to do so +markNonRecJoinOneShots join_arity rhs + = go join_arity rhs + where + go 0 rhs = rhs + go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) + (go (n-1) rhs) + go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. + -- e.g. let j = case ... in j True + -- This will become an arity-1 join point after the + -- simplifier has eta-expanded it; but it may not have + -- enough lambdas /yet/. (Lint checks that JoinIds do + -- have enough lambdas.) + +markNonRecUnfoldingOneShots :: Maybe JoinArity -> Unfolding -> Unfolding +-- ^ Apply 'markNonRecJoinOneShots' to a stable unfolding +markNonRecUnfoldingOneShots mb_join_arity unf + | Just ja <- mb_join_arity + , CoreUnfolding{uf_src=src,uf_tmpl=tmpl} <- unf + , isStableSource src + , let !tmpl' = markNonRecJoinOneShots ja tmpl + = unf{uf_tmpl=tmpl'} + | otherwise + = unf type IdWithOccInfo = Id @@ -3192,8 +3349,8 @@ tagLamBinder usage bndr tagNonRecBinder :: TopLevelFlag -- At top level? -> UsageDetails -- Of scope -> CoreBndr -- Binder - -> (UsageDetails, -- Details with binder removed - IdWithOccInfo) -- Tagged binder + -> WithUsageDetails -- Details with binder removed + IdWithOccInfo -- Tagged binder tagNonRecBinder lvl usage binder = let @@ -3205,37 +3362,34 @@ tagNonRecBinder lvl usage binder binder' = setBinderOcc occ' binder usage' = usage `delDetails` binder in - usage' `seq` (usage', binder') + WithUsageDetails usage' binder' tagRecBinders :: TopLevelFlag -- At top level? -> UsageDetails -- Of body of let ONLY - -> [Details] - -> (UsageDetails, -- Adjusted details for whole scope, + -> [NodeDetails] + -> WithUsageDetails -- Adjusted details for whole scope, -- with binders removed - [IdWithOccInfo]) -- Tagged binders + [IdWithOccInfo] -- Tagged binders -- Substantially more complicated than non-recursive case. Need to adjust RHS -- details *before* tagging binders (because the tags depend on the RHSes). tagRecBinders lvl body_uds details_s = let bndrs = map nd_bndr details_s - rhs_udss = map nd_uds details_s - -- 1. Determine join-point-hood of whole group, as determined by - -- the *unadjusted* usage details - unadj_uds = foldr andUDs body_uds rhs_udss + -- 1. See Note [Join arity prediction based on joinRhsArity] + -- Determine possible join-point-hood of whole group, by testing for + -- manifest join arity M. + -- This (re-)asserts that makeNode had made tuds for that same arity M! + unadj_uds = foldr (andUDs . test_manifest_arity) body_uds details_s + test_manifest_arity ND{nd_rhs=WithTailUsageDetails tuds rhs} + = adjustTailArity (Just (joinRhsArity rhs)) tuds - -- This is only used in `mb_join_arity`, to adjust each `Details` in `details_s`, thus, - -- when `bndrs` is non-empty. So, we only write `maybe False` as `decideJoinPointHood` - -- takes a `NonEmpty CoreBndr`; the default value `False` won't affect program behavior. - will_be_joins = maybe False (decideJoinPointHood lvl unadj_uds) (nonEmpty bndrs) - - -- 2. Adjust usage details of each RHS, taking into account the - -- join-point-hood decision - rhs_udss' = [ adjustRhsUsage (mb_join_arity bndr) rhs rhs_uds - | ND { nd_bndr = bndr, nd_uds = rhs_uds - , nd_rhs = rhs } <- details_s ] + bndr_ne = expectNonEmpty "List of binders is never empty" bndrs + will_be_joins = decideJoinPointHood lvl unadj_uds bndr_ne mb_join_arity :: Id -> Maybe JoinArity + -- mb_join_arity: See Note [Join arity prediction based on joinRhsArity] + -- This is the source O mb_join_arity bndr -- Can't use willBeJoinId_maybe here because we haven't tagged -- the binder yet (the tag depends on these adjustments!) @@ -3247,6 +3401,12 @@ tagRecBinders lvl body_uds details_s = assert (not will_be_joins) -- Should be AlwaysTailCalled if Nothing -- we are making join points! + -- 2. Adjust usage details of each RHS, taking into account the + -- join-point-hood decision + rhs_udss' = [ adjustTailUsage (mb_join_arity bndr) rhs rhs_tuds -- matching occAnalLamTail in makeNode + | ND { nd_bndr = bndr, nd_rhs = WithTailUsageDetails rhs_tuds rhs } + <- details_s ] + -- 3. Compute final usage details from adjusted RHS details adj_uds = foldr andUDs body_uds rhs_udss' @@ -3257,7 +3417,7 @@ tagRecBinders lvl body_uds details_s -- 5. Drop the binders from the adjusted details and return usage' = adj_uds `delDetailsList` bndrs in - (usage', bndrs') + WithUsageDetails usage' bndrs' setBinderOcc :: OccInfo -> CoreBndr -> CoreBndr setBinderOcc occ_info bndr @@ -3271,12 +3431,13 @@ setBinderOcc occ_info bndr | otherwise = setIdOccInfo bndr occ_info --- | Decide whether some bindings should be made into join points or not. +-- | Decide whether some bindings should be made into join points or not, based +-- on its occurrences. This is -- Returns `False` if they can't be join points. Note that it's an -- all-or-nothing decision, as if multiple binders are given, they're -- assumed to be mutually recursive. -- --- It must, however, be a final decision. If we say "True" for 'f', +-- It must, however, be a final decision. If we say `True` for 'f', -- and then subsequently decide /not/ make 'f' into a join point, then -- the decision about another binding 'g' might be invalidated if (say) -- 'f' tail-calls 'g'. ===================================== compiler/GHC/Data/Graph/Directed.hs ===================================== @@ -4,6 +4,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE DeriveFunctor #-} module GHC.Data.Graph.Directed ( Graph, graphFromEdgedVerticesOrd, graphFromEdgedVerticesUniq, @@ -108,7 +109,7 @@ data Node key payload = DigraphNode { node_payload :: payload, -- ^ User data node_key :: key, -- ^ User defined node id node_dependencies :: [key] -- ^ Dependencies/successors of the node - } + } deriving Functor instance (Outputable a, Outputable b) => Outputable (Node a b) where ===================================== compiler/GHC/Utils/Misc.hs ===================================== @@ -35,7 +35,7 @@ module GHC.Utils.Misc ( equalLength, compareLength, leLength, ltLength, isSingleton, only, expectOnly, GHC.Utils.Misc.singleton, - notNull, snocView, + notNull, expectNonEmpty, snocView, chunkList, @@ -481,7 +481,6 @@ expectOnly _ (a:_) = a #endif expectOnly msg _ = panic ("expectOnly: " ++ msg) - -- | Split a list into chunks of /n/ elements chunkList :: Int -> [a] -> [[a]] chunkList _ [] = [] @@ -500,6 +499,16 @@ changeLast [] _ = panic "changeLast" changeLast [_] x = [x] changeLast (x:xs) x' = x : changeLast xs x' +-- | Like @expectJust msg . nonEmpty@; a better alternative to 'NE.fromList'. +expectNonEmpty :: HasCallStack => String -> [a] -> NonEmpty a +{-# INLINE expectNonEmpty #-} +expectNonEmpty _ (x:xs) = x:|xs +expectNonEmpty msg [] = expectNonEmptyPanic msg + +expectNonEmptyPanic :: String -> a +expectNonEmptyPanic msg = panic ("expectNonEmpty: " ++ msg) +{-# NOINLINE expectNonEmptyPanic #-} + -- | Apply an effectful function to the last list element. mapLastM :: Functor f => (a -> f a) -> NonEmpty a -> f (NonEmpty a) mapLastM f (x:|[]) = NE.singleton <$> f x ===================================== testsuite/tests/simplCore/should_compile/T22428.hs ===================================== @@ -0,0 +1,9 @@ +module T22428 where + +f :: Integer -> Integer -> Integer +f x y = go y + where + go :: Integer -> Integer + go 0 = x + go n = go (n-1) + {-# INLINE go #-} ===================================== testsuite/tests/simplCore/should_compile/T22428.stderr ===================================== @@ -0,0 +1,45 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 32, types: 14, coercions: 0, joins: 1/1} + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22428.f1 :: Integer +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22428.f1 = GHC.Num.Integer.IS 1# + +-- RHS size: {terms: 28, types: 10, coercions: 0, joins: 1/1} +f :: Integer -> Integer -> Integer +[GblId, + Arity=2, + Str=<1L>, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 0] 156 0}] +f = \ (x :: Integer) (y :: Integer) -> + joinrec { + go [InlPrag=INLINE (sat-args=1), Occ=LoopBreaker, Dmd=SC(S,L)] + :: Integer -> Integer + [LclId[JoinId(1)(Just [!])], + Arity=1, + Str=<1L>, + Unf=Unf{Src=StableUser, TopLvl=False, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=False,boring_ok=False)}] + go (ds :: Integer) + = case ds of wild { + GHC.Num.Integer.IS x1 -> + case x1 of { + __DEFAULT -> jump go (GHC.Num.Integer.integerSub wild T22428.f1); + 0# -> x + }; + GHC.Num.Integer.IP x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1); + GHC.Num.Integer.IN x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1) + }; } in + jump go y + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -451,6 +451,7 @@ test('T22375', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeab # One module, T21851_2.hs, has OPTIONS_GHC -ddump-simpl # Expecting to see $s$wwombat 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']) @@ -462,3 +463,6 @@ test('T22272', normal, multimod_compile, ['T22272', '-O -fexpose-all-unfoldings test('T22459', normal, compile, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) test('T22662', normal, compile, ['']) + +# go should become a join point +test('T22428', [grep_errmsg(r'jump go') ], compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeable-binds -dsuppress-unfoldings']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f3bcc3b513d1332475ab3174ceb562b37810ca68 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f3bcc3b513d1332475ab3174ceb562b37810ca68 You're receiving 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 Jan 10 12:34:44 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 10 Jan 2023 07:34:44 -0500 Subject: [Git][ghc/ghc][wip/T22428] Fix contification with stable unfoldings (#22428) Message-ID: <63bd5b64eaaa0_3b1bf98fe52c44904d8@gitlab.mail> Sebastian Graf pushed to branch wip/T22428 at Glasgow Haskell Compiler / GHC Commits: 506cd44c by Sebastian Graf at 2023-01-10T13:34:29+01:00 Fix contification with stable unfoldings (#22428) Many functions now return a `TailUsageDetails` that adorns a `UsageDetails` with a `JoinArity` that reflects the number of join point binders around the body for which the `UsageDetails` was computed. `TailUsageDetails` is now returned by `occAnalLamTail` as well as `occAnalUnfolding` and `occAnalRules`. I adjusted `Note [Join points and unfoldings/rules]` and `Note [Adjusting right-hand sides]` to account for the new machinery. I also wrote a new `Note [Join arity prediction based on joinRhsArity]` and refer to it when we combine `TailUsageDetails` for a recursive RHS. I also renamed * `occAnalLam` to `occAnalLamTail` * `adjustRhsUsage` to `adjustTailUsage` * a few other less important functions and properly documented the that each call of `occAnalLamTail` must pair up with `adjustTailUsage`. I removed `Note [Unfoldings and join points]` because it was redundant with `Note [Occurrences in stable unfoldings]`. While in town, I refactored `mkLoopBreakerNodes` so that it returns a condensed `NodeDetails` called `SimpleNodeDetails`. Fixes #22428. Metric Decrease: T12150 T12425 T21839c T21839r T9961 - - - - - 7 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Data/Graph/Directed.hs - compiler/GHC/Utils/Misc.hs - + testsuite/tests/simplCore/should_compile/T22428.hs - + testsuite/tests/simplCore/should_compile/T22428.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -132,6 +132,9 @@ joinRhsArity :: CoreExpr -> JoinArity -- Join points are supposed to have manifestly-visible -- lambdas at the top: no ticks, no casts, nothing -- Moreover, type lambdas count in JoinArity +-- NB: For non-recursive bindings, the join arity of the binding may actually be +-- less that the number of manifestly-visible lambdas. +-- See Note [Join arity prediction based on joinRhsArity] in GHC.Core.Opt.OccurAnal joinRhsArity (Lam _ e) = 1 + joinRhsArity e joinRhsArity _ = 0 ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -59,7 +59,7 @@ import GHC.Builtin.Names( runRWKey ) import GHC.Unit.Module( Module ) import Data.List (mapAccumL, mapAccumR) -import Data.List.NonEmpty (NonEmpty (..), nonEmpty) +import Data.List.NonEmpty (NonEmpty (..)) import qualified Data.List.NonEmpty as NE {- @@ -510,6 +510,16 @@ of the file. at any of the definitions. This is done by Simplify.simplRecBind, when it calls addLetIdInfo. +Note [TailUsageDetails when forming Rec groups] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `TailUsageDetails` stored in the `nd_uds` field of a `NodeDetails` is +computed by `occAnalLamTail` applied to the RHS, not `occAnalExpr`. +That is because the binding might still become a *non-recursive join point* in +the AcyclicSCC case of dependency analysis! +Hence we do the delayed `adjustTailUsage` in `occAnalRec`/`tagRecBinders` to get +a regular, adjusted UsageDetails. +See Note [Join points and unfoldings/rules] for more details on the contract. + Note [Stable unfoldings] ~~~~~~~~~~~~~~~~~~~~~~~~ None of the above stuff about RULES applies to a stable unfolding @@ -608,6 +618,65 @@ tail call with `n` arguments (counting both value and type arguments). Otherwise 'occ_tail' will be 'NoTailCallInfo'. The tail call info flows bottom-up with the rest of 'OccInfo' until it goes on the binder. +Note [Join arity prediction based on joinRhsArity] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In general, the join arity from tail occurrences of a join point (O) may be +higher or lower than the manifest join arity of the join body (M). E.g., + + -- M > O: + let f x y = x + y -- M = 2 + in if b then f 1 else f 2 -- O = 1 + ==> { Contify for join arity 1 } + join f x = \y -> x + y + in if b then jump f 1 else jump f 2 + + -- M < O + let f = id -- M = 0 + in if ... then f 12 else f 13 -- O = 1 + ==> { Contify for join arity 1, eta-expand f } + join f x = id x + in if b then jump f 12 else jump f 13 + +But for *recursive* let, it is crucial that both arities match up, consider + + letrec f x y = if ... then f x else True + in f 42 + +Here, M=2 but O=1. If we settled for a joinrec arity of 1, the recursive jump +would not happen in a tail context! Contification is invalid here. +So indeed it is crucial to demand that M=O. + +(Side note: Actually, we could be more specific: Let O1 be the join arity of +occurrences from the letrec RHS and O2 the join arity from the let body. Then +we need M=O1 and M<=O2 and could simply eta-expand the RHS to match O2 later. +M=O is the specific case where we don't want to eta-expand. Neither the join +points paper nor GHC does this at the moment.) + +We can capitalise on this observation and conclude that *if* f could become a +joinrec (without eta-expansion), it will have join arity M. +Now, M is just the result of 'joinRhsArity', a rather simple, local analysis. +It is also the join arity inside the 'TailUsageDetails' returned by +'occAnalLamTail', so we can predict join arity without doing any fixed-point +iteration or really doing any deep traversal of let body or RHS at all. +We check for M in the 'adjustTailUsage' call inside 'tagRecBinders'. + +All this is quite apparent if you look at the contification transformation in +Fig. 5 of "Compiling without Continuations" (which does not account for +eta-expansion at all, mind you). The letrec case looks like this + + letrec f = /\as.\xs. L[us] in L'[es] + ... and a bunch of conditions establishing that f only occurs + in app heads of join arity (len as + len xs) inside us and es ... + +The syntactic form `/\as.\xs. L[us]` forces M=O iff `f` occurs in `us`. However, +for non-recursive functions, this is the definition of contification from the +paper: + + let f = /\as.\xs.u in L[es] ... conditions ... + +Note that u could be a lambda itself, as we have seen. No relationship between M +and O to exploit here. + Note [Join points and unfoldings/rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider @@ -618,8 +687,10 @@ Consider Before j is inlined, we'll have occurrences of j2 in both j's RHS and in its stable unfolding. We want to discover -j2 as a join point. So we must do the adjustRhsUsage thing -on j's RHS. That's why we pass mb_join_arity to calcUnfolding. +j2 as a join point. So 'occAnalUnfolding' returns an unadjusted +'TailUsageDetails', like 'occAnalLamTail'. We adjust the usage details of the +unfolding to the actual join arity using the same 'adjustTailArity' as for +the RHS, see Note [Adjusting right-hand sides]. Same with rules. Suppose we have: @@ -636,14 +707,31 @@ up. So provided the join-point arity of k matches the args of the rule we can allow the tail-call info from the RHS of the rule to propagate. -* Wrinkle for Rec case. In the recursive case we don't know the - join-point arity in advance, when calling occAnalUnfolding and - occAnalRules. (See makeNode.) We don't want to pass Nothing, - because then a recursive joinrec might lose its join-poin-hood - when SpecConstr adds a RULE. So we just make do with the - *current* join-poin-hood, stored in the Id. +* Note that the join arity of the RHS and that of the unfolding or RULE might + mismatch: + + let j x y = j2 (x+x) + {-# INLINE[2] j = \x. g #-} + {-# RULE forall x y z. j x y z = h 17 #-} + in j 1 2 - In the non-recursive case things are simple: see occAnalNonRecBind + So it is crucial that we adjust each TailUsageDetails individually + with the actual join arity 2 here before we combine with `andUDs`. + Here, that means losing tail call info on `g` and `h`. + +* Wrinkle for Rec case: We store one TailUsageDetails in the node Details for + RHS, unfolding and RULE combined. Clearly, if they don't agree on their join + arity, we have to do some adjusting. We choose to adjust to the join arity + of the RHS, because that is likely the join arity that the join point will + have; see Note [Join arity prediction based on joinRhsArity]. + + If the guess is correct, then tail calls in the RHS are preserved; a necessary + condition for the whole binding becoming a joinrec. + The guess can only be incorrect in the 'AcyclicSCC' case when the binding + becomes a non-recursive join point with a different join arity. But then the + eventual call to 'adjustTailUsage' in 'tagRecBinders'/'occAnalRec' will + be with a different join arity and destroy unsound tail call info with + 'markNonTail'. * Wrinkle for RULES. Suppose the example was a bit different: let j :: Int -> Int @@ -669,28 +757,21 @@ propagate. This appears to be very rare in practice. TODO Perhaps we should gather statistics to be sure. -Note [Unfoldings and join points] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We assume that anything in an unfolding occurs multiple times, since -unfoldings are often copied (that's the whole point!). But we still -need to track tail calls for the purpose of finding join points. - - ------------------------------------------------------------ Note [Adjusting right-hand sides] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There's a bit of a dance we need to do after analysing a lambda expression or a right-hand side. In particular, we need to - a) call 'markAllInsideLam' *unless* the binding is for a thunk, a one-shot - lambda, or a non-recursive join point; and - b) call 'markAllNonTail' *unless* the binding is for a join point, and - the RHS has the right arity; e.g. + a) call 'markAllNonTail' *unless* the binding is for a join point, and + the TailUsageDetails from the RHS has the right join arity; e.g. join j x y = case ... of A -> j2 p B -> j2 q in j a b Here we want the tail calls to j2 to be tail calls of the whole expression + b) call 'markAllInsideLam' *unless* the binding is for a thunk, a one-shot + lambda, or a non-recursive join point Some examples, with how the free occurrences in e (assumed not to be a value lambda) get marked: @@ -707,26 +788,39 @@ lambda) get marked: There are a few other caveats; most importantly, if we're marking a binding as 'AlwaysTailCalled', it's *going* to be a join point, so we treat it as one so that the effect cascades properly. Consequently, at the time the RHS is -analysed, we won't know what adjustments to make; thus 'occAnalLamOrRhs' must -return the unadjusted 'UsageDetails', to be adjusted by 'adjustRhsUsage' once -join-point-hood has been decided. - -Thus the overall sequence taking place in 'occAnalNonRecBind' and -'occAnalRecBind' is as follows: - - 1. Call 'occAnalLamOrRhs' to find usage information for the RHS. - 2. Call 'tagNonRecBinder' or 'tagRecBinders', which decides whether to make +analysed, we won't know what adjustments to make; thus 'occAnalLamTail' must +return the unadjusted 'TailUsageDetails', to be adjusted by 'adjustTailUsage' +once join-point-hood has been decided and eventual one-shot annotations have +been added through 'markNonRecJoinOneShots'. + +It is not so simple to see that 'occAnalNonRecBind' and 'occAnalRecBind' indeed +perform a similar sequence of steps. Thus, here is an interleaving of events +of both functions, serving as a specification: + + 1. Call 'occAnalLamTail' to find usage information for the RHS. + Recursive case: 'makeNode' + Non-recursive case: 'occAnalNonRecBind' + 2. (Analyse the binding's scope. Done in 'occAnalBind'/`occAnal Let{}`. + Same whether recursive or not.) + 3. Call 'tagNonRecBinder' or 'tagRecBinders', which decides whether to make the binding a join point. - 3. Call 'adjustRhsUsage' accordingly. (Done as part of 'tagRecBinders' when - recursive.) - -(In the recursive case, this logic is spread between 'makeNode' and -'occAnalRec'.) + Cyclic Recursive case: 'mkLoopBreakerNodes' + Acyclic Recursive case: `occAnalRec AcyclicSCC{}` + Non-recursive case: 'occAnalNonRecBind' + 4. Non-recursive join point: Call 'markNonRecJoinOneShots' so that e.g., + FloatOut sees one-shot annotations on lambdas + Acyclic Recursive case: `occAnalRec AcyclicSCC{}` calls 'adjustNonRecRhs' + Non-recursive case: 'occAnalNonRecBind' calls 'adjustNonRecRhs' + 5. Call 'adjustTailUsage' accordingly. + Cyclic Recursive case: 'tagRecBinders' + Acyclic Recursive case: 'adjustNonRecRhs' + Non-recursive case: 'adjustNonRecRhs' -} - data WithUsageDetails a = WithUsageDetails !UsageDetails !a +data WithTailUsageDetails a = WithTailUsageDetails !TailUsageDetails !a + ------------------------------------------------------------------ -- occAnalBind ------------------------------------------------------------------ @@ -750,19 +844,17 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage | isTyVar bndr -- A type let; we don't gather usage info = WithUsageDetails body_usage [NonRec bndr rhs] - | not (bndr `usedIn` body_usage) -- It's not mentioned - = WithUsageDetails body_usage [] + | not (bndr `usedIn` body_usage) + = WithUsageDetails body_usage [] -- See Note [Dead code] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr rhs'] + = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr final_rhs] where - (body_usage', tagged_bndr) = tagNonRecBinder lvl body_usage bndr - final_bndr = tagged_bndr `setIdUnfolding` unf' - `setIdSpecialisation` mkRuleInfo rules' - rhs_usage = rhs_uds `andUDs` unf_uds `andUDs` rule_uds + WithUsageDetails body_usage' tagged_bndr = tagNonRecBinder lvl body_usage bndr -- Get the join info from the *new* decision -- See Note [Join points and unfoldings/rules] + -- => join arity O of Note [Join arity prediction based on joinRhsArity] mb_join_arity = willBeJoinId_maybe tagged_bndr is_join_point = isJust mb_join_arity @@ -773,17 +865,28 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- See Note [Sources of one-shot information] rhs_env = env1 { occ_one_shots = argOneShots dmd } - (WithUsageDetails rhs_uds rhs') = occAnalRhs rhs_env NonRecursive mb_join_arity rhs + -- See Note [Join arity prediction based on joinRhsArity] + -- Match join arity O from mb_join_arity with manifest join arity M as + -- returned by of occAnalLamTail. It's totally OK for them to mismatch; + -- hence adjust the UDs from the RHS + WithUsageDetails adj_rhs_uds final_rhs + = adjustNonRecRhs mb_join_arity $ occAnalLamTail rhs_env rhs + rhs_usage = adj_rhs_uds `andUDs` adj_unf_uds `andUDs` adj_rule_uds + final_bndr = tagged_bndr `setIdSpecialisation` mkRuleInfo rules' + `setIdUnfolding` unf2 --------- Unfolding --------- - -- See Note [Unfoldings and join points] + -- See Note [Join points and unfoldings/rules] unf | isId bndr = idUnfolding bndr | otherwise = NoUnfolding - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env NonRecursive mb_join_arity unf + WithTailUsageDetails unf_uds unf1 = occAnalUnfolding rhs_env unf + unf2 = markNonRecUnfoldingOneShots mb_join_arity unf1 + adj_unf_uds = adjustTailArity mb_join_arity unf_uds --------- Rules --------- -- See Note [Rules are extra RHSs] and Note [Rule dependency info] - rules_w_uds = occAnalRules rhs_env mb_join_arity bndr + -- and Note [Join points and unfoldings/rules] + rules_w_uds = occAnalRules rhs_env bndr rules' = map fstOf3 rules_w_uds imp_rule_uds = impRulesScopeUsage (lookupImpRules imp_rule_edges bndr) -- imp_rule_uds: consider @@ -794,8 +897,9 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- that g is (since the RULE might turn g into h), so -- we make g mention h. - rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds - add_rule_uds (_, l, r) uds = l `andUDs` r `andUDs` uds + adj_rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds + add_rule_uds (_, l, r) uds + = l `andUDs` adjustTailArity mb_join_arity r `andUDs` uds ---------- occ = idOccInfo tagged_bndr @@ -820,7 +924,7 @@ occAnalRecBind :: OccEnv -> TopLevelFlag -> ImpRuleEdges -> [(Var,CoreExpr)] occAnalRecBind !env lvl imp_rule_edges pairs body_usage = foldr (occAnalRec rhs_env lvl) (WithUsageDetails body_usage []) sccs where - sccs :: [SCC Details] + sccs :: [SCC NodeDetails] sccs = {-# SCC "occAnalBind.scc" #-} stronglyConnCompFromEdgedVerticesUniq nodes @@ -832,27 +936,41 @@ occAnalRecBind !env lvl imp_rule_edges pairs body_usage bndr_set = mkVarSet bndrs rhs_env = env `addInScope` bndrs +adjustNonRecRhs :: Maybe JoinArity -> WithTailUsageDetails CoreExpr -> WithUsageDetails CoreExpr +-- ^ This function concentrates shared logic between occAnalNonRecBind and the +-- AcyclicSCC case of occAnalRec. +-- * It applies 'markNonRecJoinOneShots' to the RHS +-- * and returns the adjusted rhs UsageDetails combined with the body usage +adjustNonRecRhs mb_join_arity (WithTailUsageDetails rhs_tuds rhs) + = WithUsageDetails rhs_uds' rhs' + where + --------- Marking (non-rec) join binders one-shot --------- + !rhs' | Just ja <- mb_join_arity = markNonRecJoinOneShots ja rhs + | otherwise = rhs + --------- Adjusting right-hand side usage --------- + rhs_uds' = adjustTailUsage mb_join_arity rhs' rhs_tuds ----------------------------- occAnalRec :: OccEnv -> TopLevelFlag - -> SCC Details + -> SCC NodeDetails -> WithUsageDetails [CoreBind] -> WithUsageDetails [CoreBind] -- The NonRec case is just like a Let (NonRec ...) above -occAnalRec !_ lvl (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = rhs - , nd_uds = rhs_uds })) +occAnalRec !_ lvl + (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = wtuds })) (WithUsageDetails body_uds binds) | not (bndr `usedIn` body_uds) = WithUsageDetails body_uds binds -- See Note [Dead code] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_uds' `andUDs` rhs_uds') - (NonRec tagged_bndr rhs : binds) + = WithUsageDetails (body_uds' `andUDs` rhs_uds') (NonRec bndr' rhs' : binds) where - (body_uds', tagged_bndr) = tagNonRecBinder lvl body_uds bndr - rhs_uds' = adjustRhsUsage mb_join_arity rhs rhs_uds + WithUsageDetails body_uds' tagged_bndr = tagNonRecBinder lvl body_uds bndr mb_join_arity = willBeJoinId_maybe tagged_bndr + WithUsageDetails rhs_uds' rhs' = adjustNonRecRhs mb_join_arity wtuds + !unf' = markNonRecUnfoldingOneShots mb_join_arity (idUnfolding tagged_bndr) + !bndr' = tagged_bndr `setIdUnfolding` unf' -- The Rec case is the interesting one -- See Note [Recursive bindings: the grand plan] @@ -873,7 +991,7 @@ occAnalRec env lvl (CyclicSCC details_s) (WithUsageDetails body_uds binds) -- Make the nodes for the loop-breaker analysis -- See Note [Choosing loop breakers] for loop_breaker_nodes final_uds :: UsageDetails - loop_breaker_nodes :: [LetrecNode] + loop_breaker_nodes :: [LoopBreakerNode] (WithUsageDetails final_uds loop_breaker_nodes) = mkLoopBreakerNodes env lvl body_uds details_s ------------------------------ @@ -1102,7 +1220,7 @@ type Binding = (Id,CoreExpr) loopBreakNodes :: Int -> VarSet -- Binders whose dependencies may be "missing" -- See Note [Weak loop breakers] - -> [LetrecNode] + -> [LoopBreakerNode] -> [Binding] -- Append these to the end -> [Binding] @@ -1121,7 +1239,7 @@ loopBreakNodes depth weak_fvs nodes binds CyclicSCC nodes -> reOrderNodes depth weak_fvs nodes binds ---------------------------------- -reOrderNodes :: Int -> VarSet -> [LetrecNode] -> [Binding] -> [Binding] +reOrderNodes :: Int -> VarSet -> [LoopBreakerNode] -> [Binding] -> [Binding] -- Choose a loop breaker, mark it no-inline, -- and call loopBreakNodes on the rest reOrderNodes _ _ [] _ = panic "reOrderNodes" @@ -1133,7 +1251,7 @@ reOrderNodes depth weak_fvs (node : nodes) binds (map (nodeBinding mk_loop_breaker) chosen_nodes ++ binds) where (chosen_nodes, unchosen) = chooseLoopBreaker approximate_lb - (nd_score (node_payload node)) + (snd_score (node_payload node)) [node] [] nodes approximate_lb = depth >= 2 @@ -1142,8 +1260,8 @@ reOrderNodes depth weak_fvs (node : nodes) binds -- After two iterations (d=0, d=1) give up -- and approximate, returning to d=0 -nodeBinding :: (Id -> Id) -> LetrecNode -> Binding -nodeBinding set_id_occ (node_payload -> ND { nd_bndr = bndr, nd_rhs = rhs}) +nodeBinding :: (Id -> Id) -> LoopBreakerNode -> Binding +nodeBinding set_id_occ (node_payload -> SND { snd_bndr = bndr, snd_rhs = rhs}) = (set_id_occ bndr, rhs) mk_loop_breaker :: Id -> Id @@ -1163,13 +1281,13 @@ mk_non_loop_breaker weak_fvs bndr tail_info = tailCallInfo (idOccInfo bndr) ---------------------------------- -chooseLoopBreaker :: Bool -- True <=> Too many iterations, - -- so approximate - -> NodeScore -- Best score so far - -> [LetrecNode] -- Nodes with this score - -> [LetrecNode] -- Nodes with higher scores - -> [LetrecNode] -- Unprocessed nodes - -> ([LetrecNode], [LetrecNode]) +chooseLoopBreaker :: Bool -- True <=> Too many iterations, + -- so approximate + -> NodeScore -- Best score so far + -> [LoopBreakerNode] -- Nodes with this score + -> [LoopBreakerNode] -- Nodes with higher scores + -> [LoopBreakerNode] -- Unprocessed nodes + -> ([LoopBreakerNode], [LoopBreakerNode]) -- This loop looks for the bind with the lowest score -- to pick as the loop breaker. The rest accumulate in chooseLoopBreaker _ _ loop_nodes acc [] @@ -1189,7 +1307,7 @@ chooseLoopBreaker approx_lb loop_sc loop_nodes acc (node : nodes) | otherwise -- Worse score so don't pick it = chooseLoopBreaker approx_lb loop_sc loop_nodes (node : acc) nodes where - sc = nd_score (node_payload node) + sc = snd_score (node_payload node) {- Note [Complexity of loop breaking] @@ -1322,16 +1440,21 @@ ToDo: try using the occurrence info for the inline'd binder. ************************************************************************ -} -type LetrecNode = Node Unique Details -- Node comes from Digraph - -- The Unique key is gotten from the Id -data Details - = ND { nd_bndr :: Id -- Binder +-- | Digraph node as constructed by 'makeNode' and consumed by 'occAnalRec'. +-- The Unique key is gotten from the Id. +type LetrecNode = Node Unique NodeDetails - , nd_rhs :: CoreExpr -- RHS, already occ-analysed +-- | Node details as consumed by 'occAnalRec'. +data NodeDetails + = ND { nd_bndr :: Id -- Binder - , nd_uds :: UsageDetails -- Usage from RHS, and RULES, and stable unfoldings - -- ignoring phase (ie assuming all are active) - -- See Note [Forming Rec groups] + , nd_rhs :: !(WithTailUsageDetails CoreExpr) + -- ^ RHS, already occ-analysed + -- With TailUsageDetails from RHS, and RULES, and stable unfoldings, + -- ignoring phase (ie assuming all are active). + -- NB: Unadjusted TailUsageDetails, as if this Node becomes a + -- non-recursive join point! + -- See Note [TailUsageDetails when forming Rec groups] , nd_inl :: IdSet -- Free variables of the stable unfolding and the RHS -- but excluding any RULES @@ -1348,18 +1471,33 @@ data Details , nd_active_rule_fvs :: IdSet -- Variables bound in this Rec group that are free -- in the RHS of an active rule for this bndr -- See Note [Rules and loop breakers] - - , nd_score :: NodeScore } -instance Outputable Details where +instance Outputable NodeDetails where ppr nd = text "ND" <> braces (sep [ text "bndr =" <+> ppr (nd_bndr nd) - , text "uds =" <+> ppr (nd_uds nd) + , text "uds =" <+> ppr uds , text "inl =" <+> ppr (nd_inl nd) , text "simple =" <+> ppr (nd_simple nd) , text "active_rule_fvs =" <+> ppr (nd_active_rule_fvs nd) - , text "score =" <+> ppr (nd_score nd) + ]) + where WithTailUsageDetails uds _ = nd_rhs nd + +-- | Digraph with simplified and completely occurrence analysed +-- 'SimpleNodeDetails', retaining just the info we need for breaking loops. +type LoopBreakerNode = Node Unique SimpleNodeDetails + +-- | Condensed variant of 'NodeDetails' needed during loop breaking. +data SimpleNodeDetails + = SND { snd_bndr :: IdWithOccInfo -- OccInfo accurate + , snd_rhs :: CoreExpr -- properly occur-analysed + , snd_score :: NodeScore + } + +instance Outputable SimpleNodeDetails where + ppr nd = text "SND" <> braces + (sep [ text "bndr =" <+> ppr (snd_bndr nd) + , text "score =" <+> ppr (snd_score nd) ]) -- The NodeScore is compared lexicographically; @@ -1387,52 +1525,59 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) -- explained in Note [Deterministic SCC] in GHC.Data.Graph.Directed. where details = ND { nd_bndr = bndr' - , nd_rhs = rhs' - , nd_uds = scope_uds + , nd_rhs = WithTailUsageDetails scope_uds rhs' , nd_inl = inl_fvs , nd_simple = null rules_w_uds && null imp_rule_info , nd_weak_fvs = weak_fvs - , nd_active_rule_fvs = active_rule_fvs - , nd_score = pprPanic "makeNodeDetails" (ppr bndr) } + , nd_active_rule_fvs = active_rule_fvs } bndr' = bndr `setIdUnfolding` unf' `setIdSpecialisation` mkRuleInfo rules' - inl_uds = rhs_uds `andUDs` unf_uds - scope_uds = inl_uds `andUDs` rule_uds + -- NB: Both adj_unf_uds and adj_rule_uds have been adjusted to match the + -- JoinArity rhs_ja of unadj_rhs_uds. + unadj_inl_uds = unadj_rhs_uds `andUDs` adj_unf_uds + unadj_scope_uds = unadj_inl_uds `andUDs` adj_rule_uds + scope_uds = TUD rhs_ja unadj_scope_uds -- Note [Rules are extra RHSs] -- Note [Rule dependency info] - scope_fvs = udFreeVars bndr_set scope_uds + scope_fvs = udFreeVars bndr_set unadj_scope_uds -- scope_fvs: all occurrences from this binder: RHS, unfolding, -- and RULES, both LHS and RHS thereof, active or inactive - inl_fvs = udFreeVars bndr_set inl_uds + inl_fvs = udFreeVars bndr_set unadj_inl_uds -- inl_fvs: vars that would become free if the function was inlined. -- We conservatively approximate that by thefree vars from the RHS -- and the unfolding together. -- See Note [inl_fvs] - mb_join_arity = isJoinId_maybe bndr - -- Get join point info from the *current* decision - -- We don't know what the new decision will be! - -- Using the old decision at least allows us to - -- preserve existing join point, even RULEs are added - -- See Note [Join points and unfoldings/rules] --------- Right hand side --------- -- Constructing the edges for the main Rec computation -- See Note [Forming Rec groups] - -- Do not use occAnalRhs because we don't yet know the final - -- answer for mb_join_arity; instead, do the occAnalLam call from - -- occAnalRhs, and postpone adjustRhsUsage until occAnalRec - rhs_env = rhsCtxt env - (WithUsageDetails rhs_uds rhs') = occAnalLam rhs_env rhs + -- and Note [TailUsageDetails when forming Rec groups] + -- Compared to occAnalNonRecBind, we can't yet adjust the RHS because + -- (a) we don't yet know the final joinpointhood. It might not become a + -- join point after all! + -- (b) we don't even know whether it stays a recursive RHS after the SCC + -- analysis we are about to seed! So we can't markAllInsideLam in + -- advance, because if it ends up as a non-recursive join point we'll + -- consider it as one-shot and don't need to markAllInsideLam. + -- Instead, do the occAnalLamTail call here and postpone adjustTailUsage + -- until occAnalRec. In effect, we pretend that the RHS becomes a + -- non-recursive join point and fix up later with adjustTailUsage. + rhs_env = rhsCtxt env + WithTailUsageDetails (TUD rhs_ja unadj_rhs_uds) rhs' = occAnalLamTail rhs_env rhs + -- corresponding call to adjustTailUsage in occAnalRec and tagRecBinders --------- Unfolding --------- - -- See Note [Unfoldings and join points] + -- See Note [Join points and unfoldings/rules] unf = realIdUnfolding bndr -- realIdUnfolding: Ignore loop-breaker-ness -- here because that is what we are setting! - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env Recursive mb_join_arity unf + WithTailUsageDetails unf_tuds unf' = occAnalUnfolding rhs_env unf + adj_unf_uds = adjustTailArity (Just rhs_ja) unf_tuds + -- `rhs_ja` is `joinRhsArity rhs` and is the prediction for source M + -- of Note [Join arity prediction based on joinRhsArity] --------- IMP-RULES -------- is_active = occ_rule_act env :: Activation -> Bool @@ -1441,11 +1586,15 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) imp_rule_fvs = impRulesActiveFvs is_active bndr_set imp_rule_info --------- All rules -------- + -- See Note [Join points and unfoldings/rules] + -- `rhs_ja` is `joinRhsArity rhs'` and is the prediction for source M + -- of Note [Join arity prediction based on joinRhsArity] rules_w_uds :: [(CoreRule, UsageDetails, UsageDetails)] - rules_w_uds = occAnalRules rhs_env mb_join_arity bndr + rules_w_uds = [ (r,l,adjustTailArity (Just rhs_ja) rhs_tuds) + | (r,l,rhs_tuds) <- occAnalRules rhs_env bndr ] rules' = map fstOf3 rules_w_uds - rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds + adj_rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds add_rule_uds (_, l, r) uds = l `andUDs` r `andUDs` uds -------- active_rule_fvs ------------ @@ -1463,8 +1612,8 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) mkLoopBreakerNodes :: OccEnv -> TopLevelFlag -> UsageDetails -- for BODY of let - -> [Details] - -> WithUsageDetails [LetrecNode] -- adjusted + -> [NodeDetails] + -> WithUsageDetails [LoopBreakerNode] -- with OccInfo up-to-date -- See Note [Choosing loop breakers] -- This function primarily creates the Nodes for the -- loop-breaker SCC analysis. More specifically: @@ -1477,10 +1626,10 @@ mkLoopBreakerNodes :: OccEnv -> TopLevelFlag mkLoopBreakerNodes !env lvl body_uds details_s = WithUsageDetails final_uds (zipWithEqual "mkLoopBreakerNodes" mk_lb_node details_s bndrs') where - (final_uds, bndrs') = tagRecBinders lvl body_uds details_s + WithUsageDetails final_uds bndrs' = tagRecBinders lvl body_uds details_s mk_lb_node nd@(ND { nd_bndr = old_bndr, nd_inl = inl_fvs }) new_bndr - = DigraphNode { node_payload = new_nd + = DigraphNode { node_payload = simple_nd , node_key = varUnique old_bndr , node_dependencies = nonDetKeysUniqSet lb_deps } -- It's OK to use nonDetKeysUniqSet here as @@ -1488,7 +1637,8 @@ mkLoopBreakerNodes !env lvl body_uds details_s -- in nondeterministic order as explained in -- Note [Deterministic SCC] in GHC.Data.Graph.Directed. where - new_nd = nd { nd_bndr = new_bndr, nd_score = score } + WithTailUsageDetails _ rhs = nd_rhs nd + simple_nd = SND { snd_bndr = new_bndr, snd_rhs = rhs, snd_score = score } score = nodeScore env new_bndr lb_deps nd lb_deps = extendFvs_ rule_fv_env inl_fvs -- See Note [Loop breaker dependencies] @@ -1524,10 +1674,10 @@ group { f1 = e1; ...; fn = en } are: nodeScore :: OccEnv -> Id -- Binder with new occ-info -> VarSet -- Loop-breaker dependencies - -> Details + -> NodeDetails -> NodeScore nodeScore !env new_bndr lb_deps - (ND { nd_bndr = old_bndr, nd_rhs = bind_rhs }) + (ND { nd_bndr = old_bndr, nd_rhs = WithTailUsageDetails _ bind_rhs }) | not (isId old_bndr) -- A type or coercion variable is never a loop breaker = (100, 0, False) @@ -1748,7 +1898,7 @@ lambda and casts, e.g. * Occurrence analyser: we just mark each binder in the lambda-group (here: x,y,z) with its occurrence info in the *body* of the - lambda-group. See occAnalLam. + lambda-group. See occAnalLamTail. * Simplifier. The simplifier is careful when partially applying lambda-groups. See the call to zapLambdaBndrs in @@ -1804,25 +1954,31 @@ zapLambdaBndrs fun arg_count zap_bndr b | isTyVar b = b | otherwise = zapLamIdInfo b -occAnalLam :: OccEnv -> CoreExpr -> (WithUsageDetails CoreExpr) --- See Note [Occurrence analysis for lambda binders] +occAnalLamTail :: OccEnv -> CoreExpr -> WithTailUsageDetails CoreExpr +-- ^ See Note [Occurrence analysis for lambda binders]. -- It does the following: -- * Sets one-shot info on the lambda binder from the OccEnv, and -- removes that one-shot info from the OccEnv -- * Sets the OccEnv to OccVanilla when going under a value lambda -- * Tags each lambda with its occurrence information -- * Walks through casts +-- * Package up the analysed lambda with its manifest join arity +-- -- This function does /not/ do -- markAllInsideLam or -- markAllNonTail --- The caller does that, either in occAnal (Lam {}), or in adjustRhsUsage +-- The caller does that, via adjustTailUsage (mostly calls go through +-- adjustNonRecRhs). Every call to occAnalLamTail must ultimately call +-- adjustTailUsage to discharge the assumed join arity. +-- +-- In effect, the analysis result is for a non-recursive join point with +-- manifest arity and adjustTailUsage does the fixup. -- See Note [Adjusting right-hand sides] - -occAnalLam env (Lam bndr expr) +occAnalLamTail env (Lam bndr expr) | isTyVar bndr - = let env1 = addOneInScope env bndr - WithUsageDetails usage expr' = occAnalLam env1 expr - in WithUsageDetails usage (Lam bndr expr') + , let env1 = addOneInScope env bndr + , WithTailUsageDetails (TUD ja usage) expr' <- occAnalLamTail env1 expr + = WithTailUsageDetails (TUD (ja+1) usage) (Lam bndr expr') -- Important: Keep the 'env' unchanged so that with a RHS like -- \(@ x) -> K @x (f @x) -- we'll see that (K @x (f @x)) is in a OccRhs, and hence refrain @@ -1840,14 +1996,14 @@ occAnalLam env (Lam bndr expr) env1 = env { occ_encl = OccVanilla, occ_one_shots = env_one_shots' } env2 = addOneInScope env1 bndr - (WithUsageDetails usage expr') = occAnalLam env2 expr + WithTailUsageDetails (TUD ja usage) expr' = occAnalLamTail env2 expr (usage', bndr2) = tagLamBinder usage bndr1 - in WithUsageDetails usage' (Lam bndr2 expr') + in WithTailUsageDetails (TUD (ja+1) usage') (Lam bndr2 expr') -- For casts, keep going in the same lambda-group -- See Note [Occurrence analysis for lambda binders] -occAnalLam env (Cast expr co) - = let (WithUsageDetails usage expr') = occAnalLam env expr +occAnalLamTail env (Cast expr co) + = let WithTailUsageDetails (TUD ja usage) expr' = occAnalLamTail env expr -- usage1: see Note [Gather occurrences of coercion variables] usage1 = addManyOccs usage (coVarsOfCo co) @@ -1857,15 +2013,16 @@ occAnalLam env (Cast expr co) _ -> usage1 -- usage3: you might think this was not necessary, because of - -- the markAllNonTail in adjustRhsUsage; but not so! For a - -- join point, adjustRhsUsage doesn't do this; yet if there is + -- the markAllNonTail in adjustTailUsage; but not so! For a + -- join point, adjustTailUsage doesn't do this; yet if there is -- a cast, we must! Also: why markAllNonTail? See -- GHC.Core.Lint: Note Note [Join points and casts] usage3 = markAllNonTail usage2 - in WithUsageDetails usage3 (Cast expr' co) + in WithTailUsageDetails (TUD ja usage3) (Cast expr' co) -occAnalLam env expr = occAnal env expr +occAnalLamTail env expr = case occAnal env expr of + WithUsageDetails usage expr' -> WithTailUsageDetails (TUD 0 usage) expr' {- Note [Occ-anal and cast worker/wrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1885,8 +2042,8 @@ RHS. So it'll get a Many occ-info. (Maybe Cast w/w should create a stable unfolding, which would obviate this Note; but that seems a bit of a heavyweight solution.) -We only need to this in occAnalLam, not occAnal, because the top leve -of a right hand side is handled by occAnalLam. +We only need to this in occAnalLamTail, not occAnal, because the top leve +of a right hand side is handled by occAnalLamTail. -} @@ -1896,57 +2053,23 @@ of a right hand side is handled by occAnalLam. * * ********************************************************************* -} -occAnalRhs :: OccEnv -> RecFlag -> Maybe JoinArity - -> CoreExpr -- RHS - -> WithUsageDetails CoreExpr -occAnalRhs !env is_rec mb_join_arity rhs - = let (WithUsageDetails usage rhs1) = occAnalLam env rhs - -- We call occAnalLam here, not occAnalExpr, so that it doesn't - -- do the markAllInsideLam and markNonTailCall stuff before - -- we've had a chance to help with join points; that comes next - rhs2 = markJoinOneShots is_rec mb_join_arity rhs1 - rhs_usage = adjustRhsUsage mb_join_arity rhs2 usage - in WithUsageDetails rhs_usage rhs2 - - - -markJoinOneShots :: RecFlag -> Maybe JoinArity -> CoreExpr -> CoreExpr --- For a /non-recursive/ join point we can mark all --- its join-lambda as one-shot; and it's a good idea to do so -markJoinOneShots NonRecursive (Just join_arity) rhs - = go join_arity rhs - where - go 0 rhs = rhs - go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) - (go (n-1) rhs) - go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. - -- e.g. let j = case ... in j True - -- This will become an arity-1 join point after the - -- simplifier has eta-expanded it; but it may not have - -- enough lambdas /yet/. (Lint checks that JoinIds do - -- have enough lambdas.) -markJoinOneShots _ _ rhs - = rhs - occAnalUnfolding :: OccEnv - -> RecFlag - -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Unfolding - -> WithUsageDetails Unfolding + -> WithTailUsageDetails Unfolding -- Occurrence-analyse a stable unfolding; --- discard a non-stable one altogether. -occAnalUnfolding !env is_rec mb_join_arity unf +-- discard a non-stable one altogether and return empty usage details. +occAnalUnfolding !env unf = case unf of unf@(CoreUnfolding { uf_tmpl = rhs, uf_src = src }) | isStableSource src -> let - (WithUsageDetails usage rhs') = occAnalRhs env is_rec mb_join_arity rhs + WithTailUsageDetails (TUD rhs_ja usage) rhs' = occAnalLamTail env rhs unf' | noBinderSwaps env = unf -- Note [Unfoldings and rules] | otherwise = unf { uf_tmpl = rhs' } - in WithUsageDetails (markAllMany usage) unf' + in WithTailUsageDetails (TUD rhs_ja (markAllMany usage)) unf' -- markAllMany: see Note [Occurrences in stable unfoldings] - | otherwise -> WithUsageDetails emptyDetails unf + | otherwise -> WithTailUsageDetails (TUD 0 emptyDetails) unf -- For non-Stable unfoldings we leave them undisturbed, but -- don't count their usage because the simplifier will discard them. -- We leave them undisturbed because nodeScore uses their size info @@ -1955,29 +2078,26 @@ occAnalUnfolding !env is_rec mb_join_arity unf -- scope remain in scope; there is no cloning etc. unf@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) - -> WithUsageDetails final_usage (unf { df_args = args' }) + -> WithTailUsageDetails (TUD 0 final_usage) (unf { df_args = args' }) where env' = env `addInScope` bndrs (WithUsageDetails usage args') = occAnalList env' args - final_usage = markAllManyNonTail (delDetailsList usage bndrs) - `addLamCoVarOccs` bndrs - `delDetailsList` bndrs + final_usage = usage `addLamCoVarOccs` bndrs `delDetailsList` bndrs -- delDetailsList; no need to use tagLamBinders because we -- never inline DFuns so the occ-info on binders doesn't matter - unf -> WithUsageDetails emptyDetails unf + unf -> WithTailUsageDetails (TUD 0 emptyDetails) unf occAnalRules :: OccEnv - -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Id -- Get rules from here -> [(CoreRule, -- Each (non-built-in) rule UsageDetails, -- Usage details for LHS - UsageDetails)] -- Usage details for RHS -occAnalRules !env mb_join_arity bndr + TailUsageDetails)] -- Usage details for RHS +occAnalRules !env bndr = map occ_anal_rule (idCoreRules bndr) where occ_anal_rule rule@(Rule { ru_bndrs = bndrs, ru_args = args, ru_rhs = rhs }) - = (rule', lhs_uds', rhs_uds') + = (rule', lhs_uds', TUD rhs_ja rhs_uds') where env' = env `addInScope` bndrs rule' | noBinderSwaps env = rule -- Note [Unfoldings and rules] @@ -1990,14 +2110,11 @@ occAnalRules !env mb_join_arity bndr (WithUsageDetails rhs_uds rhs') = occAnal env' rhs -- Note [Rules are extra RHSs] -- Note [Rule dependency info] - rhs_uds' = markAllNonTailIf (not exact_join) $ - markAllMany $ + rhs_uds' = markAllMany $ rhs_uds `delDetailsList` bndrs + rhs_ja = length args -- See Note [Join points and unfoldings/rules] - exact_join = exactJoin mb_join_arity args - -- See Note [Join points and unfoldings/rules] - - occ_anal_rule other_rule = (other_rule, emptyDetails, emptyDetails) + occ_anal_rule other_rule = (other_rule, emptyDetails, TUD 0 emptyDetails) {- Note [Join point RHSs] ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2032,6 +2149,8 @@ Another way to think about it: if we inlined g as-is into multiple call sites, now there's be multiple calls to f. Bottom line: treat all occurrences in a stable unfolding as "Many". +We still leave tail call information intact, though, as to not spoil +potential join points. Note [Unfoldings and rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2209,10 +2328,7 @@ occAnal env app@(App _ _) = occAnalApp env (collectArgsTicks tickishFloatable app) occAnal env expr@(Lam {}) - = let (WithUsageDetails usage expr') = occAnalLam env expr - final_usage = markAllInsideLamIf (not (isOneShotFun expr')) $ - markAllNonTail usage - in WithUsageDetails final_usage expr' + = adjustNonRecRhs Nothing $ occAnalLamTail env expr -- mb_join_arity == Nothing <=> markAllManyNonTail occAnal env (Case scrut bndr ty alts) = let @@ -2287,7 +2403,7 @@ occAnalApp !env (Var fun, args, ticks) -- This caused #18296 | fun `hasKey` runRWKey , [t1, t2, arg] <- args - , let (WithUsageDetails usage arg') = occAnalRhs env NonRecursive (Just 1) arg + , WithUsageDetails usage arg' <- adjustNonRecRhs (Just 1) $ occAnalLamTail env arg = WithUsageDetails usage (mkTicks ticks $ mkApps (Var fun) [t1, t2, arg']) occAnalApp env (Var fun_id, args, ticks) @@ -2872,7 +2988,6 @@ lookupBndrSwap env@(OccEnv { occ_bs_env = bs_env }) bndr case lookupBndrSwap env bndr1 of (fun, fun_id) -> (mkCastMCo fun mco, fun_id) } - {- Historical note [Proxy let-bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We used to do the binder-swap transformation by introducing @@ -2998,6 +3113,19 @@ data UsageDetails instance Outputable UsageDetails where ppr ud = ppr (ud_env (flattenUsageDetails ud)) +-- | Captures the result of applying 'occAnalLamTail' to a function `\xyz.body`. +-- The TailUsageDetails records +-- * the number of lambdas (including type lambdas: a JoinArity) +-- * UsageDetails for the `body`, unadjusted by `adjustTailUsage`. +-- If the binding turns out to be a join point with the indicated join +-- arity, this unadjusted usage details is just what we need; otherwise we +-- need to discard tail calls. That's what `adjustTailUsage` does. +data TailUsageDetails = TUD !JoinArity !UsageDetails + +instance Outputable TailUsageDetails where + ppr (TUD ja uds) = lambda <> ppr ja <> ppr uds + + ------------------- -- UsageDetails API @@ -3139,24 +3267,49 @@ flattenUsageDetails ud@(UD { ud_env = env }) ------------------- -- See Note [Adjusting right-hand sides] -adjustRhsUsage :: Maybe JoinArity - -> CoreExpr -- Rhs, AFTER occ anal - -> UsageDetails -- From body of lambda +adjustTailUsage :: Maybe JoinArity + -> CoreExpr -- Rhs, AFTER occAnalLamTail + -> TailUsageDetails -- From body of lambda -> UsageDetails -adjustRhsUsage mb_join_arity rhs usage +adjustTailUsage mb_join_arity rhs (TUD rhs_ja usage) = -- c.f. occAnal (Lam {}) markAllInsideLamIf (not one_shot) $ markAllNonTailIf (not exact_join) $ usage where one_shot = isOneShotFun rhs - exact_join = exactJoin mb_join_arity bndrs - (bndrs,_) = collectBinders rhs + exact_join = mb_join_arity == Just rhs_ja + +adjustTailArity :: Maybe JoinArity -> TailUsageDetails -> UsageDetails +adjustTailArity mb_rhs_ja (TUD ud_ja usage) = + markAllNonTailIf (mb_rhs_ja /= Just ud_ja) usage + +markNonRecJoinOneShots :: JoinArity -> CoreExpr -> CoreExpr +-- For a /non-recursive/ join point we can mark all +-- its join-lambda as one-shot; and it's a good idea to do so +markNonRecJoinOneShots join_arity rhs + = go join_arity rhs + where + go 0 rhs = rhs + go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) + (go (n-1) rhs) + go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. + -- e.g. let j = case ... in j True + -- This will become an arity-1 join point after the + -- simplifier has eta-expanded it; but it may not have + -- enough lambdas /yet/. (Lint checks that JoinIds do + -- have enough lambdas.) -exactJoin :: Maybe JoinArity -> [a] -> Bool -exactJoin Nothing _ = False -exactJoin (Just join_arity) args = args `lengthIs` join_arity - -- Remember join_arity includes type binders +markNonRecUnfoldingOneShots :: Maybe JoinArity -> Unfolding -> Unfolding +-- ^ Apply 'markNonRecJoinOneShots' to a stable unfolding +markNonRecUnfoldingOneShots mb_join_arity unf + | Just ja <- mb_join_arity + , CoreUnfolding{uf_src=src,uf_tmpl=tmpl} <- unf + , isStableSource src + , let !tmpl' = markNonRecJoinOneShots ja tmpl + = unf{uf_tmpl=tmpl'} + | otherwise + = unf type IdWithOccInfo = Id @@ -3192,8 +3345,8 @@ tagLamBinder usage bndr tagNonRecBinder :: TopLevelFlag -- At top level? -> UsageDetails -- Of scope -> CoreBndr -- Binder - -> (UsageDetails, -- Details with binder removed - IdWithOccInfo) -- Tagged binder + -> WithUsageDetails -- Details with binder removed + IdWithOccInfo -- Tagged binder tagNonRecBinder lvl usage binder = let @@ -3205,37 +3358,34 @@ tagNonRecBinder lvl usage binder binder' = setBinderOcc occ' binder usage' = usage `delDetails` binder in - usage' `seq` (usage', binder') + WithUsageDetails usage' binder' tagRecBinders :: TopLevelFlag -- At top level? -> UsageDetails -- Of body of let ONLY - -> [Details] - -> (UsageDetails, -- Adjusted details for whole scope, + -> [NodeDetails] + -> WithUsageDetails -- Adjusted details for whole scope, -- with binders removed - [IdWithOccInfo]) -- Tagged binders + [IdWithOccInfo] -- Tagged binders -- Substantially more complicated than non-recursive case. Need to adjust RHS -- details *before* tagging binders (because the tags depend on the RHSes). tagRecBinders lvl body_uds details_s = let bndrs = map nd_bndr details_s - rhs_udss = map nd_uds details_s - -- 1. Determine join-point-hood of whole group, as determined by - -- the *unadjusted* usage details - unadj_uds = foldr andUDs body_uds rhs_udss + -- 1. See Note [Join arity prediction based on joinRhsArity] + -- Determine possible join-point-hood of whole group, by testing for + -- manifest join arity M. + -- This (re-)asserts that makeNode had made tuds for that same arity M! + unadj_uds = foldr (andUDs . test_manifest_arity) body_uds details_s + test_manifest_arity ND{nd_rhs=WithTailUsageDetails tuds rhs} + = adjustTailArity (Just (joinRhsArity rhs)) tuds - -- This is only used in `mb_join_arity`, to adjust each `Details` in `details_s`, thus, - -- when `bndrs` is non-empty. So, we only write `maybe False` as `decideJoinPointHood` - -- takes a `NonEmpty CoreBndr`; the default value `False` won't affect program behavior. - will_be_joins = maybe False (decideJoinPointHood lvl unadj_uds) (nonEmpty bndrs) - - -- 2. Adjust usage details of each RHS, taking into account the - -- join-point-hood decision - rhs_udss' = [ adjustRhsUsage (mb_join_arity bndr) rhs rhs_uds - | ND { nd_bndr = bndr, nd_uds = rhs_uds - , nd_rhs = rhs } <- details_s ] + bndr_ne = expectNonEmpty "List of binders is never empty" bndrs + will_be_joins = decideJoinPointHood lvl unadj_uds bndr_ne mb_join_arity :: Id -> Maybe JoinArity + -- mb_join_arity: See Note [Join arity prediction based on joinRhsArity] + -- This is the source O mb_join_arity bndr -- Can't use willBeJoinId_maybe here because we haven't tagged -- the binder yet (the tag depends on these adjustments!) @@ -3247,6 +3397,12 @@ tagRecBinders lvl body_uds details_s = assert (not will_be_joins) -- Should be AlwaysTailCalled if Nothing -- we are making join points! + -- 2. Adjust usage details of each RHS, taking into account the + -- join-point-hood decision + rhs_udss' = [ adjustTailUsage (mb_join_arity bndr) rhs rhs_tuds -- matching occAnalLamTail in makeNode + | ND { nd_bndr = bndr, nd_rhs = WithTailUsageDetails rhs_tuds rhs } + <- details_s ] + -- 3. Compute final usage details from adjusted RHS details adj_uds = foldr andUDs body_uds rhs_udss' @@ -3257,7 +3413,7 @@ tagRecBinders lvl body_uds details_s -- 5. Drop the binders from the adjusted details and return usage' = adj_uds `delDetailsList` bndrs in - (usage', bndrs') + WithUsageDetails usage' bndrs' setBinderOcc :: OccInfo -> CoreBndr -> CoreBndr setBinderOcc occ_info bndr @@ -3271,12 +3427,13 @@ setBinderOcc occ_info bndr | otherwise = setIdOccInfo bndr occ_info --- | Decide whether some bindings should be made into join points or not. +-- | Decide whether some bindings should be made into join points or not, based +-- on its occurrences. This is -- Returns `False` if they can't be join points. Note that it's an -- all-or-nothing decision, as if multiple binders are given, they're -- assumed to be mutually recursive. -- --- It must, however, be a final decision. If we say "True" for 'f', +-- It must, however, be a final decision. If we say `True` for 'f', -- and then subsequently decide /not/ make 'f' into a join point, then -- the decision about another binding 'g' might be invalidated if (say) -- 'f' tail-calls 'g'. ===================================== compiler/GHC/Data/Graph/Directed.hs ===================================== @@ -4,6 +4,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE DeriveFunctor #-} module GHC.Data.Graph.Directed ( Graph, graphFromEdgedVerticesOrd, graphFromEdgedVerticesUniq, @@ -108,7 +109,7 @@ data Node key payload = DigraphNode { node_payload :: payload, -- ^ User data node_key :: key, -- ^ User defined node id node_dependencies :: [key] -- ^ Dependencies/successors of the node - } + } deriving Functor instance (Outputable a, Outputable b) => Outputable (Node a b) where ===================================== compiler/GHC/Utils/Misc.hs ===================================== @@ -35,7 +35,7 @@ module GHC.Utils.Misc ( equalLength, compareLength, leLength, ltLength, isSingleton, only, expectOnly, GHC.Utils.Misc.singleton, - notNull, snocView, + notNull, expectNonEmpty, snocView, chunkList, @@ -481,7 +481,6 @@ expectOnly _ (a:_) = a #endif expectOnly msg _ = panic ("expectOnly: " ++ msg) - -- | Split a list into chunks of /n/ elements chunkList :: Int -> [a] -> [[a]] chunkList _ [] = [] @@ -500,6 +499,16 @@ changeLast [] _ = panic "changeLast" changeLast [_] x = [x] changeLast (x:xs) x' = x : changeLast xs x' +-- | Like @expectJust msg . nonEmpty@; a better alternative to 'NE.fromList'. +expectNonEmpty :: HasCallStack => String -> [a] -> NonEmpty a +{-# INLINE expectNonEmpty #-} +expectNonEmpty _ (x:xs) = x:|xs +expectNonEmpty msg [] = expectNonEmptyPanic msg + +expectNonEmptyPanic :: String -> a +expectNonEmptyPanic msg = panic ("expectNonEmpty: " ++ msg) +{-# NOINLINE expectNonEmptyPanic #-} + -- | Apply an effectful function to the last list element. mapLastM :: Functor f => (a -> f a) -> NonEmpty a -> f (NonEmpty a) mapLastM f (x:|[]) = NE.singleton <$> f x ===================================== testsuite/tests/simplCore/should_compile/T22428.hs ===================================== @@ -0,0 +1,9 @@ +module T22428 where + +f :: Integer -> Integer -> Integer +f x y = go y + where + go :: Integer -> Integer + go 0 = x + go n = go (n-1) + {-# INLINE go #-} ===================================== testsuite/tests/simplCore/should_compile/T22428.stderr ===================================== @@ -0,0 +1,45 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 32, types: 14, coercions: 0, joins: 1/1} + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22428.f1 :: Integer +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22428.f1 = GHC.Num.Integer.IS 1# + +-- RHS size: {terms: 28, types: 10, coercions: 0, joins: 1/1} +f :: Integer -> Integer -> Integer +[GblId, + Arity=2, + Str=<1L>, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 0] 156 0}] +f = \ (x :: Integer) (y :: Integer) -> + joinrec { + go [InlPrag=INLINE (sat-args=1), Occ=LoopBreaker, Dmd=SC(S,L)] + :: Integer -> Integer + [LclId[JoinId(1)(Just [!])], + Arity=1, + Str=<1L>, + Unf=Unf{Src=StableUser, TopLvl=False, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=False,boring_ok=False)}] + go (ds :: Integer) + = case ds of wild { + GHC.Num.Integer.IS x1 -> + case x1 of { + __DEFAULT -> jump go (GHC.Num.Integer.integerSub wild T22428.f1); + 0# -> x + }; + GHC.Num.Integer.IP x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1); + GHC.Num.Integer.IN x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1) + }; } in + jump go y + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -451,6 +451,7 @@ test('T22375', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeab # One module, T21851_2.hs, has OPTIONS_GHC -ddump-simpl # Expecting to see $s$wwombat 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']) @@ -462,3 +463,6 @@ test('T22272', normal, multimod_compile, ['T22272', '-O -fexpose-all-unfoldings test('T22459', normal, compile, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) test('T22662', normal, compile, ['']) + +# go should become a join point +test('T22428', [grep_errmsg(r'jump go') ], compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeable-binds -dsuppress-unfoldings']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/506cd44c25e9cebb5bd9fff1cd9ebea3a44a71f2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/506cd44c25e9cebb5bd9fff1cd9ebea3a44a71f2 You're receiving 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 Jan 10 14:31:05 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Tue, 10 Jan 2023 09:31:05 -0500 Subject: [Git][ghc/ghc] Deleted branch wip/remove-rts-configure-hack Message-ID: <63bd76a9f1f7d_3b1bf95260c510638@gitlab.mail> John Ericson deleted branch wip/remove-rts-configure-hack at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Jan 10 15:03:10 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Tue, 10 Jan 2023 10:03:10 -0500 Subject: [Git][ghc/ghc][wip/int-index/type-abs-flag] Introduce the TypeAbstractions language flag Message-ID: <63bd7e2ec7f9b_3b1bf959e705321cf@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/type-abs-flag at Glasgow Haskell Compiler / GHC Commits: 690fbf53 by Vladislav Zavialov at 2023-01-10T18:02:54+03:00 Introduce the TypeAbstractions language flag GHC Proposals #448 "Modern scoped type variables" and #425 "Invisible binders in type declarations" introduce a new language extension flag: TypeAbstractions. Part of the functionality guarded by this flag has already been implemented, namely type abstractions in constructor patterns, but it was guarded by a combination of TypeApplications and ScopedTypeVariables instead of a dedicated language extension flag. This patch does the following: * introduces a new language extension flag TypeAbstractions * requires TypeAbstractions for @a-syntax in constructor patterns instead of TypeApplications and ScopedTypeVariables * creates a User's Guide page for TypeAbstractions and moves the "Type Applications in Patterns" section there To avoid a breaking change, the new flag is implied by ScopedTypeVariables and is retroactively added to GHC2021. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 18 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Rename/Pat.hs - docs/users_guide/exts/gadt.rst - + docs/users_guide/exts/type_abstractions.rst - docs/users_guide/exts/type_applications.rst - docs/users_guide/exts/types.rst - libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs - testsuite/tests/driver/T4437.hs - testsuite/tests/showIface/DocsInHiFile1.stdout - testsuite/tests/showIface/DocsInHiFileTH.stdout - testsuite/tests/showIface/HaddockIssue849.stdout - testsuite/tests/showIface/HaddockOpts.stdout - testsuite/tests/showIface/MagicHashInHaddocks.stdout - testsuite/tests/showIface/NoExportList.stdout - testsuite/tests/showIface/PragmaDocs.stdout - testsuite/tests/showIface/ReExports.stdout - testsuite/tests/typecheck/should_compile/T20443a.hs - testsuite/tests/typecheck/should_fail/T19109.stderr Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -1412,6 +1412,7 @@ languageExtensions (Just GHC2021) LangExt.PostfixOperators, LangExt.RankNTypes, LangExt.ScopedTypeVariables, + LangExt.TypeAbstractions, -- implied by ScopedTypeVariables according to GHC Proposal #448 "Modern Scoped Type Variables" LangExt.StandaloneDeriving, LangExt.StandaloneKindSignatures, LangExt.TupleSections, @@ -3765,6 +3766,7 @@ xFlagsDeps = [ flagSpec "TraditionalRecordSyntax" LangExt.TraditionalRecordSyntax, flagSpec "TransformListComp" LangExt.TransformListComp, flagSpec "TupleSections" LangExt.TupleSections, + flagSpec "TypeAbstractions" LangExt.TypeAbstractions, flagSpec "TypeApplications" LangExt.TypeApplications, flagSpec "TypeData" LangExt.TypeData, depFlagSpec' "TypeInType" LangExt.TypeInType @@ -3901,6 +3903,9 @@ impliedXFlags , (LangExt.MultiParamTypeClasses, turnOn, LangExt.ConstrainedClassMethods) -- c.f. #7854 , (LangExt.TypeFamilyDependencies, turnOn, LangExt.TypeFamilies) + -- In accordance with GHC Proposal #448 "Modern Scoped Type Variables" + , (LangExt.ScopedTypeVariables, turnOn, LangExt.TypeAbstractions) + , (LangExt.RebindableSyntax, turnOff, LangExt.ImplicitPrelude) -- NB: turn off! , (LangExt.DerivingVia, turnOn, LangExt.DerivingStrategies) ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -640,16 +640,14 @@ rnConPatAndThen mk con (PrefixCon tyargs pats) where check_lang_exts :: RnM () check_lang_exts = do - scoped_tyvars <- xoptM LangExt.ScopedTypeVariables - type_app <- xoptM LangExt.TypeApplications - unless (scoped_tyvars && type_app) $ + type_abs <- xoptM LangExt.TypeAbstractions + unless type_abs $ case listToMaybe tyargs of Nothing -> pure () Just tyarg -> addErr $ mkTcRnUnknownMessage $ mkPlainError noHints $ hang (text "Illegal visible type application in a pattern:" <+> quotes (ppr tyarg)) - 2 (text "Both ScopedTypeVariables and TypeApplications are" - <+> text "required to use this feature") + 2 (text "Perhaps you intended to use TypeAbstractions") rnConPatTyArg (HsConPatTyArg at t) = do t' <- liftCpsWithCont $ rnHsPatSigTypeBindingVars HsTypeCtx t return (HsConPatTyArg at t') ===================================== docs/users_guide/exts/gadt.rst ===================================== @@ -227,7 +227,7 @@ also sets :extension:`GADTSyntax` and :extension:`MonoLocalBinds`. case f of (_ :: F (Maybe z) (Maybe z)) -> Nothing @z - Another way is to use :ref:`type-applications-in-patterns` instead of a + Another way is to use :ref:`type-abstractions-in-patterns` instead of a pattern type signature: :: g4 :: F a a -> a ===================================== docs/users_guide/exts/type_abstractions.rst ===================================== @@ -0,0 +1,95 @@ +Type abstractions +================= + +.. extension:: TypeAbstractions + :shortdesc: Enable type abstraction syntax in patterns and type variable binders. + + :since: 9.6.1 + + :status: Partially implemented + + Allow the use of type abstraction syntax. + +The :extension:`TypeAbstractions` extension provides a way to explicitly bind +scoped type or kind variables using the ``@a`` syntax. The feature is only +partially implemented, and this text covers only the implemented parts, whereas +the full specification can be found in GHC Proposals `#448 `__ +and `#425 `__. + + +.. _type-abstractions-in-patterns: + +Type Abstractions in Patterns +----------------------------- + +The type abstraction syntax can be used in patterns that match a data +constructor. The syntax can't be used with record patterns or infix patterns. +This is useful in particular to bind existential type variables associated with +a GADT data constructor as in the following example:: + + {-# LANGUAGE AllowAmbiguousTypes #-} + {-# LANGUAGE GADTs #-} + {-# LANGUAGE RankNTypes #-} + {-# LANGUAGE TypeApplications #-} + import Data.Proxy + + data Foo where + Foo :: forall a. (Show a, Num a) => Foo + + test :: Foo -> String + test x = case x of + Foo @t -> show @t 0 + + main :: IO () + main = print $ test (Foo @Float) + +In this example, the case in ``test``` is binding an existential variable introduced +by ``Foo`` that otherwise could not be named and used. + +It's possible to bind variables to any part of the type arguments to a constructor; +there is no need for them to be existential. In addition, it's possible to "match" against +part of the type argument using type constructors. + +For a somewhat-contrived example:: + + foo :: (Num a) => Maybe [a] -> String + foo (Nothing @[t]) = show (0 :: t) + foo (Just @[t] xs) = show (sum xs :: t) + +Here, we're binding the type variable t to be the type of the elements of the list type +which is itself the argument to Maybe. + +The order of the type arguments specified by the type applications in a pattern is the same +as that for an expression: either the order as given by the user in an explicit ``forall`` in the +definition of the data constructor, or if that is not present, the order in which the type +variables appear in its type signature from left to right. + +For example if we have the following declaration in GADT syntax:: + + data Foo :: * -> * where + A :: forall s t. [(t,s)] -> Foo (t,s) + B :: (t,s) -> Foo (t,s) + +Then the type arguments to ``A`` will match first ``s`` and then ``t``, while the type arguments +to ``B`` will match first ``t`` and then ``s``. + +Type arguments appearing in patterns can influence the inferred type of a definition:: + + foo (Nothing @Int) = 0 + foo (Just x) = x + +will have inferred type:: + + foo :: Maybe Int -> Int + +which is more restricted than what it would be without the application:: + + foo :: Num a => Maybe a -> a + +For more information and detail regarding type applications in patterns, see the paper +`Type variables in patterns `__ by Eisenberg, Breitner +and Peyton Jones. Relative to that paper, the implementation in GHC for now at least makes one +additional conservative restriction, that type variables occurring in patterns must not +already be in scope, and so are always new variables that only bind whatever type is +matched, rather than ever referring to a variable from an outer scope. Type wildcards +``_`` may be used in any place where no new variable needs binding. ===================================== docs/users_guide/exts/type_applications.rst ===================================== @@ -4,7 +4,7 @@ Visible type application ======================== .. extension:: TypeApplications - :shortdesc: Enable type application syntax in terms, patterns and types. + :shortdesc: Enable type application syntax in terms and types. :since: 8.0.1 @@ -261,81 +261,4 @@ of equality over types. For example, given the following definitions: :: app2 g x = g x GHC will deem all of ``app1 id1``, ``app1 id2``, ``app2 id1``, and ``app2 id2`` -to be well typed. - -.. _type-applications-in-patterns: - -Type Applications in Patterns ------------------------------ - -The type application syntax can be used in patterns that match a data -constructor. The syntax can't be used with record patterns or infix patterns. -This is useful in particular to bind existential type variables associated with -a GADT data constructor as in the following example:: - - {-# LANGUAGE AllowAmbiguousTypes #-} - {-# LANGUAGE GADTs #-} - {-# LANGUAGE RankNTypes #-} - {-# LANGUAGE TypeApplications #-} - import Data.Proxy - - data Foo where - Foo :: forall a. (Show a, Num a) => Foo - - test :: Foo -> String - test x = case x of - Foo @t -> show @t 0 - - main :: IO () - main = print $ test (Foo @Float) - -In this example, the case in ``test``` is binding an existential variable introduced -by ``Foo`` that otherwise could not be named and used. - -It's possible to bind variables to any part of the type arguments to a constructor; -there is no need for them to be existential. In addition, it's possible to "match" against -part of the type argument using type constructors. - -For a somewhat-contrived example:: - - foo :: (Num a) => Maybe [a] -> String - foo (Nothing @[t]) = show (0 :: t) - foo (Just @[t] xs) = show (sum xs :: t) - -Here, we're binding the type variable t to be the type of the elements of the list type -which is itself the argument to Maybe. - -The order of the type arguments specified by the type applications in a pattern is the same -as that for an expression: either the order as given by the user in an explicit ``forall`` in the -definition of the data constructor, or if that is not present, the order in which the type -variables appear in its type signature from left to right. - -For example if we have the following declaration in GADT syntax:: - - data Foo :: * -> * where - A :: forall s t. [(t,s)] -> Foo (t,s) - B :: (t,s) -> Foo (t,s) - -Then the type arguments to ``A`` will match first ``s`` and then ``t``, while the type arguments -to ``B`` will match first ``t`` and then ``s``. - -Type arguments appearing in patterns can influence the inferred type of a definition:: - - foo (Nothing @Int) = 0 - foo (Just x) = x - -will have inferred type:: - - foo :: Maybe Int -> Int - -which is more restricted than what it would be without the application:: - - foo :: Num a => Maybe a -> a - -For more information and detail regarding type applications in patterns, see the paper -`Type variables in patterns `__ by Eisenberg, Breitner -and Peyton Jones. Relative to that paper, the implementation in GHC for now at least makes one -additional conservative restriction, that type variables occurring in patterns must not -already be in scope, and so are always new variables that only bind whatever type is -matched, rather than ever referring to a variable from an outer scope. Type wildcards -``_`` may be used in any place where no new variable needs binding. +to be well typed. \ No newline at end of file ===================================== docs/users_guide/exts/types.rst ===================================== @@ -21,6 +21,7 @@ Types representation_polymorphism type_literals type_applications + type_abstractions rank_polymorphism impredicative_types linear_types ===================================== libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs ===================================== @@ -151,6 +151,7 @@ data Extension | FieldSelectors | OverloadedRecordDot | OverloadedRecordUpdate + | TypeAbstractions deriving (Eq, Enum, Show, Generic, Bounded) -- 'Ord' and 'Bounded' are provided for GHC API users (see discussions -- in https://gitlab.haskell.org/ghc/ghc/merge_requests/2707 and ===================================== testsuite/tests/driver/T4437.hs ===================================== @@ -37,7 +37,7 @@ check title expected got -- See Note [Adding a language extension] in compiler/GHC/Driver/Session.hs. expectedGhcOnlyExtensions :: [String] expectedGhcOnlyExtensions = - [ + [ "TypeAbstractions" ] expectedCabalOnlyExtensions :: [String] ===================================== testsuite/tests/showIface/DocsInHiFile1.stdout ===================================== @@ -143,5 +143,6 @@ docs: ImportQualifiedPost StandaloneKindSignatures FieldSelectors + TypeAbstractions extensible fields: ===================================== testsuite/tests/showIface/DocsInHiFileTH.stdout ===================================== @@ -286,5 +286,6 @@ docs: ImportQualifiedPost StandaloneKindSignatures FieldSelectors + TypeAbstractions extensible fields: ===================================== testsuite/tests/showIface/HaddockIssue849.stdout ===================================== @@ -66,5 +66,6 @@ docs: ImportQualifiedPost StandaloneKindSignatures FieldSelectors + TypeAbstractions extensible fields: ===================================== testsuite/tests/showIface/HaddockOpts.stdout ===================================== @@ -58,5 +58,6 @@ docs: ImportQualifiedPost StandaloneKindSignatures FieldSelectors + TypeAbstractions extensible fields: ===================================== testsuite/tests/showIface/MagicHashInHaddocks.stdout ===================================== @@ -68,5 +68,6 @@ docs: ImportQualifiedPost StandaloneKindSignatures FieldSelectors + TypeAbstractions extensible fields: ===================================== testsuite/tests/showIface/NoExportList.stdout ===================================== @@ -94,5 +94,6 @@ docs: ImportQualifiedPost StandaloneKindSignatures FieldSelectors + TypeAbstractions extensible fields: ===================================== testsuite/tests/showIface/PragmaDocs.stdout ===================================== @@ -68,5 +68,6 @@ docs: ImportQualifiedPost StandaloneKindSignatures FieldSelectors + TypeAbstractions extensible fields: ===================================== testsuite/tests/showIface/ReExports.stdout ===================================== @@ -65,5 +65,6 @@ docs: ImportQualifiedPost StandaloneKindSignatures FieldSelectors + TypeAbstractions extensible fields: ===================================== testsuite/tests/typecheck/should_compile/T20443a.hs ===================================== @@ -10,4 +10,4 @@ a :: () -> Proxy Int a () = Proxy @Int b :: Proxy Int -> () -b (Proxy @Int) = () -- This should compile, but doesn't +b (Proxy @Int) = () ===================================== testsuite/tests/typecheck/should_fail/T19109.stderr ===================================== @@ -1,4 +1,4 @@ T19109.hs:6:4: error: Illegal visible type application in a pattern: ‘@Int’ - Both ScopedTypeVariables and TypeApplications are required to use this feature + Perhaps you intended to use TypeAbstractions View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/690fbf53cca771eec58f3a345df7c33dd7f63314 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/690fbf53cca771eec58f3a345df7c33dd7f63314 You're receiving 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 Jan 10 15:24:36 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 10 Jan 2023 10:24:36 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: m4/fp_leading_underscore.m4: Avoid implicit exit function declaration Message-ID: <63bd833491a7_3b1bf91d2c59a85382e1@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 480b5d64 by Florian Weimer at 2023-01-10T08:03:53+00:00 m4/fp_leading_underscore.m4: Avoid implicit exit function declaration And switch to a new-style function definition. Fixes build issues with compilers that do not accept implicit function declarations. - - - - - 2cfbc97a by HaskellMouse at 2023-01-10T10:24:28-05:00 Added a new warning about compatibility with RequiredTypeArguments This commit introduces a new warning that indicates code incompatible with future extension: RequiredTypeArguments. Enabling this extension may break some code and the warning will help to make it compatible in advance. - - - - - 30 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Types/Name/Reader.hs - docs/users_guide/9.6.1-notes.rst - docs/users_guide/using-warnings.rst - m4/fp_leading_underscore.m4 - + testsuite/tests/rename/should_compile/T22513a.hs - + testsuite/tests/rename/should_compile/T22513a.stderr - + testsuite/tests/rename/should_compile/T22513b.hs - + testsuite/tests/rename/should_compile/T22513b.stderr - + testsuite/tests/rename/should_compile/T22513c.hs - + testsuite/tests/rename/should_compile/T22513c.stderr - + testsuite/tests/rename/should_compile/T22513d.hs - + testsuite/tests/rename/should_compile/T22513d.stderr - + testsuite/tests/rename/should_compile/T22513e.hs - + testsuite/tests/rename/should_compile/T22513e.stderr - + testsuite/tests/rename/should_compile/T22513f.hs - + testsuite/tests/rename/should_compile/T22513f.stderr - + testsuite/tests/rename/should_compile/T22513g.hs - + testsuite/tests/rename/should_compile/T22513g.stderr - + testsuite/tests/rename/should_compile/T22513h.hs - + testsuite/tests/rename/should_compile/T22513h.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/146a145835f5c2e82da4dd0bcb90702460505a01...2cfbc97a95949c7f3e4a5097f5e38bf02def6ef5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/146a145835f5c2e82da4dd0bcb90702460505a01...2cfbc97a95949c7f3e4a5097f5e38bf02def6ef5 You're receiving 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 Jan 10 16:10:17 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 10 Jan 2023 11:10:17 -0500 Subject: [Git][ghc/ghc][ghc-9.6] ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Message-ID: <63bd8de9ea12e_3b1bf93c57d8c5523f8@gitlab.mail> Matthew Pickering pushed to branch ghc-9.6 at Glasgow Haskell Compiler / GHC Commits: da3f7b74 by Matthew Pickering at 2023-01-10T16:08:50+00:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 (cherry picked from commit c306d939d2e1b08cbe683bb9829a4b4010948010) - - - - - 4 changed files: - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/ci.sh ===================================== @@ -213,10 +213,14 @@ function set_toolchain_paths() { x86_64-darwin|aarch64-darwin) ;; *) fail "unknown NIX_SYSTEM" ;; esac - nix build -f .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh + info "Building toolchain for $NIX_SYSTEM" + nix-build .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh cat toolchain.sh fi - source toolchain.sh ;; + source toolchain.sh + info "--info for GHC for $NIX_SYSTEM" + $GHC --info + ;; env) # These are generally set by the Docker image but # we provide these handy fallbacks in case the @@ -320,7 +324,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 = [ @@ -38,6 +38,21 @@ let ]; buildPhase = "true"; + # This is a horrible hack because the configure script invokes /usr/bin/clang + # without a `--target` flag. Then depending on whether the `nix` binary itself is + # a native x86 or arm64 binary means that /usr/bin/clang thinks it needs to run in + # x86 or arm64 mode. + + # The correct answer for the check in question is the first one we try, so by replacing + # the condition to true; we select the right C++ standard library still. + preConfigure = '' + sed "s/\"\$CC\" -o actest actest.o \''${1} 2>\/dev\/null/true/i" configure > configure.new + mv configure.new configure + chmod +x configure + cat configure + + ''; + # N.B. Work around #20253. nativeBuildInputs = [ pkgs.gnused ]; postInstallPhase = '' ===================================== .gitlab/gen_ci.hs ===================================== @@ -349,8 +349,8 @@ 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" - , "CABAL_INSTALL_VERSION" =: "3.6.2.0" + , "GHC_VERSION" =: "9.4.3" + , "CABAL_INSTALL_VERSION" =: "3.8.1.0" ] opsysVariables _ (Linux distro) = distroVariables distro opsysVariables AArch64 (Darwin {}) = @@ -378,8 +378,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 ===================================== @@ -477,9 +477,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.6.2.0", + "CABAL_INSTALL_VERSION": "3.8.1.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", @@ -2048,9 +2048,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-release", "BUILD_FLAVOUR": "release", - "CABAL_INSTALL_VERSION": "3.6.2.0", + "CABAL_INSTALL_VERSION": "3.8.1.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+no_split_sections", "BUILD_FLAVOUR": "release+no_split_sections", - "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+no_split_sections", "BUILD_FLAVOUR": "release+no_split_sections", - "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", @@ -2968,9 +2968,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.6.2.0", + "CABAL_INSTALL_VERSION": "3.8.1.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/da3f7b74dae7075a290aa07c5dfbef44905fc003 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/da3f7b74dae7075a290aa07c5dfbef44905fc003 You're receiving 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 Jan 10 16:48:23 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 10 Jan 2023 11:48:23 -0500 Subject: [Git][ghc/ghc][ghc-9.6] darwin ci: Explicitly pass desired build triple to configure Message-ID: <63bd96d7aea72_3b1bf93fcc9905787ac@gitlab.mail> Matthew Pickering pushed to branch ghc-9.6 at Glasgow Haskell Compiler / GHC Commits: 079b443b by Matthew Pickering at 2023-01-10T16:47:59+00:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. (cherry picked from commit 0db496ff1e372b19429fee91a4a569f7021fe1d7) - - - - - 1 changed file: - .gitlab/darwin/toolchain.nix Changes: ===================================== .gitlab/darwin/toolchain.nix ===================================== @@ -113,6 +113,6 @@ pkgs.writeTextFile { export CABAL="$CABAL_INSTALL" sdk_path="$(xcrun --sdk macosx --show-sdk-path)" - export CONFIGURE_ARGS="$CONFIGURE_ARGS --with-ffi-libraries=$sdk_path/usr/lib --with-ffi-includes=$sdk_path/usr/include/ffi" + export CONFIGURE_ARGS="$CONFIGURE_ARGS --with-ffi-libraries=$sdk_path/usr/lib --with-ffi-includes=$sdk_path/usr/include/ffi --build=${targetTriple}" ''; } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/079b443bf94cf5c9eadc0ae75045605758fbc889 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/079b443bf94cf5c9eadc0ae75045605758fbc889 You're receiving 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 Jan 10 17:49:33 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Tue, 10 Jan 2023 12:49:33 -0500 Subject: [Git][ghc/ghc][wip/specialize-hdoc] 9 commits: Remove RTS hack for configuring Message-ID: <63bda52db6915_3b1bf956324604789@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/specialize-hdoc at Glasgow Haskell Compiler / GHC Commits: 5d65773e by John Ericson at 2023-01-09T20:39:27-05:00 Remove RTS hack for configuring See the brand new Note [Undefined symbols in the RTS] for additional details. - - - - - e3fff751 by Sebastian Graf at 2023-01-09T20:40:02-05:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - d53f6f4d by Oleg Grenrus at 2023-01-09T21:11:02-05:00 Add safe list indexing operator: !? With Joachim's amendments. Implements https://github.com/haskell/core-libraries-committee/issues/110 - - - - - cfaf1ad7 by Nicolas Trangez at 2023-01-09T21:11:03-05:00 rts, tests: limit thread name length to 15 bytes On Linux, `pthread_setname_np` (or rather, the kernel) only allows for thread names up to 16 bytes, including the terminating null byte. This commit adds a note pointing this out in `createOSThread`, and fixes up two instances where a thread name of more than 15 characters long was used (in the RTS, and in a test-case). Fixes: #22366 Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796 - - - - - 64286132 by Matthew Pickering at 2023-01-09T21:11:03-05:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 4724e8d1 by Matthew Pickering at 2023-01-09T21:11:04-05:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. This completes the fix for #22429 - - - - - 2e926b88 by Georgi Lyubenov at 2023-01-09T21:11:07-05:00 Fix outdated link to Happy section on sequences - - - - - 146a1458 by Matthew Pickering at 2023-01-09T21:11:07-05:00 Revert "NCG(x86): Compile add+shift as lea if possible." This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a. See #22666 and #21777 - - - - - 0d68f927 by Krzysztof Gogolewski at 2023-01-10T18:49:15+01:00 Add 'docWithStyle' to improve codegen This new combiator docWithStyle :: IsOutput doc => doc -> (PprStyle -> SDoc) -> doc let us remove the need for code to be polymorphic in HDoc when not used in code style. Metric Decrease: ManyConstructors T13035 T1969 - - - - - 24 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Parser.y - compiler/GHC/Types/CostCentre.hs - compiler/GHC/Types/Name.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Unit/Types.hs - compiler/GHC/Utils/Outputable.hs - configure.ac - distrib/configure.ac.in - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Rules/Register.hs - libraries/base/Data/List.hs - libraries/base/Data/OldList.hs - libraries/base/GHC/List.hs - libraries/base/changelog.md - m4/ghc_llvm_target.m4 - rts/posix/OSThreads.c - rts/rts.cabal.in - rts/sm/NonMoving.c - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.asm - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.hs - testsuite/tests/codeGen/should_gen_asm/all.T - testsuite/tests/rts/pause-resume/pause_resume.c Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -1048,29 +1048,10 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps -------------------- add_code :: Width -> CmmExpr -> CmmExpr -> NatM Register - -- x + imm add_code rep x (CmmLit (CmmInt y _)) | is32BitInteger y , rep /= W8 -- LEA doesn't support byte size (#18614) = add_int rep x y - -- x + (y << imm) - add_code rep x y - -- Byte size is not supported and 16bit size is slow when computed via LEA - | rep /= W8 && rep /= W16 - -- 2^3 = 8 is the highest multiplicator supported by LEA. - , Just (x,y,shift_bits) <- get_shift x y - = add_shiftL rep x y (fromIntegral shift_bits) - where - -- x + (y << imm) - get_shift x (CmmMachOp (MO_Shl _w) [y, CmmLit (CmmInt shift_bits _)]) - | shift_bits <= 3 - = Just (x, y, shift_bits) - -- (y << imm) + x - get_shift (CmmMachOp (MO_Shl _w) [y, CmmLit (CmmInt shift_bits _)]) x - | shift_bits <= 3 - = Just (x, y, shift_bits) - get_shift _ _ - = Nothing add_code rep x y = trivialCode rep (ADD format) (Just (ADD format)) x y where format = intFormat rep -- TODO: There are other interesting patterns we want to replace @@ -1085,7 +1066,6 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps sub_code rep x y = trivialCode rep (SUB (intFormat rep)) Nothing x y -- our three-operand add instruction: - add_int :: (Width -> CmmExpr -> Integer -> NatM Register) add_int width x y = do (x_reg, x_code) <- getSomeReg x let @@ -1099,22 +1079,6 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps -- return (Any format code) - -- x + (y << shift_bits) using LEA - add_shiftL :: (Width -> CmmExpr -> CmmExpr -> Int -> NatM Register) - add_shiftL width x y shift_bits = do - (x_reg, x_code) <- getSomeReg x - (y_reg, y_code) <- getSomeReg y - let - format = intFormat width - imm = ImmInt 0 - code dst - = (x_code `appOL` y_code) `snocOL` - LEA format - (OpAddr (AddrBaseIndex (EABaseReg x_reg) (EAIndex y_reg (2 ^ shift_bits)) imm)) - (OpReg dst) - -- - return (Any format code) - ---------------------- -- See Note [DIV/IDIV for bytes] ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -333,7 +333,8 @@ dmdAnalBindLetUp :: TopLevelFlag -> WithDmdType (DmdResult CoreBind a) dmdAnalBindLetUp top_lvl env id rhs anal_body = WithDmdType final_ty (R (NonRec id' rhs') (body')) where - WithDmdType body_ty body' = anal_body env + WithDmdType body_ty body' = anal_body (addInScopeAnalEnv env id) + -- See Note [Bringing a new variable into scope] WithDmdType body_ty' id_dmd = findBndrDmd env body_ty id -- See Note [Finalising boxity for demand signatures] @@ -473,7 +474,8 @@ dmdAnal' env dmd (App fun arg) dmdAnal' env dmd (Lam var body) | isTyVar var = let - WithDmdType body_ty body' = dmdAnal env dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) dmd body + -- See Note [Bringing a new variable into scope] in WithDmdType body_ty (Lam var body') @@ -481,7 +483,8 @@ dmdAnal' env dmd (Lam var body) = let (n, body_dmd) = peelCallDmd dmd -- body_dmd: a demand to analyze the body - WithDmdType body_ty body' = dmdAnal env body_dmd body + WithDmdType body_ty body' = dmdAnal (addInScopeAnalEnv env var) body_dmd body + -- See Note [Bringing a new variable into scope] WithDmdType lam_ty var' = annotateLamIdBndr env body_ty var new_dmd_type = multDmdType n lam_ty in @@ -493,7 +496,9 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt_con bndrs rhs]) -- can consider its field demands when analysing the scrutinee. | want_precise_field_dmds alt_con = let - WithDmdType rhs_ty rhs' = dmdAnal env dmd rhs + rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + WithDmdType rhs_ty rhs' = dmdAnal rhs_env dmd rhs WithDmdType alt_ty1 fld_dmds = findBndrsDmds env rhs_ty bndrs WithDmdType alt_ty2 case_bndr_dmd = findBndrDmd env alt_ty1 case_bndr !case_bndr' = setIdDemandInfo case_bndr case_bndr_dmd @@ -629,7 +634,9 @@ dmdAnalSumAlts env dmd case_bndr (alt:alts) dmdAnalSumAlt :: AnalEnv -> SubDemand -> Id -> CoreAlt -> WithDmdType CoreAlt dmdAnalSumAlt env dmd case_bndr (Alt con bndrs rhs) - | WithDmdType rhs_ty rhs' <- dmdAnal env dmd rhs + | let rhs_env = addInScopeAnalEnvs env (case_bndr:bndrs) + -- See Note [Bringing a new variable into scope] + , WithDmdType rhs_ty rhs' <- dmdAnal rhs_env dmd rhs , WithDmdType alt_ty dmds <- findBndrsDmds env rhs_ty bndrs , let (_ :* case_bndr_sd) = findIdDemand alt_ty case_bndr -- See Note [Demand on case-alternative binders] @@ -2399,7 +2406,7 @@ enterDFun bind env emptySigEnv :: SigEnv emptySigEnv = emptyVarEnv --- | Extend an environment with the strictness IDs attached to the id +-- | Extend an environment with the strictness sigs attached to the Ids extendAnalEnvs :: TopLevelFlag -> AnalEnv -> [Id] -> AnalEnv extendAnalEnvs top_lvl env vars = env { ae_sigs = extendSigEnvs top_lvl (ae_sigs env) vars } @@ -2418,6 +2425,12 @@ extendSigEnv top_lvl sigs var sig = extendVarEnv sigs var (sig, top_lvl) lookupSigEnv :: AnalEnv -> Id -> Maybe (DmdSig, TopLevelFlag) lookupSigEnv env id = lookupVarEnv (ae_sigs env) id +addInScopeAnalEnv :: AnalEnv -> Var -> AnalEnv +addInScopeAnalEnv env id = env { ae_sigs = delVarEnv (ae_sigs env) id } + +addInScopeAnalEnvs :: AnalEnv -> [Var] -> AnalEnv +addInScopeAnalEnvs env ids = env { ae_sigs = delVarEnvList (ae_sigs env) ids } + nonVirgin :: AnalEnv -> AnalEnv nonVirgin env = env { ae_virgin = False } @@ -2456,7 +2469,18 @@ findBndrDmd env dmd_ty id fam_envs = ae_fam_envs env -{- Note [Making dictionary parameters strict] +{- Note [Bringing a new variable into scope] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + f x = blah + g = ...(\f. ...f...)... + +In the body of the '\f', any occurrence of `f` refers to the lambda-bound `f`, +not the top-level `f` (which will be in `ae_sigs`). So it's very important +to delete `f` from `ae_sigs` when we pass a lambda/case/let-up binding of `f`. +Otherwise chaos results (#22718). + +Note [Making dictionary parameters strict] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? ===================================== compiler/GHC/Parser.y ===================================== @@ -540,8 +540,9 @@ importdecls This might seem like an awfully roundabout way to declare a list; plus, to add insult to injury you have to reverse the results at the end. The answer is that left recursion prevents us from running out of stack space when parsing long -sequences. See: https://www.haskell.org/happy/doc/html/sec-sequences.html for -more guidance. +sequences. See: +https://haskell-happy.readthedocs.io/en/latest/using.html#parsing-sequences +for more guidance. By adding/removing branches, you can affect what lists are accepted. Here are the most common patterns, rewritten as regular expressions for clarity: ===================================== compiler/GHC/Types/CostCentre.hs ===================================== @@ -265,10 +265,8 @@ instance Outputable CostCentre where ppr = pprCostCentre pprCostCentre :: IsLine doc => CostCentre -> doc -pprCostCentre cc = docWithContext $ \ sty -> - if codeStyle (sdocStyle sty) - then ppCostCentreLbl cc - else ftext (costCentreUserNameFS cc) +pprCostCentre cc = docWithStyle (ppCostCentreLbl cc) + (\_ -> ftext (costCentreUserNameFS cc)) {-# SPECIALISE pprCostCentre :: CostCentre -> SDoc #-} {-# SPECIALISE pprCostCentre :: CostCentre -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable ===================================== compiler/GHC/Types/Name.hs ===================================== @@ -627,21 +627,30 @@ instance OutputableBndr Name where pprName :: forall doc. IsLine doc => Name -> doc pprName name@(Name {n_sort = sort, n_uniq = uniq, n_occ = occ}) - = docWithContext $ \ctx -> - let sty = sdocStyle ctx - debug = sdocPprDebug ctx - listTuplePuns = sdocListTuplePuns ctx - in handlePuns listTuplePuns (namePun_maybe name) $ - case sort of - WiredIn mod _ builtin -> pprExternal debug sty uniq mod occ True builtin - External mod -> pprExternal debug sty uniq mod occ False UserSyntax - System -> pprSystem debug sty uniq occ - Internal -> pprInternal debug sty uniq occ + = docWithStyle codeDoc normalDoc where - -- Print GHC.Types.List as [], etc. - handlePuns :: Bool -> Maybe FastString -> doc -> doc - handlePuns True (Just pun) _ = ftext pun - handlePuns _ _ r = r + codeDoc = case sort of + WiredIn mod _ _ -> pprModule mod <> char '_' <> ppr_z_occ_name occ + External mod -> pprModule mod <> char '_' <> ppr_z_occ_name occ + -- In code style, always qualify + -- ToDo: maybe we could print all wired-in things unqualified + -- in code style, to reduce symbol table bloat? + System -> pprUniqueAlways uniq + Internal -> pprUniqueAlways uniq + + normalDoc sty = + getPprDebug $ \debug -> + sdocOption sdocListTuplePuns $ \listTuplePuns -> + handlePuns listTuplePuns (namePun_maybe name) $ + case sort of + WiredIn mod _ builtin -> pprExternal debug sty uniq mod occ True builtin + External mod -> pprExternal debug sty uniq mod occ False UserSyntax + System -> pprSystem debug sty uniq occ + Internal -> pprInternal debug sty uniq occ + + handlePuns :: Bool -> Maybe FastString -> SDoc -> SDoc + handlePuns True (Just pun) _ = ftext pun + handlePuns _ _ r = r {-# SPECIALISE pprName :: Name -> SDoc #-} {-# SPECIALISE pprName :: Name -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable @@ -674,12 +683,8 @@ pprTickyName this_mod name pprNameUnqualified :: Name -> SDoc pprNameUnqualified Name { n_occ = occ } = ppr_occ_name occ -pprExternal :: IsLine doc => Bool -> PprStyle -> Unique -> Module -> OccName -> Bool -> BuiltInSyntax -> doc +pprExternal :: Bool -> PprStyle -> Unique -> Module -> OccName -> Bool -> BuiltInSyntax -> SDoc pprExternal debug sty uniq mod occ is_wired is_builtin - | codeStyle sty = pprModule mod <> char '_' <> ppr_z_occ_name occ - -- In code style, always qualify - -- ToDo: maybe we could print all wired-in things unqualified - -- in code style, to reduce symbol table bloat? | debug = pp_mod <> ppr_occ_name occ <> braces (hsep [if is_wired then text "(w)" else empty, pprNameSpaceBrief (occNameSpace occ), @@ -695,9 +700,8 @@ pprExternal debug sty uniq mod occ is_wired is_builtin pp_mod = ppUnlessOption sdocSuppressModulePrefixes (pprModule mod <> dot) -pprInternal :: IsLine doc => Bool -> PprStyle -> Unique -> OccName -> doc +pprInternal :: Bool -> PprStyle -> Unique -> OccName -> SDoc pprInternal debug sty uniq occ - | codeStyle sty = pprUniqueAlways uniq | debug = ppr_occ_name occ <> braces (hsep [pprNameSpaceBrief (occNameSpace occ), pprUnique uniq]) | dumpStyle sty = ppr_occ_name occ <> ppr_underscore_unique uniq @@ -706,9 +710,8 @@ pprInternal debug sty uniq occ | otherwise = ppr_occ_name occ -- User style -- Like Internal, except that we only omit the unique in Iface style -pprSystem :: IsLine doc => Bool -> PprStyle -> Unique -> OccName -> doc -pprSystem debug sty uniq occ - | codeStyle sty = pprUniqueAlways uniq +pprSystem :: Bool -> PprStyle -> Unique -> OccName -> SDoc +pprSystem debug _sty uniq occ | debug = ppr_occ_name occ <> ppr_underscore_unique uniq <> braces (pprNameSpaceBrief (occNameSpace occ)) | otherwise = ppr_occ_name occ <> ppr_underscore_unique uniq @@ -717,7 +720,7 @@ pprSystem debug sty uniq occ -- so print the unique -pprModulePrefix :: IsLine doc => PprStyle -> Module -> OccName -> doc +pprModulePrefix :: PprStyle -> Module -> OccName -> SDoc -- Print the "M." part of a name, based on whether it's in scope or not -- See Note [Printing original names] in GHC.Types.Name.Ppr pprModulePrefix sty mod occ = ppUnlessOption sdocSuppressModulePrefixes $ @@ -728,20 +731,20 @@ pprModulePrefix sty mod occ = ppUnlessOption sdocSuppressModulePrefixes $ <> pprModuleName (moduleName mod) <> dot -- scope either NameUnqual -> empty -- In scope unqualified -pprUnique :: IsLine doc => Unique -> doc +pprUnique :: Unique -> SDoc -- Print a unique unless we are suppressing them pprUnique uniq = ppUnlessOption sdocSuppressUniques $ pprUniqueAlways uniq -ppr_underscore_unique :: IsLine doc => Unique -> doc +ppr_underscore_unique :: Unique -> SDoc -- Print an underscore separating the name from its unique -- But suppress it if we aren't printing the uniques anyway ppr_underscore_unique uniq = ppUnlessOption sdocSuppressUniques $ char '_' <> pprUniqueAlways uniq -ppr_occ_name :: IsLine doc => OccName -> doc +ppr_occ_name :: OccName -> SDoc ppr_occ_name occ = ftext (occNameFS occ) -- Don't use pprOccName; instead, just print the string of the OccName; -- we print the namespace in the debug stuff above ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -200,7 +200,7 @@ pprNonVarNameSpace :: NameSpace -> SDoc pprNonVarNameSpace VarName = empty pprNonVarNameSpace ns = pprNameSpace ns -pprNameSpaceBrief :: IsLine doc => NameSpace -> doc +pprNameSpaceBrief :: NameSpace -> SDoc pprNameSpaceBrief DataName = char 'd' pprNameSpaceBrief VarName = char 'v' pprNameSpaceBrief TvName = text "tv" @@ -278,10 +278,9 @@ instance OutputableBndr OccName where pprOccName :: IsLine doc => OccName -> doc pprOccName (OccName sp occ) - = docWithContext $ \ sty -> - if codeStyle (sdocStyle sty) - then ztext (zEncodeFS occ) - else ftext occ <> whenPprDebug (braces (pprNameSpaceBrief sp)) + = docWithStyle (ztext (zEncodeFS occ)) (\_ -> ftext occ <> whenPprDebug (braces (pprNameSpaceBrief sp))) +{-# SPECIALIZE pprOccName :: OccName -> SDoc #-} +{-# SPECIALIZE pprOccName :: OccName -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable {- ************************************************************************ ===================================== compiler/GHC/Unit/Types.hs ===================================== @@ -166,7 +166,7 @@ instance Outputable InstantiatedModule where instance Outputable InstantiatedUnit where ppr = pprInstantiatedUnit -pprInstantiatedUnit :: IsLine doc => InstantiatedUnit -> doc +pprInstantiatedUnit :: InstantiatedUnit -> SDoc pprInstantiatedUnit uid = -- getPprStyle $ \sty -> pprUnitId cid <> @@ -180,8 +180,6 @@ pprInstantiatedUnit uid = where cid = instUnitInstanceOf uid insts = instUnitInsts uid -{-# SPECIALIZE pprInstantiatedUnit :: InstantiatedUnit -> SDoc #-} -{-# SPECIALIZE pprInstantiatedUnit :: InstantiatedUnit -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable -- | Class for types that are used as unit identifiers (UnitKey, UnitId, Unit) -- @@ -203,14 +201,13 @@ instance IsUnitId u => IsUnitId (GenUnit u) where unitFS HoleUnit = holeFS pprModule :: IsLine doc => Module -> doc -pprModule mod@(Module p n) = docWithContext (doc . sdocStyle) +pprModule mod@(Module p n) = docWithStyle code doc where - doc sty - | codeStyle sty = - (if p == mainUnit + code = (if p == mainUnit then empty -- never qualify the main package in code else ztext (zEncodeFS (unitFS p)) <> char '_') <> pprModuleName n + doc sty | qualModule sty mod = case p of HoleUnit -> angleBrackets (pprModuleName n) @@ -352,12 +349,10 @@ stableUnitCmp p1 p2 = unitFS p1 `lexicalCompareFS` unitFS p2 instance Outputable Unit where ppr pk = pprUnit pk -pprUnit :: IsLine doc => Unit -> doc +pprUnit :: Unit -> SDoc pprUnit (RealUnit (Definite d)) = pprUnitId d pprUnit (VirtUnit uid) = pprInstantiatedUnit uid pprUnit HoleUnit = ftext holeFS -{-# SPECIALIZE pprUnit :: Unit -> SDoc #-} -{-# SPECIALIZE pprUnit :: Unit -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable instance Show Unit where show = unitString @@ -535,12 +530,8 @@ instance Uniquable UnitId where instance Outputable UnitId where ppr = pprUnitId -pprUnitId :: IsLine doc => UnitId -> doc -pprUnitId (UnitId fs) = dualLine (sdocOption sdocUnitIdForUser ($ fs)) (ftext fs) - -- see Note [Pretty-printing UnitId] in GHC.Unit - -- also see Note [dualLine and dualDoc] in GHC.Utils.Outputable -{-# SPECIALIZE pprUnitId :: UnitId -> SDoc #-} -{-# SPECIALIZE pprUnitId :: UnitId -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable +pprUnitId :: UnitId -> SDoc +pprUnitId (UnitId fs) = sdocOption sdocUnitIdForUser ($ fs) -- | A 'DefUnitId' is an 'UnitId' with the invariant that -- it only refers to a definite library; i.e., one we have generated ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -126,6 +126,8 @@ import GHC.Data.FastString import qualified GHC.Utils.Ppr as Pretty import qualified GHC.Utils.Ppr.Colour as Col import GHC.Utils.Ppr ( Doc, Mode(..) ) +import GHC.Utils.Panic.Plain (assert) +import GHC.Utils.Constants (debugIsOn) import GHC.Serialized import GHC.LanguageExtensions (Extension) import GHC.Utils.GlobalVars( unsafeHasPprDebug ) @@ -855,9 +857,10 @@ ppWhenOption f doc = sdocOption f $ \case False -> empty {-# INLINE CONLIKE ppUnlessOption #-} -ppUnlessOption :: IsLine doc => (SDocContext -> Bool) -> doc -> doc -ppUnlessOption f doc = docWithContext $ - \ctx -> if f ctx then empty else doc +ppUnlessOption :: (SDocContext -> Bool) -> SDoc -> SDoc +ppUnlessOption f doc = sdocOption f $ \case + True -> empty + False -> doc -- | Apply the given colour\/style for the argument. -- @@ -1040,10 +1043,7 @@ instance Outputable ModuleName where pprModuleName :: IsLine doc => ModuleName -> doc pprModuleName (ModuleName nm) = - docWithContext $ \ctx -> - if codeStyle (sdocStyle ctx) - then ztext (zEncodeFS nm) - else ftext nm + docWithStyle (ztext (zEncodeFS nm)) (\_ -> ftext nm) {-# SPECIALIZE pprModuleName :: ModuleName -> SDoc #-} {-# SPECIALIZE pprModuleName :: ModuleName -> HLine #-} -- see Note [SPECIALIZE to HDoc] @@ -1633,6 +1633,7 @@ IsOutput, that allows these combinators to be generic over both variants: class IsOutput doc where empty :: doc docWithContext :: (SDocContext -> doc) -> doc + docWithStyle :: doc -> (PprStyle -> SDoc) -> doc class IsOutput doc => IsLine doc class (IsOutput doc, IsLine (Line doc)) => IsDoc doc @@ -1669,13 +1670,22 @@ arguments depending on the type they are instantiated at. They serve as a difficult to make completely equivalent under both printer implementations. These operations should generally be avoided, as they can result in surprising -changes in behavior when the printer implementation is changed. However, in -certain cases, the alternative is even worse. For example, we use dualLine in -the implementation of pprUnitId, as the hack we use for printing unit ids -(see Note [Pretty-printing UnitId] in GHC.Unit) is difficult to adapt to HLine -and is not necessary for code paths that use it, anyway. - -Use these operations wisely. -} +changes in behavior when the printer implementation is changed. +Right now, they are used only when outputting debugging comments in +codegen, as it is difficult to adapt that code to use HLine and not necessary. + +Use these operations wisely. + +Note [docWithStyle] +~~~~~~~~~~~~~~~~~~~ +Sometimes when printing, we consult the printing style. This can be done +with 'docWithStyle c f'. This is similar to 'docWithContext (f . sdocStyle)', +but: +* For code style, 'docWithStyle c f' will return 'c'. +* For other styles, 'docWithStyle c f', will call 'f style', but expect + an SDoc rather than doc. This removes the need to write code polymorphic + in SDoc and HDoc, since the latter is used only for code style. +-} -- | Represents a single line of output that can be efficiently printed directly -- to a 'System.IO.Handle' (actually a 'BufHandle'). @@ -1700,7 +1710,7 @@ pattern HDoc f <- HDoc' f {-# COMPLETE HDoc #-} bPutHDoc :: BufHandle -> SDocContext -> HDoc -> IO () -bPutHDoc h ctx (HDoc f) = f ctx h +bPutHDoc h ctx (HDoc f) = assert (codeStyle (sdocStyle ctx)) (f ctx h) -- | A superclass for 'IsLine' and 'IsDoc' that provides an identity, 'empty', -- as well as access to the shared 'SDocContext'. @@ -1709,6 +1719,7 @@ bPutHDoc h ctx (HDoc f) = f ctx h class IsOutput doc where empty :: doc docWithContext :: (SDocContext -> doc) -> doc + docWithStyle :: doc -> (PprStyle -> SDoc) -> doc -- see Note [docWithStyle] -- | A class of types that represent a single logical line of text, with support -- for horizontal composition. @@ -1779,6 +1790,11 @@ instance IsOutput SDoc where {-# INLINE CONLIKE empty #-} docWithContext = sdocWithContext {-# INLINE docWithContext #-} + docWithStyle c f = sdocWithContext (\ctx -> let sty = sdocStyle ctx + in if codeStyle sty then c + else f sty) + -- see Note [docWithStyle] + {-# INLINE CONLIKE docWithStyle #-} instance IsLine SDoc where char c = docToSDoc $ Pretty.char c @@ -1823,12 +1839,18 @@ instance IsOutput HLine where {-# INLINE empty #-} docWithContext f = HLine $ \ctx h -> runHLine (f ctx) ctx h {-# INLINE CONLIKE docWithContext #-} + docWithStyle c@(HLine c') _ | debugIsOn = HLine $ \ctx h -> assert (codeStyle (sdocStyle ctx)) (c' ctx h) + | otherwise = c -- see Note [docWithStyle] + {-# INLINE CONLIKE docWithStyle #-} instance IsOutput HDoc where empty = HDoc (\_ _ -> pure ()) {-# INLINE empty #-} docWithContext f = HDoc $ \ctx h -> runHDoc (f ctx) ctx h {-# INLINE CONLIKE docWithContext #-} + docWithStyle c@(HDoc c') _ | debugIsOn = HDoc $ \ctx h -> assert (codeStyle (sdocStyle ctx)) (c' ctx h) + | otherwise = c -- see Note [docWithStyle] + {-# INLINE CONLIKE docWithStyle #-} instance IsLine HLine where char c = HLine (\_ h -> bPutChar h c) ===================================== configure.ac ===================================== @@ -667,6 +667,8 @@ GHC_LLVM_TARGET_SET_VAR # we intend to pass trough --targets to llvm as is. LLVMTarget_CPP=` echo "$LlvmTarget"` AC_SUBST(LLVMTarget_CPP) +# The target is substituted into the distrib/configure.ac file +AC_SUBST(LlvmTarget) dnl ** See whether cc supports --target= and set dnl CONF_CC_OPTS_STAGE[012] accordingly. ===================================== distrib/configure.ac.in ===================================== @@ -18,6 +18,8 @@ dnl-------------------------------------------------------------------- dnl Various things from the source distribution configure bootstrap_target=@TargetPlatform@ +bootstrap_llvm_target=@LlvmTarget@ + TargetHasRTSLinker=@TargetHasRTSLinker@ AC_SUBST(TargetHasRTSLinker) @@ -169,6 +171,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG # Stage 3 won't be supported by cross-compilation FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) +FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) +FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + AC_SUBST(CONF_CC_OPTS_STAGE0) AC_SUBST(CONF_CC_OPTS_STAGE1) AC_SUBST(CONF_CC_OPTS_STAGE2) ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -148,6 +148,8 @@ configurePackage context at Context {..} = do -- Figure out what hooks we need. hooks <- case C.buildType (C.flattenPackageDescription gpd) of C.Configure -> pure C.autoconfUserHooks + C.Simple -> pure C.simpleUserHooks + C.Make -> fail "build-type: Make is not supported" -- The 'time' package has a 'C.Custom' Setup.hs, but it's actually -- 'C.Configure' plus a @./Setup test@ hook. However, Cabal is also -- 'C.Custom', but doesn't have a configure script. @@ -155,12 +157,6 @@ configurePackage context at Context {..} = do configureExists <- doesFileExist $ replaceFileName (pkgCabalFile package) "configure" pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks - -- Not quite right, but good enough for us: - _ | package == rts -> - -- Don't try to do post configuration validation for 'rts'. This - -- will simply not work, due to the @ld-options@ and @Stg.h at . - pure $ C.simpleUserHooks { C.postConf = \_ _ _ _ -> return () } - | otherwise -> pure C.simpleUserHooks -- Compute the list of flags, and the Cabal configuration arguments flavourArgs <- args <$> flavour ===================================== hadrian/src/Rules/Register.hs ===================================== @@ -45,6 +45,14 @@ configurePackageRules = do isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend when isGmp $ need [buildP -/- "include/ghc-gmp.h"] + when (pkg == rts) $ do + -- Rts.h is a header listed in the cabal file, and configuring + -- therefore wants to ensure that the header "works" post-configure. + -- But it (transitively) includes these, so we must ensure they exist + -- for that check to work. + need [ buildP -/- "include/ghcautoconf.h" + , buildP -/- "include/ghcplatform.h" + ] Cabal.configurePackage ctx root -/- "**/autogen/cabal_macros.h" %> \out -> do ===================================== libraries/base/Data/List.hs ===================================== @@ -127,6 +127,7 @@ module Data.List -- | These functions treat a list @xs@ as a indexed collection, -- with indices ranging from 0 to @'length' xs - 1 at . + , (!?) , (!!) , elemIndex ===================================== libraries/base/Data/OldList.hs ===================================== @@ -127,6 +127,7 @@ module Data.OldList -- | These functions treat a list @xs@ as a indexed collection, -- with indices ranging from 0 to @'length' xs - 1 at . + , (!?) , (!!) , elemIndex ===================================== libraries/base/GHC/List.hs ===================================== @@ -31,7 +31,7 @@ module GHC.List ( -- Other functions foldl1', concat, concatMap, map, (++), filter, lookup, - head, last, tail, init, uncons, (!!), + head, last, tail, init, uncons, (!?), (!!), scanl, scanl1, scanl', scanr, scanr1, iterate, iterate', repeat, replicate, cycle, take, drop, splitAt, takeWhile, dropWhile, span, break, reverse, @@ -49,7 +49,7 @@ import GHC.Num (Num(..)) import GHC.Num.Integer (Integer) import GHC.Stack.Types (HasCallStack) -infixl 9 !! +infixl 9 !?, !! infix 4 `elem`, `notElem` -- $setup @@ -1370,9 +1370,10 @@ concat = foldr (++) [] -- >>> ['a', 'b', 'c'] !! (-1) -- *** Exception: Prelude.!!: negative index -- --- WARNING: This function is partial. You can use --- --- instead. +-- WARNING: This function is partial, and should only be used if you are +-- sure that the indexing will not fail. Otherwise, use 'Data.List.!?'. +-- +-- WARNING: This function takes linear time in the index. #if defined(USE_REPORT_PRELUDE) (!!) :: [a] -> Int -> a xs !! n | n < 0 = errorWithoutStackTrace "Prelude.!!: negative index" @@ -1401,6 +1402,30 @@ xs !! n _ -> r (k-1)) tooLarge xs n #endif +-- | List index (subscript) operator, starting from 0. Returns 'Nothing' +-- if the index is out of bounds +-- +-- >>> ['a', 'b', 'c'] !? 0 +-- Just 'a' +-- >>> ['a', 'b', 'c'] !? 2 +-- Just 'c' +-- >>> ['a', 'b', 'c'] !? 3 +-- Nothing +-- >>> ['a', 'b', 'c'] !? (-1) +-- Nothing +-- +-- This is the total variant of the partial '!!' operator. +-- +-- WARNING: This function takes linear time in the index. +(!?) :: [a] -> Int -> Maybe a + +{-# INLINABLE (!?) #-} +xs !? n + | n < 0 = Nothing + | otherwise = foldr (\x r k -> case k of + 0 -> Just x + _ -> r (k-1)) (const Nothing) xs n + -------------------------------------------------------------- -- The zip family -------------------------------------------------------------- ===================================== libraries/base/changelog.md ===================================== @@ -58,6 +58,8 @@ 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`. + * Add `Data.List.!?` per + [CLC proposal #110](https://github.com/haskell/core-libraries-committee/issues/110). ## 4.17.0.0 *August 2022* ===================================== m4/ghc_llvm_target.m4 ===================================== @@ -50,5 +50,10 @@ AC_DEFUN([GHC_LLVM_TARGET], [ # require it. AC_DEFUN([GHC_LLVM_TARGET_SET_VAR], [ AC_REQUIRE([FPTOOLS_SET_PLATFORMS_VARS]) - GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + if test "$bootstrap_llvm_target" != "" + then + LlvmTarget=$bootstrap_llvm_target + else + GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + fi ]) ===================================== rts/posix/OSThreads.c ===================================== @@ -218,6 +218,12 @@ start_thread (void *param) return startProc(startParam); } +/* Note: at least on Linux/Glibc, `pthread_setname_np` restricts the name of + * a thread to 16 bytes, including the terminating null byte. Hence, make sure + * to only pass in names of up to 15 characters. Otherwise, + * `pthread_setname_np` when called in `start_thread` will fail with `ERANGE`, + * which is not checked for, and the thread won't be named at all. + */ int createOSThread (OSThreadId* pId, const char *name, OSThreadProc *startProc, void *param) ===================================== rts/rts.cabal.in ===================================== @@ -275,6 +275,8 @@ library stg/SMP.h stg/Ticky.h stg/Types.h + + -- See Note [Undefined symbols in the RTS] if flag(64bit) if flag(leading-underscore) ld-options: @@ -474,6 +476,8 @@ library ld-options: "-Wl,-search_paths_first" -- See Note [fd_set_overflow] "-Wl,-U,___darwin_check_fd_set_overflow" + -- See Note [Undefined symbols in the RTS] + "-Wl,-undefined,dynamic_lookup" if !arch(x86_64) && !arch(aarch64) ld-options: -read_only_relocs warning @@ -714,3 +718,35 @@ library -- , https://github.com/sitsofe/fio/commit/b6a1e63a1ff607692a3caf3c2db2c3d575ba2320 -- The issue was originally reported in #19950 + + +-- Note [Undefined symbols in the RTS] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- The RTS is built with a number of `-u` flags. This is to handle cyclic +-- dependencies between the RTS and other libraries which we normally think of as +-- downstream from the RTS. "Regular" dependencies from usages in those libraries +-- to definitions in the RTS are handled normally. "Reverse" dependencies from +-- usages in the RTS to definitions in those libraries get the `-u` flag in the +-- RTS. +-- +-- The symbols are specified literally, but follow C ABI conventions (as all 3 of +-- C, C--, and Haskell do currently). Thus, we have to be careful to include a +-- leading underscore or not based on those conventions for the given platform in +-- question. +-- +-- A tricky part is that different linkers have different policies regarding +-- undefined symbols (not defined in the current binary, or found in a shared +-- library that could be loaded at run time). GNU Binutils' linker is fine with +-- undefined symbols by default, but Apple's "cctools" linker is not. To appease +-- that linker we either need to do a blanket `-undefined dynamic_lookup` or +-- whitelist each such symbol with an additional `-U` (see the man page for more +-- details). +-- +-- GHC already does `-undefined dynamic_lookup`, so we just do that for now, but +-- we might try to get more precise with `-U` in the future. +-- +-- Note that the RTS also `-u`s some atomics symbols that *are* defined --- and +-- defined within the RTS! It is not immediately clear why this is needed. This +-- dates back to c06e3f46d24ef69f3a3d794f5f604cb8c2a40cbc which mentions a build +-- failure that it was suggested that this fix, but the precise reasoning is not +-- explained. ===================================== rts/sm/NonMoving.c ===================================== @@ -1015,7 +1015,7 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) nonmoving_write_barrier_enabled = true; debugTrace(DEBUG_nonmoving_gc, "Starting concurrent mark thread"); OSThreadId thread; - if (createOSThread(&thread, "non-moving mark thread", + if (createOSThread(&thread, "nonmoving-mark", nonmovingConcurrentMark, mark_queue) != 0) { barf("nonmovingCollect: failed to spawn mark thread: %s", strerror(errno)); } ===================================== testsuite/tests/codeGen/should_gen_asm/AddMulX86.asm deleted ===================================== @@ -1,46 +0,0 @@ -.section .text -.align 8 -.align 8 - .quad 8589934604 - .quad 0 - .long 14 - .long 0 -.globl AddMulX86_f_info -.type AddMulX86_f_info, @function -AddMulX86_f_info: -.LcAx: - leaq (%r14,%rsi,8),%rbx - jmp *(%rbp) - .size AddMulX86_f_info, .-AddMulX86_f_info -.section .data -.align 8 -.align 1 -.globl AddMulX86_f_closure -.type AddMulX86_f_closure, @object -AddMulX86_f_closure: - .quad AddMulX86_f_info -.section .text -.align 8 -.align 8 - .quad 8589934604 - .quad 0 - .long 14 - .long 0 -.globl AddMulX86_g_info -.type AddMulX86_g_info, @function -AddMulX86_g_info: -.LcAL: - leaq (%r14,%rsi,8),%rbx - jmp *(%rbp) - .size AddMulX86_g_info, .-AddMulX86_g_info -.section .data -.align 8 -.align 1 -.globl AddMulX86_g_closure -.type AddMulX86_g_closure, @object -AddMulX86_g_closure: - .quad AddMulX86_g_info -.section .note.GNU-stack,"", at progbits -.ident "GHC 9.3.20220228" - - ===================================== testsuite/tests/codeGen/should_gen_asm/AddMulX86.hs deleted ===================================== @@ -1,12 +0,0 @@ -{-# LANGUAGE MagicHash #-} - -module AddMulX86 where - -import GHC.Exts - -f :: Int# -> Int# -> Int# -f x y = - x +# (y *# 8#) -- Should result in a lea instruction, which we grep the assembly output for. - -g x y = - (y *# 8#) +# x -- Should result in a lea instruction, which we grep the assembly output for. ===================================== testsuite/tests/codeGen/should_gen_asm/all.T ===================================== @@ -10,4 +10,3 @@ test('memset-unroll', is_amd64_codegen, compile_cmp_asm, ['cmm', '']) test('bytearray-memset-unroll', is_amd64_codegen, compile_grep_asm, ['hs', True, '']) test('bytearray-memcpy-unroll', is_amd64_codegen, compile_grep_asm, ['hs', True, '']) test('T18137', [when(opsys('darwin'), skip), only_ways(llvm_ways)], compile_grep_asm, ['hs', False, '-fllvm -split-sections']) -test('AddMulX86', is_amd64_codegen, compile_cmp_asm, ['hs', '-dno-typeable-binds']) ===================================== testsuite/tests/rts/pause-resume/pause_resume.c ===================================== @@ -187,7 +187,7 @@ void pauseAndResumeViaThread ) { OSThreadId threadId; - createOSThread(&threadId, "Pause and resume thread", &pauseAndResumeViaThread_helper, (void *)count); + createOSThread(&threadId, "pause-resume", &pauseAndResumeViaThread_helper, (void *)count); } const int TIMEOUT = 1000000; // 1 second View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d270e2408713763d0784b4f028174bbe09412320...0d68f927438e7fbeb7fbb725e0a2e42f8e66729d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d270e2408713763d0784b4f028174bbe09412320...0d68f927438e7fbeb7fbb725e0a2e42f8e66729d You're receiving 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 Jan 10 18:13:41 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Tue, 10 Jan 2023 13:13:41 -0500 Subject: [Git][ghc/ghc][wip/specialize-hdoc] Add 'docWithStyle' to improve codegen Message-ID: <63bdaad594c1b_3b1bf91d2c59a860543e@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/specialize-hdoc at Glasgow Haskell Compiler / GHC Commits: 3725adb1 by Krzysztof Gogolewski at 2023-01-10T19:13:28+01:00 Add 'docWithStyle' to improve codegen This new combinator docWithStyle :: IsOutput doc => doc -> (PprStyle -> SDoc) -> doc let us remove the need for code to be polymorphic in HDoc when not used in code style. Metric Decrease: ManyConstructors T13035 T1969 - - - - - 5 changed files: - compiler/GHC/Types/CostCentre.hs - compiler/GHC/Types/Name.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Unit/Types.hs - compiler/GHC/Utils/Outputable.hs Changes: ===================================== compiler/GHC/Types/CostCentre.hs ===================================== @@ -265,10 +265,8 @@ instance Outputable CostCentre where ppr = pprCostCentre pprCostCentre :: IsLine doc => CostCentre -> doc -pprCostCentre cc = docWithContext $ \ sty -> - if codeStyle (sdocStyle sty) - then ppCostCentreLbl cc - else ftext (costCentreUserNameFS cc) +pprCostCentre cc = docWithStyle (ppCostCentreLbl cc) + (\_ -> ftext (costCentreUserNameFS cc)) {-# SPECIALISE pprCostCentre :: CostCentre -> SDoc #-} {-# SPECIALISE pprCostCentre :: CostCentre -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable ===================================== compiler/GHC/Types/Name.hs ===================================== @@ -627,21 +627,30 @@ instance OutputableBndr Name where pprName :: forall doc. IsLine doc => Name -> doc pprName name@(Name {n_sort = sort, n_uniq = uniq, n_occ = occ}) - = docWithContext $ \ctx -> - let sty = sdocStyle ctx - debug = sdocPprDebug ctx - listTuplePuns = sdocListTuplePuns ctx - in handlePuns listTuplePuns (namePun_maybe name) $ - case sort of - WiredIn mod _ builtin -> pprExternal debug sty uniq mod occ True builtin - External mod -> pprExternal debug sty uniq mod occ False UserSyntax - System -> pprSystem debug sty uniq occ - Internal -> pprInternal debug sty uniq occ + = docWithStyle codeDoc normalDoc where - -- Print GHC.Types.List as [], etc. - handlePuns :: Bool -> Maybe FastString -> doc -> doc - handlePuns True (Just pun) _ = ftext pun - handlePuns _ _ r = r + codeDoc = case sort of + WiredIn mod _ _ -> pprModule mod <> char '_' <> ppr_z_occ_name occ + External mod -> pprModule mod <> char '_' <> ppr_z_occ_name occ + -- In code style, always qualify + -- ToDo: maybe we could print all wired-in things unqualified + -- in code style, to reduce symbol table bloat? + System -> pprUniqueAlways uniq + Internal -> pprUniqueAlways uniq + + normalDoc sty = + getPprDebug $ \debug -> + sdocOption sdocListTuplePuns $ \listTuplePuns -> + handlePuns listTuplePuns (namePun_maybe name) $ + case sort of + WiredIn mod _ builtin -> pprExternal debug sty uniq mod occ True builtin + External mod -> pprExternal debug sty uniq mod occ False UserSyntax + System -> pprSystem debug sty uniq occ + Internal -> pprInternal debug sty uniq occ + + handlePuns :: Bool -> Maybe FastString -> SDoc -> SDoc + handlePuns True (Just pun) _ = ftext pun + handlePuns _ _ r = r {-# SPECIALISE pprName :: Name -> SDoc #-} {-# SPECIALISE pprName :: Name -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable @@ -674,12 +683,8 @@ pprTickyName this_mod name pprNameUnqualified :: Name -> SDoc pprNameUnqualified Name { n_occ = occ } = ppr_occ_name occ -pprExternal :: IsLine doc => Bool -> PprStyle -> Unique -> Module -> OccName -> Bool -> BuiltInSyntax -> doc +pprExternal :: Bool -> PprStyle -> Unique -> Module -> OccName -> Bool -> BuiltInSyntax -> SDoc pprExternal debug sty uniq mod occ is_wired is_builtin - | codeStyle sty = pprModule mod <> char '_' <> ppr_z_occ_name occ - -- In code style, always qualify - -- ToDo: maybe we could print all wired-in things unqualified - -- in code style, to reduce symbol table bloat? | debug = pp_mod <> ppr_occ_name occ <> braces (hsep [if is_wired then text "(w)" else empty, pprNameSpaceBrief (occNameSpace occ), @@ -695,9 +700,8 @@ pprExternal debug sty uniq mod occ is_wired is_builtin pp_mod = ppUnlessOption sdocSuppressModulePrefixes (pprModule mod <> dot) -pprInternal :: IsLine doc => Bool -> PprStyle -> Unique -> OccName -> doc +pprInternal :: Bool -> PprStyle -> Unique -> OccName -> SDoc pprInternal debug sty uniq occ - | codeStyle sty = pprUniqueAlways uniq | debug = ppr_occ_name occ <> braces (hsep [pprNameSpaceBrief (occNameSpace occ), pprUnique uniq]) | dumpStyle sty = ppr_occ_name occ <> ppr_underscore_unique uniq @@ -706,9 +710,8 @@ pprInternal debug sty uniq occ | otherwise = ppr_occ_name occ -- User style -- Like Internal, except that we only omit the unique in Iface style -pprSystem :: IsLine doc => Bool -> PprStyle -> Unique -> OccName -> doc -pprSystem debug sty uniq occ - | codeStyle sty = pprUniqueAlways uniq +pprSystem :: Bool -> PprStyle -> Unique -> OccName -> SDoc +pprSystem debug _sty uniq occ | debug = ppr_occ_name occ <> ppr_underscore_unique uniq <> braces (pprNameSpaceBrief (occNameSpace occ)) | otherwise = ppr_occ_name occ <> ppr_underscore_unique uniq @@ -717,7 +720,7 @@ pprSystem debug sty uniq occ -- so print the unique -pprModulePrefix :: IsLine doc => PprStyle -> Module -> OccName -> doc +pprModulePrefix :: PprStyle -> Module -> OccName -> SDoc -- Print the "M." part of a name, based on whether it's in scope or not -- See Note [Printing original names] in GHC.Types.Name.Ppr pprModulePrefix sty mod occ = ppUnlessOption sdocSuppressModulePrefixes $ @@ -728,20 +731,20 @@ pprModulePrefix sty mod occ = ppUnlessOption sdocSuppressModulePrefixes $ <> pprModuleName (moduleName mod) <> dot -- scope either NameUnqual -> empty -- In scope unqualified -pprUnique :: IsLine doc => Unique -> doc +pprUnique :: Unique -> SDoc -- Print a unique unless we are suppressing them pprUnique uniq = ppUnlessOption sdocSuppressUniques $ pprUniqueAlways uniq -ppr_underscore_unique :: IsLine doc => Unique -> doc +ppr_underscore_unique :: Unique -> SDoc -- Print an underscore separating the name from its unique -- But suppress it if we aren't printing the uniques anyway ppr_underscore_unique uniq = ppUnlessOption sdocSuppressUniques $ char '_' <> pprUniqueAlways uniq -ppr_occ_name :: IsLine doc => OccName -> doc +ppr_occ_name :: OccName -> SDoc ppr_occ_name occ = ftext (occNameFS occ) -- Don't use pprOccName; instead, just print the string of the OccName; -- we print the namespace in the debug stuff above ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -200,7 +200,7 @@ pprNonVarNameSpace :: NameSpace -> SDoc pprNonVarNameSpace VarName = empty pprNonVarNameSpace ns = pprNameSpace ns -pprNameSpaceBrief :: IsLine doc => NameSpace -> doc +pprNameSpaceBrief :: NameSpace -> SDoc pprNameSpaceBrief DataName = char 'd' pprNameSpaceBrief VarName = char 'v' pprNameSpaceBrief TvName = text "tv" @@ -278,10 +278,9 @@ instance OutputableBndr OccName where pprOccName :: IsLine doc => OccName -> doc pprOccName (OccName sp occ) - = docWithContext $ \ sty -> - if codeStyle (sdocStyle sty) - then ztext (zEncodeFS occ) - else ftext occ <> whenPprDebug (braces (pprNameSpaceBrief sp)) + = docWithStyle (ztext (zEncodeFS occ)) (\_ -> ftext occ <> whenPprDebug (braces (pprNameSpaceBrief sp))) +{-# SPECIALIZE pprOccName :: OccName -> SDoc #-} +{-# SPECIALIZE pprOccName :: OccName -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable {- ************************************************************************ ===================================== compiler/GHC/Unit/Types.hs ===================================== @@ -166,7 +166,7 @@ instance Outputable InstantiatedModule where instance Outputable InstantiatedUnit where ppr = pprInstantiatedUnit -pprInstantiatedUnit :: IsLine doc => InstantiatedUnit -> doc +pprInstantiatedUnit :: InstantiatedUnit -> SDoc pprInstantiatedUnit uid = -- getPprStyle $ \sty -> pprUnitId cid <> @@ -180,8 +180,6 @@ pprInstantiatedUnit uid = where cid = instUnitInstanceOf uid insts = instUnitInsts uid -{-# SPECIALIZE pprInstantiatedUnit :: InstantiatedUnit -> SDoc #-} -{-# SPECIALIZE pprInstantiatedUnit :: InstantiatedUnit -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable -- | Class for types that are used as unit identifiers (UnitKey, UnitId, Unit) -- @@ -203,14 +201,13 @@ instance IsUnitId u => IsUnitId (GenUnit u) where unitFS HoleUnit = holeFS pprModule :: IsLine doc => Module -> doc -pprModule mod@(Module p n) = docWithContext (doc . sdocStyle) +pprModule mod@(Module p n) = docWithStyle code doc where - doc sty - | codeStyle sty = - (if p == mainUnit + code = (if p == mainUnit then empty -- never qualify the main package in code else ztext (zEncodeFS (unitFS p)) <> char '_') <> pprModuleName n + doc sty | qualModule sty mod = case p of HoleUnit -> angleBrackets (pprModuleName n) @@ -352,12 +349,10 @@ stableUnitCmp p1 p2 = unitFS p1 `lexicalCompareFS` unitFS p2 instance Outputable Unit where ppr pk = pprUnit pk -pprUnit :: IsLine doc => Unit -> doc +pprUnit :: Unit -> SDoc pprUnit (RealUnit (Definite d)) = pprUnitId d pprUnit (VirtUnit uid) = pprInstantiatedUnit uid pprUnit HoleUnit = ftext holeFS -{-# SPECIALIZE pprUnit :: Unit -> SDoc #-} -{-# SPECIALIZE pprUnit :: Unit -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable instance Show Unit where show = unitString @@ -535,12 +530,8 @@ instance Uniquable UnitId where instance Outputable UnitId where ppr = pprUnitId -pprUnitId :: IsLine doc => UnitId -> doc -pprUnitId (UnitId fs) = dualLine (sdocOption sdocUnitIdForUser ($ fs)) (ftext fs) - -- see Note [Pretty-printing UnitId] in GHC.Unit - -- also see Note [dualLine and dualDoc] in GHC.Utils.Outputable -{-# SPECIALIZE pprUnitId :: UnitId -> SDoc #-} -{-# SPECIALIZE pprUnitId :: UnitId -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable +pprUnitId :: UnitId -> SDoc +pprUnitId (UnitId fs) = sdocOption sdocUnitIdForUser ($ fs) -- | A 'DefUnitId' is an 'UnitId' with the invariant that -- it only refers to a definite library; i.e., one we have generated ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -126,6 +126,8 @@ import GHC.Data.FastString import qualified GHC.Utils.Ppr as Pretty import qualified GHC.Utils.Ppr.Colour as Col import GHC.Utils.Ppr ( Doc, Mode(..) ) +import GHC.Utils.Panic.Plain (assert) +import GHC.Utils.Constants (debugIsOn) import GHC.Serialized import GHC.LanguageExtensions (Extension) import GHC.Utils.GlobalVars( unsafeHasPprDebug ) @@ -855,9 +857,10 @@ ppWhenOption f doc = sdocOption f $ \case False -> empty {-# INLINE CONLIKE ppUnlessOption #-} -ppUnlessOption :: IsLine doc => (SDocContext -> Bool) -> doc -> doc -ppUnlessOption f doc = docWithContext $ - \ctx -> if f ctx then empty else doc +ppUnlessOption :: (SDocContext -> Bool) -> SDoc -> SDoc +ppUnlessOption f doc = sdocOption f $ \case + True -> empty + False -> doc -- | Apply the given colour\/style for the argument. -- @@ -1040,10 +1043,7 @@ instance Outputable ModuleName where pprModuleName :: IsLine doc => ModuleName -> doc pprModuleName (ModuleName nm) = - docWithContext $ \ctx -> - if codeStyle (sdocStyle ctx) - then ztext (zEncodeFS nm) - else ftext nm + docWithStyle (ztext (zEncodeFS nm)) (\_ -> ftext nm) {-# SPECIALIZE pprModuleName :: ModuleName -> SDoc #-} {-# SPECIALIZE pprModuleName :: ModuleName -> HLine #-} -- see Note [SPECIALIZE to HDoc] @@ -1633,6 +1633,7 @@ IsOutput, that allows these combinators to be generic over both variants: class IsOutput doc where empty :: doc docWithContext :: (SDocContext -> doc) -> doc + docWithStyle :: doc -> (PprStyle -> SDoc) -> doc class IsOutput doc => IsLine doc class (IsOutput doc, IsLine (Line doc)) => IsDoc doc @@ -1669,13 +1670,22 @@ arguments depending on the type they are instantiated at. They serve as a difficult to make completely equivalent under both printer implementations. These operations should generally be avoided, as they can result in surprising -changes in behavior when the printer implementation is changed. However, in -certain cases, the alternative is even worse. For example, we use dualLine in -the implementation of pprUnitId, as the hack we use for printing unit ids -(see Note [Pretty-printing UnitId] in GHC.Unit) is difficult to adapt to HLine -and is not necessary for code paths that use it, anyway. - -Use these operations wisely. -} +changes in behavior when the printer implementation is changed. +Right now, they are used only when outputting debugging comments in +codegen, as it is difficult to adapt that code to use HLine and not necessary. + +Use these operations wisely. + +Note [docWithStyle] +~~~~~~~~~~~~~~~~~~~ +Sometimes when printing, we consult the printing style. This can be done +with 'docWithStyle c f'. This is similar to 'docWithContext (f . sdocStyle)', +but: +* For code style, 'docWithStyle c f' will return 'c'. +* For other styles, 'docWithStyle c f', will call 'f style', but expect + an SDoc rather than doc. This removes the need to write code polymorphic + in SDoc and HDoc, since the latter is used only for code style. +-} -- | Represents a single line of output that can be efficiently printed directly -- to a 'System.IO.Handle' (actually a 'BufHandle'). @@ -1700,7 +1710,7 @@ pattern HDoc f <- HDoc' f {-# COMPLETE HDoc #-} bPutHDoc :: BufHandle -> SDocContext -> HDoc -> IO () -bPutHDoc h ctx (HDoc f) = f ctx h +bPutHDoc h ctx (HDoc f) = assert (codeStyle (sdocStyle ctx)) (f ctx h) -- | A superclass for 'IsLine' and 'IsDoc' that provides an identity, 'empty', -- as well as access to the shared 'SDocContext'. @@ -1709,6 +1719,7 @@ bPutHDoc h ctx (HDoc f) = f ctx h class IsOutput doc where empty :: doc docWithContext :: (SDocContext -> doc) -> doc + docWithStyle :: doc -> (PprStyle -> SDoc) -> doc -- see Note [docWithStyle] -- | A class of types that represent a single logical line of text, with support -- for horizontal composition. @@ -1779,6 +1790,11 @@ instance IsOutput SDoc where {-# INLINE CONLIKE empty #-} docWithContext = sdocWithContext {-# INLINE docWithContext #-} + docWithStyle c f = sdocWithContext (\ctx -> let sty = sdocStyle ctx + in if codeStyle sty then c + else f sty) + -- see Note [docWithStyle] + {-# INLINE CONLIKE docWithStyle #-} instance IsLine SDoc where char c = docToSDoc $ Pretty.char c @@ -1823,12 +1839,18 @@ instance IsOutput HLine where {-# INLINE empty #-} docWithContext f = HLine $ \ctx h -> runHLine (f ctx) ctx h {-# INLINE CONLIKE docWithContext #-} + docWithStyle (HLine c) _ = HLine $ \ctx h -> assert (codeStyle (sdocStyle ctx)) (c ctx h) + -- see Note [docWithStyle] + {-# INLINE CONLIKE docWithStyle #-} instance IsOutput HDoc where empty = HDoc (\_ _ -> pure ()) {-# INLINE empty #-} docWithContext f = HDoc $ \ctx h -> runHDoc (f ctx) ctx h {-# INLINE CONLIKE docWithContext #-} + docWithStyle (HDoc c) _ = HDoc $ \ctx h -> assert (codeStyle (sdocStyle ctx)) (c ctx h) + -- see Note [docWithStyle] + {-# INLINE CONLIKE docWithStyle #-} instance IsLine HLine where char c = HLine (\_ h -> bPutChar h c) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3725adb14c19cdffa9b2a759fe81c7daf31eee4c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3725adb14c19cdffa9b2a759fe81c7daf31eee4c You're receiving 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 Jan 10 18:41:50 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Tue, 10 Jan 2023 13:41:50 -0500 Subject: [Git][ghc/ghc][wip/rts-configure-symbols] 8 commits: Add safe list indexing operator: !? Message-ID: <63bdb16e82470_3b1bf95260c61834e@gitlab.mail> John Ericson pushed to branch wip/rts-configure-symbols at Glasgow Haskell Compiler / GHC Commits: d53f6f4d by Oleg Grenrus at 2023-01-09T21:11:02-05:00 Add safe list indexing operator: !? With Joachim's amendments. Implements https://github.com/haskell/core-libraries-committee/issues/110 - - - - - cfaf1ad7 by Nicolas Trangez at 2023-01-09T21:11:03-05:00 rts, tests: limit thread name length to 15 bytes On Linux, `pthread_setname_np` (or rather, the kernel) only allows for thread names up to 16 bytes, including the terminating null byte. This commit adds a note pointing this out in `createOSThread`, and fixes up two instances where a thread name of more than 15 characters long was used (in the RTS, and in a test-case). Fixes: #22366 Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796 - - - - - 64286132 by Matthew Pickering at 2023-01-09T21:11:03-05:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 4724e8d1 by Matthew Pickering at 2023-01-09T21:11:04-05:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. This completes the fix for #22429 - - - - - 2e926b88 by Georgi Lyubenov at 2023-01-09T21:11:07-05:00 Fix outdated link to Happy section on sequences - - - - - 146a1458 by Matthew Pickering at 2023-01-09T21:11:07-05:00 Revert "NCG(x86): Compile add+shift as lea if possible." This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a. See #22666 and #21777 - - - - - 5a763d8c by John Ericson at 2023-01-10T08:04:54+00:00 Give the RTS it's own configure script Currently it doesn't do much anything, we are just trying to introduce it without breaking the build. Later, we will move functionality from the top-level configure script over to it. We need to bump Cabal for https://github.com/haskell/cabal/pull/8649; to facilitate and existing hack of skipping some configure checks for the RTS we now need to skip just *part* not *all* of the "post configure" hook, as running the configure script (which we definitely want to do) is also implemented as part of the "post configure" hook. But doing this requires exposing functionality that wasn't exposed before. - - - - - af547008 by John Ericson at 2023-01-10T09:53:37-05:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. - - - - - 28 changed files: - boot - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Parser.y - configure.ac - distrib/configure.ac.in - hadrian/src/Base.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Lint.hs - hadrian/src/Rules/Register.hs - hadrian/src/Rules/SourceDist.hs - libraries/base/.gitignore - libraries/base/Data/List.hs - libraries/base/Data/OldList.hs - libraries/base/GHC/List.hs - libraries/base/changelog.md - m4/fp_find_libdw.m4 - m4/ghc_llvm_target.m4 - rts/.gitignore - + rts/configure.ac - + rts/external-symbols.list.in - rts/posix/OSThreads.c - + rts/rts.buildinfo.in - rts/rts.cabal.in - rts/sm/NonMoving.c - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.asm - − testsuite/tests/codeGen/should_gen_asm/AddMulX86.hs - testsuite/tests/codeGen/should_gen_asm/all.T - testsuite/tests/rts/pause-resume/pause_resume.c Changes: ===================================== boot ===================================== @@ -63,7 +63,7 @@ def autoreconf(): else: reconf_cmd = 'autoreconf' - for dir_ in ['.'] + glob.glob('libraries/*/'): + for dir_ in ['.', 'rts'] + glob.glob('libraries/*/'): if os.path.isfile(os.path.join(dir_, 'configure.ac')): print("Booting %s" % dir_) # Update config.sub in submodules ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -1048,29 +1048,10 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps -------------------- add_code :: Width -> CmmExpr -> CmmExpr -> NatM Register - -- x + imm add_code rep x (CmmLit (CmmInt y _)) | is32BitInteger y , rep /= W8 -- LEA doesn't support byte size (#18614) = add_int rep x y - -- x + (y << imm) - add_code rep x y - -- Byte size is not supported and 16bit size is slow when computed via LEA - | rep /= W8 && rep /= W16 - -- 2^3 = 8 is the highest multiplicator supported by LEA. - , Just (x,y,shift_bits) <- get_shift x y - = add_shiftL rep x y (fromIntegral shift_bits) - where - -- x + (y << imm) - get_shift x (CmmMachOp (MO_Shl _w) [y, CmmLit (CmmInt shift_bits _)]) - | shift_bits <= 3 - = Just (x, y, shift_bits) - -- (y << imm) + x - get_shift (CmmMachOp (MO_Shl _w) [y, CmmLit (CmmInt shift_bits _)]) x - | shift_bits <= 3 - = Just (x, y, shift_bits) - get_shift _ _ - = Nothing add_code rep x y = trivialCode rep (ADD format) (Just (ADD format)) x y where format = intFormat rep -- TODO: There are other interesting patterns we want to replace @@ -1085,7 +1066,6 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps sub_code rep x y = trivialCode rep (SUB (intFormat rep)) Nothing x y -- our three-operand add instruction: - add_int :: (Width -> CmmExpr -> Integer -> NatM Register) add_int width x y = do (x_reg, x_code) <- getSomeReg x let @@ -1099,22 +1079,6 @@ getRegister' _ is32Bit (CmmMachOp mop [x, y]) = -- dyadic MachOps -- return (Any format code) - -- x + (y << shift_bits) using LEA - add_shiftL :: (Width -> CmmExpr -> CmmExpr -> Int -> NatM Register) - add_shiftL width x y shift_bits = do - (x_reg, x_code) <- getSomeReg x - (y_reg, y_code) <- getSomeReg y - let - format = intFormat width - imm = ImmInt 0 - code dst - = (x_code `appOL` y_code) `snocOL` - LEA format - (OpAddr (AddrBaseIndex (EABaseReg x_reg) (EAIndex y_reg (2 ^ shift_bits)) imm)) - (OpReg dst) - -- - return (Any format code) - ---------------------- -- See Note [DIV/IDIV for bytes] ===================================== compiler/GHC/Parser.y ===================================== @@ -540,8 +540,9 @@ importdecls This might seem like an awfully roundabout way to declare a list; plus, to add insult to injury you have to reverse the results at the end. The answer is that left recursion prevents us from running out of stack space when parsing long -sequences. See: https://www.haskell.org/happy/doc/html/sec-sequences.html for -more guidance. +sequences. See: +https://haskell-happy.readthedocs.io/en/latest/using.html#parsing-sequences +for more guidance. By adding/removing branches, you can affect what lists are accepted. Here are the most common patterns, rewritten as regular expressions for clarity: ===================================== configure.ac ===================================== @@ -667,6 +667,8 @@ GHC_LLVM_TARGET_SET_VAR # we intend to pass trough --targets to llvm as is. LLVMTarget_CPP=` echo "$LlvmTarget"` AC_SUBST(LLVMTarget_CPP) +# The target is substituted into the distrib/configure.ac file +AC_SUBST(LlvmTarget) dnl ** See whether cc supports --target= and set dnl CONF_CC_OPTS_STAGE[012] accordingly. ===================================== distrib/configure.ac.in ===================================== @@ -18,6 +18,8 @@ dnl-------------------------------------------------------------------- dnl Various things from the source distribution configure bootstrap_target=@TargetPlatform@ +bootstrap_llvm_target=@LlvmTarget@ + TargetHasRTSLinker=@TargetHasRTSLinker@ AC_SUBST(TargetHasRTSLinker) @@ -169,6 +171,11 @@ FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAG # Stage 3 won't be supported by cross-compilation FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) +FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) +FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) + AC_SUBST(CONF_CC_OPTS_STAGE0) AC_SUBST(CONF_CC_OPTS_STAGE1) AC_SUBST(CONF_CC_OPTS_STAGE2) ===================================== hadrian/src/Base.hs ===================================== @@ -20,9 +20,6 @@ module Base ( module Stage, module Way, - -- * Files - configH, - -- * Paths hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, @@ -72,11 +69,6 @@ configFile = configPath -/- "system.config" sourcePath :: FilePath sourcePath = hadrianPath -/- "src" --- TODO: Change @mk/config.h@ to @shake-build/cfg/config.h at . --- | Path to the generated @mk/config.h@ file. -configH :: FilePath -configH = "mk/config.h" - -- | The directory in 'buildRoot' containing the Shake database and other -- auxiliary files generated by Hadrian. shakeFilesDir :: FilePath ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -147,7 +147,8 @@ generatePackageCode context@(Context stage pkg _ _) = do root -/- "**" -/- dir -/- "cmm/AutoApply.cmm" %> \file -> build $ target context GenApply [] [file] let go gen file = generate file (semiEmptyTarget stage) gen - root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> go generateGhcAutoconfH + root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> \_ -> + need . pure =<< pkgSetupConfigFile context root -/- "**" -/- dir -/- "include/ghcplatform.h" %> go generateGhcPlatformH root -/- "**" -/- dir -/- "include/DerivedConstants.h" %> genPlatformConstantsHeader context root -/- "**" -/- dir -/- "include/rts/EventLogConstants.h" %> genEventTypes "--event-types-defines" @@ -486,26 +487,6 @@ generateConfigHs = do stageString (Stage0 GlobalLibs) = error "stageString: StageBoot" --- | Generate @ghcautoconf.h@ header. -generateGhcAutoconfH :: Expr String -generateGhcAutoconfH = do - trackGenerateHs - configHContents <- expr $ mapMaybe undefinePackage <$> readFileLines configH - return . unlines $ - [ "#if !defined(__GHCAUTOCONF_H__)" - , "#define __GHCAUTOCONF_H__" ] - ++ configHContents ++ - [ "#endif /* __GHCAUTOCONF_H__ */" ] - where - undefinePackage s - | "#define PACKAGE_" `isPrefixOf` s - = Just $ "/* #undef " ++ takeWhile (/=' ') (drop 8 s) ++ " */" - | "#define __GLASGOW_HASKELL" `isPrefixOf` s - = Nothing - | "/* REMOVE ME */" == s - = Nothing - | otherwise = Just s - -- | Generate @Version.hs@ files. generateVersionHs :: Expr String generateVersionHs = do ===================================== hadrian/src/Rules/Lint.hs ===================================== @@ -11,13 +11,15 @@ lintRules :: Rules () lintRules = do "lint:base" ~> lint base "lint:compiler" ~> lint compiler + + -- Ensure that autoconf scripts, which are usually run by Cabal, are run to + -- avoid depending upon Cabal from the stage0 compiler.. "libraries" -/- "base" -/- "include" -/- "HsBaseConfig.h" %> \_ -> -- ./configure is called here manually because we need to generate -- HsBaseConfig.h, which is created from HsBaseConfig.h.in. ./configure - -- is usually run by Cabal which generates this file but if we do that - -- then hadrian thinks it needs to build the stage0 compiler before - -- attempting to configure. Therefore we just run it directly here. cmd_ (Cwd "libraries/base") "./configure" + "rts" -/- "include" -/- "ghcautoconf.h" %> \_ -> + cmd_ (Cwd "rts") "./configure" lint :: Action () -> Action () lint lintAction = do ===================================== hadrian/src/Rules/Register.hs ===================================== @@ -48,11 +48,9 @@ configurePackageRules = do when (pkg == rts) $ do -- Rts.h is a header listed in the cabal file, and configuring -- therefore wants to ensure that the header "works" post-configure. - -- But it (transitively) includes these, so we must ensure they exist + -- But it (transitively) includes this, so we must ensure it exists -- for that check to work. - need [ buildP -/- "include/ghcautoconf.h" - , buildP -/- "include/ghcplatform.h" - ] + need [buildP -/- "include/ghcplatform.h"] Cabal.configurePackage ctx root -/- "**/autogen/cabal_macros.h" %> \out -> do ===================================== hadrian/src/Rules/SourceDist.hs ===================================== @@ -142,7 +142,9 @@ prepareTree dest = do moveFile (dest -/- "boot") (dest -/- "boot.source") bootFiles = - [ pkgPath process -/- "include" -/- "HsProcessConfig.h.in" + [ pkgPath rts -/- "configure" + , pkgPath rts -/- "ghcautoconf.h.autoconf.in" + , pkgPath process -/- "include" -/- "HsProcessConfig.h.in" , pkgPath process -/- "configure" , pkgPath ghcBignum -/- "configure" , pkgPath base -/- "configure" ===================================== libraries/base/.gitignore ===================================== @@ -19,4 +19,3 @@ /include/EventConfig.h /include/HsBaseConfig.h /include/HsBaseConfig.h.in - ===================================== libraries/base/Data/List.hs ===================================== @@ -127,6 +127,7 @@ module Data.List -- | These functions treat a list @xs@ as a indexed collection, -- with indices ranging from 0 to @'length' xs - 1 at . + , (!?) , (!!) , elemIndex ===================================== libraries/base/Data/OldList.hs ===================================== @@ -127,6 +127,7 @@ module Data.OldList -- | These functions treat a list @xs@ as a indexed collection, -- with indices ranging from 0 to @'length' xs - 1 at . + , (!?) , (!!) , elemIndex ===================================== libraries/base/GHC/List.hs ===================================== @@ -31,7 +31,7 @@ module GHC.List ( -- Other functions foldl1', concat, concatMap, map, (++), filter, lookup, - head, last, tail, init, uncons, (!!), + head, last, tail, init, uncons, (!?), (!!), scanl, scanl1, scanl', scanr, scanr1, iterate, iterate', repeat, replicate, cycle, take, drop, splitAt, takeWhile, dropWhile, span, break, reverse, @@ -49,7 +49,7 @@ import GHC.Num (Num(..)) import GHC.Num.Integer (Integer) import GHC.Stack.Types (HasCallStack) -infixl 9 !! +infixl 9 !?, !! infix 4 `elem`, `notElem` -- $setup @@ -1370,9 +1370,10 @@ concat = foldr (++) [] -- >>> ['a', 'b', 'c'] !! (-1) -- *** Exception: Prelude.!!: negative index -- --- WARNING: This function is partial. You can use --- --- instead. +-- WARNING: This function is partial, and should only be used if you are +-- sure that the indexing will not fail. Otherwise, use 'Data.List.!?'. +-- +-- WARNING: This function takes linear time in the index. #if defined(USE_REPORT_PRELUDE) (!!) :: [a] -> Int -> a xs !! n | n < 0 = errorWithoutStackTrace "Prelude.!!: negative index" @@ -1401,6 +1402,30 @@ xs !! n _ -> r (k-1)) tooLarge xs n #endif +-- | List index (subscript) operator, starting from 0. Returns 'Nothing' +-- if the index is out of bounds +-- +-- >>> ['a', 'b', 'c'] !? 0 +-- Just 'a' +-- >>> ['a', 'b', 'c'] !? 2 +-- Just 'c' +-- >>> ['a', 'b', 'c'] !? 3 +-- Nothing +-- >>> ['a', 'b', 'c'] !? (-1) +-- Nothing +-- +-- This is the total variant of the partial '!!' operator. +-- +-- WARNING: This function takes linear time in the index. +(!?) :: [a] -> Int -> Maybe a + +{-# INLINABLE (!?) #-} +xs !? n + | n < 0 = Nothing + | otherwise = foldr (\x r k -> case k of + 0 -> Just x + _ -> r (k-1)) (const Nothing) xs n + -------------------------------------------------------------- -- The zip family -------------------------------------------------------------- ===================================== libraries/base/changelog.md ===================================== @@ -58,6 +58,8 @@ 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`. + * Add `Data.List.!?` per + [CLC proposal #110](https://github.com/haskell/core-libraries-committee/issues/110). ## 4.17.0.0 *August 2022* ===================================== m4/fp_find_libdw.m4 ===================================== @@ -48,9 +48,6 @@ AC_DEFUN([FP_FIND_LIBDW], AC_SUBST(UseLibdw) if test $UseLibdw = "YES" ; then USE_LIBDW=1 - AC_SUBST([CabalHaveLibdw],[True]) - else - AC_SUBST([CabalHaveLibdw],[False]) fi AC_DEFINE_UNQUOTED([USE_LIBDW], [$USE_LIBDW], [Set to 1 to use libdw]) ]) ===================================== m4/ghc_llvm_target.m4 ===================================== @@ -50,5 +50,10 @@ AC_DEFUN([GHC_LLVM_TARGET], [ # require it. AC_DEFUN([GHC_LLVM_TARGET_SET_VAR], [ AC_REQUIRE([FPTOOLS_SET_PLATFORMS_VARS]) - GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + if test "$bootstrap_llvm_target" != "" + then + LlvmTarget=$bootstrap_llvm_target + else + GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + fi ]) ===================================== rts/.gitignore ===================================== @@ -12,7 +12,13 @@ /package.conf.install.raw /fs.* +/aclocal.m4 /autom4te.cache/ /config.log /config.status /configure + +/external-symbols.list +/ghcautoconf.h.autoconf.in +/ghcautoconf.h.autoconf +/include/ghcautoconf.h ===================================== rts/configure.ac ===================================== @@ -0,0 +1,88 @@ +# Configure script template for the Run-time System of GHC +# +# Process with 'autoreconf' to get a working configure script. +# +# For the generated configure script, do "./configure --help" to +# see what flags are available. (Better yet, read the documentation!) +# + +AC_INIT([GHC run-time system], [1.0.2], [libraries at haskell.org], [rts]) + +AC_CONFIG_MACRO_DIRS([../m4]) + +# Safety check: Ensure that we are in the correct source directory. +AC_CONFIG_SRCDIR([include/rts/Constants.h]) + +dnl * We require autoconf version 2.69 due to +dnl https://bugs.ruby-lang.org/issues/8179. Also see #14910. +dnl * We need 2.50 due to the use of AC_SYS_LARGEFILE and AC_MSG_NOTICE. +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.69]) + +AC_CONFIG_HEADERS([ghcautoconf.h.autoconf]) + +# We have to run these unconditionally, but we may discard their +# results in the following code +AC_CANONICAL_BUILD +AC_CANONICAL_HOST + +GHC_CONVERT_PLATFORM_PARTS([host], [Host]) +FPTOOLS_SET_PLATFORM_VARS([host], [Host]) +FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host]) + +AC_OUTPUT + +dnl ###################################################################### +dnl Generate ghcautoconf.h +dnl ###################################################################### + +[ +mkdir -p include +touch include/ghcautoconf.h +> include/ghcautoconf.h + +echo "#if !defined(__GHCAUTOCONF_H__)" >> include/ghcautoconf.h +echo "#define __GHCAUTOCONF_H__" >> include/ghcautoconf.h +# Copy the contents of $srcdir/../mk/config.h, turning '#define PACKAGE_FOO +# "blah"' into '/* #undef PACKAGE_FOO */' to avoid clashes. +cat $srcdir/../mk/config.h ghcautoconf.h.autoconf | sed \ + -e 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$,\1/* #undef \2 */,' \ + -e '/__GLASGOW_HASKELL/d' \ + -e '/REMOVE ME/d' \ + >> include/ghcautoconf.h +echo "#endif /* __GHCAUTOCONF_H__ */" >> include/ghcautoconf.h +] + +dnl ###################################################################### +dnl Generate external symbol flags (-Wl,-u...) +dnl ###################################################################### + +dnl See Note [Undefined symbols in the RTS] + +cat $srcdir/external-symbols.list.in \ + | "$CC" -E -P -traditional -Iinclude - -o - \ + | sed '/^$/d' \ + > external-symbols.list \ + || exit 1 + +mv external-symbols.list external-symbols.tmp +if [[ -n "$LeadingUnderscore" ]]; then + sed 's/^/ -Wl,-u_/' external-symbols.tmp > external-symbols.list +else + sed 's/^/ -Wl,-u/' external-symbols.tmp > external-symbols.list +fi +rm -f external-symbols.tmp + +dnl ###################################################################### +dnl Generate build-info +dnl ###################################################################### + +cat $srcdir/rts.buildinfo.in | \ + sed -e 's/^ *//' | \ + "$CC" -E -P -traditional - -o - \ + > rts.buildinfo +echo "" >> rts.buildinfo +rm -f external-symbols.list ===================================== rts/external-symbols.list.in ===================================== @@ -0,0 +1,96 @@ +#include "ghcautoconf.h" + +#if 0 +See Note [Undefined symbols in the RTS] +#endif + +#if SIZEOF_VOID_P == 8 +hs_atomic_add64 +hs_atomic_sub64 +hs_atomic_and64 +hs_atomic_nand64 +hs_atomic_or64 +hs_atomic_xor64 +hs_atomicread64 +hs_atomicwrite64 +#endif + +#if mingw32_HOST_OS +base_GHCziEventziWindows_processRemoteCompletion_closure +#endif + +base_GHCziTopHandler_runIO_closure +base_GHCziTopHandler_runNonIO_closure +ghczmprim_GHCziTupleziPrim_Z0T_closure +ghczmprim_GHCziTypes_True_closure +ghczmprim_GHCziTypes_False_closure +base_GHCziPack_unpackCString_closure +base_GHCziWeakziFinalizze_runFinalizzerBatch_closure +base_GHCziIOziException_stackOverflow_closure +base_GHCziIOziException_heapOverflow_closure +base_GHCziIOziException_allocationLimitExceeded_closure +base_GHCziIOziException_blockedIndefinitelyOnMVar_closure +base_GHCziIOziException_blockedIndefinitelyOnSTM_closure +base_GHCziIOziException_cannotCompactFunction_closure +base_GHCziIOziException_cannotCompactPinned_closure +base_GHCziIOziException_cannotCompactMutable_closure +base_GHCziIOPort_doubleReadException_closure +base_ControlziExceptionziBase_nonTermination_closure +base_ControlziExceptionziBase_nestedAtomically_closure +base_GHCziEventziThread_blockedOnBadFD_closure +base_GHCziConcziSync_runSparks_closure +base_GHCziConcziIO_ensureIOManagerIsRunning_closure +base_GHCziConcziIO_interruptIOManager_closure +base_GHCziConcziIO_ioManagerCapabilitiesChanged_closure +base_GHCziConcziSignal_runHandlersPtr_closure +base_GHCziTopHandler_flushStdHandles_closure +base_GHCziTopHandler_runMainIO_closure +ghczmprim_GHCziTypes_Czh_con_info +ghczmprim_GHCziTypes_Izh_con_info +ghczmprim_GHCziTypes_Fzh_con_info +ghczmprim_GHCziTypes_Dzh_con_info +ghczmprim_GHCziTypes_Wzh_con_info +base_GHCziPtr_Ptr_con_info +base_GHCziPtr_FunPtr_con_info +base_GHCziInt_I8zh_con_info +base_GHCziInt_I16zh_con_info +base_GHCziInt_I32zh_con_info +base_GHCziInt_I64zh_con_info +base_GHCziWord_W8zh_con_info +base_GHCziWord_W16zh_con_info +base_GHCziWord_W32zh_con_info +base_GHCziWord_W64zh_con_info +base_GHCziStable_StablePtr_con_info +hs_atomic_add8 +hs_atomic_add16 +hs_atomic_add32 +hs_atomic_sub8 +hs_atomic_sub16 +hs_atomic_sub32 +hs_atomic_and8 +hs_atomic_and16 +hs_atomic_and32 +hs_atomic_nand8 +hs_atomic_nand16 +hs_atomic_nand32 +hs_atomic_or8 +hs_atomic_or16 +hs_atomic_or32 +hs_atomic_xor8 +hs_atomic_xor16 +hs_atomic_xor32 +hs_cmpxchg8 +hs_cmpxchg16 +hs_cmpxchg32 +hs_cmpxchg64 +hs_xchg8 +hs_xchg16 +hs_xchg32 +hs_xchg64 +hs_atomicread8 +hs_atomicread16 +hs_atomicread32 +hs_atomicwrite8 +hs_atomicwrite16 +hs_atomicwrite32 +base_GHCziStackziCloneStack_StackSnapshot_closure ===================================== rts/posix/OSThreads.c ===================================== @@ -218,6 +218,12 @@ start_thread (void *param) return startProc(startParam); } +/* Note: at least on Linux/Glibc, `pthread_setname_np` restricts the name of + * a thread to 16 bytes, including the terminating null byte. Hence, make sure + * to only pass in names of up to 15 characters. Otherwise, + * `pthread_setname_np` when called in `start_thread` will fail with `ERANGE`, + * which is not checked for, and the thread won't be named at all. + */ int createOSThread (OSThreadId* pId, const char *name, OSThreadProc *startProc, void *param) ===================================== rts/rts.buildinfo.in ===================================== @@ -0,0 +1,3 @@ +-- External symbols referenced by the RTS +ld-options: +#include "external-symbols.list" ===================================== rts/rts.cabal.in ===================================== @@ -1,9 +1,27 @@ cabal-version: 3.0 name: rts version: 1.0.2 +synopsis: The GHC runtime system +description: + The GHC runtime system. + + Code produced by GHC links this library to provide missing functionality + that cannot be written in Haskell itself. license: BSD-3-Clause maintainer: glasgow-haskell-users at haskell.org -build-type: Simple +build-type: Configure + +extra-source-files: + configure + configure.ac + external-symbols.list.in + rts.buildinfo.in + +extra-tmp-files: + autom4te.cache + rts.buildinfo + config.log + config.status source-repository head type: git @@ -206,6 +224,7 @@ library include-dirs: include includes: Rts.h + autogen-includes: ghcautoconf.h install-includes: Cmm.h HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h -- ^ from include @@ -277,201 +296,22 @@ library stg/Types.h -- See Note [Undefined symbols in the RTS] - if flag(64bit) - if flag(leading-underscore) - ld-options: - "-Wl,-u,_hs_atomic_add64" - "-Wl,-u,_hs_atomic_sub64" - "-Wl,-u,_hs_atomic_and64" - "-Wl,-u,_hs_atomic_nand64" - "-Wl,-u,_hs_atomic_or64" - "-Wl,-u,_hs_atomic_xor64" - "-Wl,-u,_hs_atomicread64" - "-Wl,-u,_hs_atomicwrite64" - else - ld-options: - "-Wl,-u,hs_atomic_add64" - "-Wl,-u,hs_atomic_sub64" - "-Wl,-u,hs_atomic_and64" - "-Wl,-u,hs_atomic_nand64" - "-Wl,-u,hs_atomic_or64" - "-Wl,-u,hs_atomic_xor64" - "-Wl,-u,hs_atomicread64" - "-Wl,-u,hs_atomicwrite64" + -- + -- We should handle this symbol with the others in the configure script + -- once we are using Cabal containing + -- https://github.com/haskell/cabal/pull/8565 / + -- 30f8a46008d164b5c4c6ce0b4453eb93eb5ef46c. if flag(leading-underscore) - ld-options: - "-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_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" - "-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" - "-Wl,-u,_hs_atomic_sub8" - "-Wl,-u,_hs_atomic_sub16" - "-Wl,-u,_hs_atomic_sub32" - "-Wl,-u,_hs_atomic_and8" - "-Wl,-u,_hs_atomic_and16" - "-Wl,-u,_hs_atomic_and32" - "-Wl,-u,_hs_atomic_nand8" - "-Wl,-u,_hs_atomic_nand16" - "-Wl,-u,_hs_atomic_nand32" - "-Wl,-u,_hs_atomic_or8" - "-Wl,-u,_hs_atomic_or16" - "-Wl,-u,_hs_atomic_or32" - "-Wl,-u,_hs_atomic_xor8" - "-Wl,-u,_hs_atomic_xor16" - "-Wl,-u,_hs_atomic_xor32" - "-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" - "-Wl,-u,_hs_atomicwrite8" - "-Wl,-u,_hs_atomicwrite16" - "-Wl,-u,_hs_atomicwrite32" - "-Wl,-u,_base_GHCziStackziCloneStack_StackSnapshot_closure" - if flag(find-ptr) -- This symbol is useful in gdb, but not referred to anywhere, -- so we need to force it to be included in the binary. ld-options: "-Wl,-u,_findPtr" - else - ld-options: - "-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_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" - "-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" - "-Wl,-u,hs_atomic_sub8" - "-Wl,-u,hs_atomic_sub16" - "-Wl,-u,hs_atomic_sub32" - "-Wl,-u,hs_atomic_and8" - "-Wl,-u,hs_atomic_and16" - "-Wl,-u,hs_atomic_and32" - "-Wl,-u,hs_atomic_nand8" - "-Wl,-u,hs_atomic_nand16" - "-Wl,-u,hs_atomic_nand32" - "-Wl,-u,hs_atomic_or8" - "-Wl,-u,hs_atomic_or16" - "-Wl,-u,hs_atomic_or32" - "-Wl,-u,hs_atomic_xor8" - "-Wl,-u,hs_atomic_xor16" - "-Wl,-u,hs_atomic_xor32" - "-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" - "-Wl,-u,hs_atomicwrite8" - "-Wl,-u,hs_atomicwrite16" - "-Wl,-u,hs_atomicwrite32" - "-Wl,-u,base_GHCziStackziCloneStack_StackSnapshot_closure" - if flag(find-ptr) -- This symbol is useful in gdb, but not referred to anywhere, -- so we need to force it to be included in the binary. ld-options: "-Wl,-u,findPtr" - if os(windows) - if flag(leading-underscore) - ld-options: - "-Wl,-u,_base_GHCziEventziWindows_processRemoteCompletion_closure" - else - ld-options: - "-Wl,-u,base_GHCziEventziWindows_processRemoteCompletion_closure" - if os(osx) ld-options: "-Wl,-search_paths_first" -- See Note [fd_set_overflow] ===================================== rts/sm/NonMoving.c ===================================== @@ -1015,7 +1015,7 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) nonmoving_write_barrier_enabled = true; debugTrace(DEBUG_nonmoving_gc, "Starting concurrent mark thread"); OSThreadId thread; - if (createOSThread(&thread, "non-moving mark thread", + if (createOSThread(&thread, "nonmoving-mark", nonmovingConcurrentMark, mark_queue) != 0) { barf("nonmovingCollect: failed to spawn mark thread: %s", strerror(errno)); } ===================================== testsuite/tests/codeGen/should_gen_asm/AddMulX86.asm deleted ===================================== @@ -1,46 +0,0 @@ -.section .text -.align 8 -.align 8 - .quad 8589934604 - .quad 0 - .long 14 - .long 0 -.globl AddMulX86_f_info -.type AddMulX86_f_info, @function -AddMulX86_f_info: -.LcAx: - leaq (%r14,%rsi,8),%rbx - jmp *(%rbp) - .size AddMulX86_f_info, .-AddMulX86_f_info -.section .data -.align 8 -.align 1 -.globl AddMulX86_f_closure -.type AddMulX86_f_closure, @object -AddMulX86_f_closure: - .quad AddMulX86_f_info -.section .text -.align 8 -.align 8 - .quad 8589934604 - .quad 0 - .long 14 - .long 0 -.globl AddMulX86_g_info -.type AddMulX86_g_info, @function -AddMulX86_g_info: -.LcAL: - leaq (%r14,%rsi,8),%rbx - jmp *(%rbp) - .size AddMulX86_g_info, .-AddMulX86_g_info -.section .data -.align 8 -.align 1 -.globl AddMulX86_g_closure -.type AddMulX86_g_closure, @object -AddMulX86_g_closure: - .quad AddMulX86_g_info -.section .note.GNU-stack,"", at progbits -.ident "GHC 9.3.20220228" - - ===================================== testsuite/tests/codeGen/should_gen_asm/AddMulX86.hs deleted ===================================== @@ -1,12 +0,0 @@ -{-# LANGUAGE MagicHash #-} - -module AddMulX86 where - -import GHC.Exts - -f :: Int# -> Int# -> Int# -f x y = - x +# (y *# 8#) -- Should result in a lea instruction, which we grep the assembly output for. - -g x y = - (y *# 8#) +# x -- Should result in a lea instruction, which we grep the assembly output for. ===================================== testsuite/tests/codeGen/should_gen_asm/all.T ===================================== @@ -10,4 +10,3 @@ test('memset-unroll', is_amd64_codegen, compile_cmp_asm, ['cmm', '']) test('bytearray-memset-unroll', is_amd64_codegen, compile_grep_asm, ['hs', True, '']) test('bytearray-memcpy-unroll', is_amd64_codegen, compile_grep_asm, ['hs', True, '']) test('T18137', [when(opsys('darwin'), skip), only_ways(llvm_ways)], compile_grep_asm, ['hs', False, '-fllvm -split-sections']) -test('AddMulX86', is_amd64_codegen, compile_cmp_asm, ['hs', '-dno-typeable-binds']) ===================================== testsuite/tests/rts/pause-resume/pause_resume.c ===================================== @@ -187,7 +187,7 @@ void pauseAndResumeViaThread ) { OSThreadId threadId; - createOSThread(&threadId, "Pause and resume thread", &pauseAndResumeViaThread_helper, (void *)count); + createOSThread(&threadId, "pause-resume", &pauseAndResumeViaThread_helper, (void *)count); } const int TIMEOUT = 1000000; // 1 second View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a5f611a4c4564bb1f9b5fd856279f7e3608b82d7...af547008235a83b95bf28cebb634bf4ace33d672 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a5f611a4c4564bb1f9b5fd856279f7e3608b82d7...af547008235a83b95bf28cebb634bf4ace33d672 You're receiving 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 Jan 10 18:44:20 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Tue, 10 Jan 2023 13:44:20 -0500 Subject: [Git][ghc/ghc][wip/misc-cleanup4] Misc cleanup Message-ID: <63bdb204cf680_3b1bf98fe52c4624018@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/misc-cleanup4 at Glasgow Haskell Compiler / GHC Commits: 627a288b by Krzysztof Gogolewski at 2023-01-10T19:44:11+01:00 Misc cleanup - Remove unused mkWildEvBinder - Use typeTypeOrConstraint - more symmetric and asserts that that the type is Type or Constraint - Fix escape sequences in Python; they raise a deprecation warning with -Wdefault - - - - - 12 changed files: - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Type.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Tc/Validity.hs - testsuite/driver/runtests.py - testsuite/tests/cabal/all.T - testsuite/tests/cmm/should_compile/all.T - testsuite/tests/codeGen/should_compile/all.T - testsuite/tests/simplStg/should_compile/all.T - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs ===================================== @@ -199,8 +199,7 @@ joinToTargets_again (return ()) -} delta <- getDeltaR - fixUpInstrs_ <- mapM (handleComponent delta instr) sccs - let fixUpInstrs = concat fixUpInstrs_ + fixUpInstrs <- concatMapM (handleComponent delta instr) sccs -- make a new basic block containing the fixup code. -- A the end of the current block we will jump to the fixup one, ===================================== compiler/GHC/Core/Make.hs ===================================== @@ -6,7 +6,7 @@ module GHC.Core.Make ( mkCoreLet, mkCoreLets, mkCoreApp, mkCoreApps, mkCoreConApps, mkCoreLams, mkWildCase, mkIfThenElse, - mkWildValBinder, mkWildEvBinder, + mkWildValBinder, mkSingleAltCase, sortQuantVars, castBottomExpr, @@ -54,7 +54,7 @@ import GHC.Prelude import GHC.Platform import GHC.Types.Id -import GHC.Types.Var ( EvVar, setTyVarUnique, visArgConstraintLike ) +import GHC.Types.Var ( setTyVarUnique, visArgConstraintLike ) import GHC.Types.TyThing import GHC.Types.Id.Info import GHC.Types.Cpr @@ -173,9 +173,6 @@ mkCoreAppTyped d (fun, fun_ty) arg * * ********************************************************************* -} -mkWildEvBinder :: PredType -> EvVar -mkWildEvBinder pred = mkWildValBinder ManyTy pred - -- | Make a /wildcard binder/. This is typically used when you need a binder -- that you expect to use only at a *binding* site. Do not use it at -- occurrence sites because it has a single, fixed unique, and it's very @@ -1082,8 +1079,9 @@ mkImpossibleExpr :: Type -> String -> CoreExpr mkImpossibleExpr res_ty str = mkRuntimeErrorApp err_id res_ty str where -- See Note [Type vs Constraint for error ids] - err_id | isConstraintLikeKind (typeKind res_ty) = iMPOSSIBLE_CONSTRAINT_ERROR_ID - | otherwise = iMPOSSIBLE_ERROR_ID + err_id = case typeTypeOrConstraint res_ty of + TypeLike -> iMPOSSIBLE_ERROR_ID + ConstraintLike -> iMPOSSIBLE_CONSTRAINT_ERROR_ID {- Note [Type vs Constraint for error ids] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1207,8 +1205,9 @@ mkAbsentErrorApp :: Type -- The type to instantiate 'a' mkAbsentErrorApp res_ty err_msg = mkApps (Var err_id) [ Type res_ty, err_string ] where - err_id | isConstraintLikeKind (typeKind res_ty) = aBSENT_CONSTRAINT_ERROR_ID - | otherwise = aBSENT_ERROR_ID + err_id = case typeTypeOrConstraint res_ty of + TypeLike -> aBSENT_ERROR_ID + ConstraintLike -> aBSENT_CONSTRAINT_ERROR_ID err_string = Lit (mkLitString err_msg) absentErrorName, absentConstraintErrorName :: Name ===================================== compiler/GHC/Core/Opt/WorkWrap.hs ===================================== @@ -68,9 +68,7 @@ info for exported values). wwTopBinds :: WwOpts -> UniqSupply -> CoreProgram -> CoreProgram wwTopBinds ww_opts us top_binds - = initUs_ us $ do - top_binds' <- mapM (wwBind ww_opts) top_binds - return (concat top_binds') + = initUs_ us $ concatMapM (wwBind ww_opts) top_binds {- ************************************************************************ ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -770,7 +770,7 @@ isBoxedRuntimeRep rep = isJust (isBoxedRuntimeRep_maybe rep) -- expands to `Boxed lev` and returns `Nothing` otherwise. -- -- Types with this runtime rep are represented by pointers on the GC'd heap. -isBoxedRuntimeRep_maybe :: RuntimeRepType -> Maybe Type +isBoxedRuntimeRep_maybe :: RuntimeRepType -> Maybe LevityType isBoxedRuntimeRep_maybe rep | Just (rr_tc, args) <- splitRuntimeRep_maybe rep , rr_tc `hasKey` boxedRepDataConKey ===================================== compiler/GHC/HsToCore/Utils.hs ===================================== @@ -81,7 +81,6 @@ import GHC.Types.Tickish import GHC.Utils.Misc import GHC.Driver.Session import GHC.Driver.Ppr -import GHC.Data.FastString import qualified GHC.LanguageExtensions as LangExt import GHC.Tc.Types.Evidence @@ -995,19 +994,10 @@ mkOptTickBox = flip (foldr Tick) mkBinaryTickBox :: Int -> Int -> CoreExpr -> DsM CoreExpr mkBinaryTickBox ixT ixF e = do - uq <- newUnique this_mod <- getModule - let bndr1 = mkSysLocal (fsLit "t1") uq OneTy boolTy - -- It's always sufficient to pattern-match on a boolean with - -- multiplicity 'One'. - let + let trueBox = Tick (HpcTick this_mod ixT) (Var trueDataConId) falseBox = Tick (HpcTick this_mod ixF) (Var falseDataConId) - trueBox = Tick (HpcTick this_mod ixT) (Var trueDataConId) - -- - return $ Case e bndr1 boolTy - [ Alt (DataAlt falseDataCon) [] falseBox - , Alt (DataAlt trueDataCon) [] trueBox - ] + return $ mkIfThenElse e trueBox falseBox ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -774,7 +774,8 @@ check_type (ve at ValidityEnv{ ve_tidy_env = env, ve_ctxt = ctxt where (arg_rank, res_rank) = funArgResRank rank -check_type _ ty = pprPanic "check_type" (ppr ty) +check_type _ ty@(ForAllTy {}) = pprPanic "check_type" (ppr ty) +check_type _ ty@(CoercionTy {}) = pprPanic "check_type" (ppr ty) ---------------------------------------- check_syn_tc_app :: ValidityEnv ===================================== testsuite/driver/runtests.py ===================================== @@ -224,7 +224,7 @@ else: h.close() if v != '': # If it does then use the first utf8 locale that is available - h = os.popen('locale -a | grep -i "utf8\|utf-8" 2>/dev/null', 'r') + h = os.popen(r'locale -a | grep -i "utf8\|utf-8" 2>/dev/null', 'r') v = h.readline().strip() h.close() if v != '': ===================================== testsuite/tests/cabal/all.T ===================================== @@ -1,5 +1,5 @@ def normaliseDynlibNames(str): - return re.sub('-ghc[0-9.]+\.', '-ghc.', str) + return re.sub(r'-ghc[0-9.]+\.', '-ghc.', str) def ignore_warnings(str): return re.sub(r'Warning:.*\n', '', str) ===================================== testsuite/tests/cmm/should_compile/all.T ===================================== @@ -3,7 +3,7 @@ setTestOpts( ]) test('selfloop', [cmm_src], compile, ['-no-hs-main']) -test('cmm_sink_sp', [ only_ways(['optasm']), grep_errmsg('(\[Sp.*\]).*(=).*(\[.*R1.*\]).*;',[1,2,3]), cmm_src], compile, ['-no-hs-main -ddump-cmm -dsuppress-uniques -O']) +test('cmm_sink_sp', [ only_ways(['optasm']), grep_errmsg(r'(\[Sp.*\]).*(=).*(\[.*R1.*\]).*;',[1,2,3]), cmm_src], compile, ['-no-hs-main -ddump-cmm -dsuppress-uniques -O']) test('T16930', normal, makefile_test, ['T16930']) test('T17442', normal, compile, ['']) ===================================== testsuite/tests/codeGen/should_compile/all.T ===================================== @@ -75,9 +75,9 @@ test('T14373', [ js_skip # JS backend doesn't produce Cmm ], multimod_compile_filter, ['T14373', '-fasm -O2 -c -ddump-cmm-from-stg', - 'grep -e "const T14373\.._closure+.;"']) + r'grep -e "const T14373\.._closure+.;"']) -switch_skeleton_only = 'grep -e "switch \[" -e "case " -e "default: " | sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g"' +switch_skeleton_only = r'grep -e "switch \[" -e "case " -e "default: " | sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g"' test('T14373a', [ js_skip # JS backend doesn't produce Cmm @@ -95,8 +95,8 @@ test('T14373c', multimod_compile_filter, ['T14373c', '-fasm -O2 -c -ddump-cmm-from-stg', switch_skeleton_only]) -switch_skeleton_and_entries_only = ('grep -e "switch \[" -e "case " -e "default: " -e "Default_entry(" -e "R1 = .*_closure+2;"' - '| sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g" -e "s|R1 = .*_closure+2;.*|R1 = XYZ_closure+2;|g" -e "s|//.*|//|g"') +switch_skeleton_and_entries_only = (r'grep -e "switch \[" -e "case " -e "default: " -e "Default_entry(" -e "R1 = .*_closure+2;"' + '| sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g" -e "s|R1 = .*_closure+2;.*|R1 = XYZ_closure+2;|g" -e "s|//.*|//|g"') test('T14373d', [ js_skip # JS backend doesn't produce Cmm ===================================== testsuite/tests/simplStg/should_compile/all.T ===================================== @@ -11,6 +11,6 @@ setTestOpts(f) test('T13588', [ grep_errmsg('case') ] , compile, ['-dverbose-stg2stg -fno-worker-wrapper']) test('T19717', normal, compile, ['-ddump-stg-final -dsuppress-uniques -dno-typeable-binds']) -test('inferTags002', [ only_ways(['optasm']), grep_errmsg('(call stg\_ap\_0)', [1])], compile, ['-ddump-cmm -dsuppress-uniques -dno-typeable-binds -O']) +test('inferTags002', [ only_ways(['optasm']), grep_errmsg(r'(call stg\_ap\_0)', [1])], compile, ['-ddump-cmm -dsuppress-uniques -dno-typeable-binds -O']) test('T22212', normal, compile, ['-O']) ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -23,7 +23,7 @@ test('T13380c', expect_broken('!3014'), compile, ['']) test('T13380f', normal, compile, ['']) test('T18086', normal, compile, ['-package ghc']) test('T18957', normal, compile, ['']) -test('T16197b', [grep_errmsg('\$wf')], compile, ['-ddump-simpl -dsuppress-uniques -dsuppress-all']) +test('T16197b', [grep_errmsg(r'\$wf')], compile, ['-ddump-simpl -dsuppress-uniques -dsuppress-all']) test('T19407', normal, compile, ['']) test('T19871', normal, compile, ['']) test('T16859', normal, compile, ['-package ghc']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/627a288b216defe0d66efc060b79db4fbd8c47e5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/627a288b216defe0d66efc060b79db4fbd8c47e5 You're receiving 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 Jan 10 18:54:06 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 10 Jan 2023 13:54:06 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22719 Message-ID: <63bdb44e7f762_3b1bf91d2c59a86300ec@gitlab.mail> Simon Peyton Jones pushed new branch wip/T22719 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22719 You're receiving 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 Jan 10 19:03:17 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 10 Jan 2023 14:03:17 -0500 Subject: [Git][ghc/ghc][wip/T22725] Fix void-arg-adding mechanism for worker/wrapper Message-ID: <63bdb67532b69_3b1bf95260c63405d@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22725 at Glasgow Haskell Compiler / GHC Commits: bcd9dda3 by Simon Peyton Jones at 2023-01-10T19:03:27+00:00 Fix void-arg-adding mechanism for worker/wrapper As #22725 shows, in worker/wrapper we must add the void argument /last/, not first. See GHC.Core.Opt.WorkWrap.Utils Note [Worker/wrapper needs to add void arg last]. That led me to to study GHC.Core.Opt.SpecConstr Note [SpecConstr needs to add void args first] which suggests the opposite! And indeed I think it's the other way round for SpecConstr -- or more precisely the void arg must precede the "extra_bndrs". That led me to some refactoring of GHC.Core.Opt.SpecConstr.calcSpecInfo. - - - - - 8 changed files: - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/simplCore/should_compile/T18328.stderr - + testsuite/tests/simplCore/should_compile/T22725.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -53,6 +53,7 @@ import GHC.Unit.Module.ModGuts import GHC.Types.Literal ( litIsLifted ) import GHC.Types.Id import GHC.Types.Id.Info ( IdDetails(..) ) +import GHC.Types.Id.Make ( voidArgId, voidPrimId ) import GHC.Types.Var.Env import GHC.Types.Var.Set import GHC.Types.Name @@ -1924,24 +1925,13 @@ spec_one env fn arg_bndrs body (call_pat, rule_number) -- And build the results ; (qvars', pats') <- generaliseDictPats qvars pats - ; let spec_body_ty = exprType spec_body - (spec_lam_args1, spec_sig, spec_arity1, spec_join_arity1) - = calcSpecInfo fn call_pat extra_bndrs - -- Annotate the variables with the strictness information from - -- the function (see Note [Strictness information in worker binders]) - add_void_arg = needsVoidWorkerArg fn arg_bndrs spec_lam_args1 - (spec_lam_args, spec_call_args, spec_arity, spec_join_arity) - | add_void_arg - -- See Note [SpecConstr needs to add void args first] - , (spec_lam_args, spec_call_args, _) <- addVoidWorkerArg spec_lam_args1 [] - -- needsVoidWorkerArg: usual w/w hack to avoid generating - -- a spec_rhs of unlifted type and no args. - , !spec_arity <- spec_arity1 + 1 - , !spec_join_arity <- fmap (+ 1) spec_join_arity1 - = (spec_lam_args, spec_call_args, spec_arity, spec_join_arity) - | otherwise - = (spec_lam_args1, spec_lam_args1, spec_arity1, spec_join_arity1) + ; let spec_body_ty = exprType spec_body + (spec_lam_args, spec_call_args, spec_sig) + = calcSpecInfo fn arg_bndrs call_pat extra_bndrs + spec_arity = count isId spec_lam_args + spec_join_arity | isJoinId fn = Just (length spec_call_args) + | otherwise = Nothing spec_id = asWorkerLikeId $ mkLocalId spec_name ManyTy (mkLamTypes spec_lam_args spec_body_ty) @@ -1953,11 +1943,7 @@ spec_one env fn arg_bndrs body (call_pat, rule_number) -- Conditionally use result of new worker-wrapper transform spec_rhs = mkLams spec_lam_args (mkSeqs cbv_args spec_body_ty spec_body) - rule_rhs = mkVarApps (Var spec_id) $ - -- This will give us all the arguments we quantify over - -- in the rule plus the void argument if present - -- since `length(qvars) + void + length(extra_bndrs) = length spec_call_args` - dropTail (length extra_bndrs) spec_call_args + rule_rhs = mkVarApps (Var spec_id) spec_call_args inline_act = idInlineActivation fn this_mod = sc_module $ sc_opts env rule = mkRule this_mod True {- Auto -} True {- Local -} @@ -2020,33 +2006,55 @@ mkSeqs seqees res_ty rhs = = rhs -{- Note [SpecConstr needs to add void args first] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- Note [SpecConstr void argument insertion] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider a function + f :: Bool -> forall t. blah f start @t = e We want to specialize for a partially applied call `f True`. See also Note [SpecConstr call patterns], second Wrinkle. Naively we would expect to get + $sf :: forall t. blah $sf @t = $se RULE: f True = $sf -The specialized function only takes a single type argument -so we add a void argument to prevent it from turning into -a thunk. See Note [Protecting the last value argument] for details -why. Normally we would add the void argument after the -type argument giving us: +The specialized function only takes a single type argument so we add a +void argument to prevent it from turning into a thunk. See Note +[Protecting the last value argument] for details why. Normally we +would add the void argument after the type argument giving us: + $sf :: forall t. Void# -> bla $sf @t void = $se RULE: f True = $sf void# (wrong) -But if you look closely this wouldn't typecheck! -If we substitute `f True` with `$sf void#` we expect the type argument to be applied first -but we apply void# first. -The easiest fix seems to be just to add the void argument to the front of the arguments. -Now we get: + +But if you look closely this wouldn't typecheck! If we substitute `f +True` with `$sf void#` we expect the type argument to be applied first +but we apply void# first. The easiest fix seems to be just to add the +void argument to the front of the arguments. Now we get: + $sf :: Void# -> forall t. bla $sf void @t = $se RULE: f True = $sf void# + And now we can substitute `f True` with `$sf void#` with everything working out nicely! +More precisely, in `calcSpecInfo` +(i) we need the void arg to /precede/ the `extra_bndrs`, but +(ii) it must still /follow/ `qvar_bndrs`. + +Example to illustrate (ii): + f :: forall r (a :: TYPE r). Bool -> a + f = /\r. /\(a::TYPE r). \b. body + + {- Specialise for f _ _ True -} + + $sf :: forall r (a :: TYPE r). Void# -> a + $sf = /\r. /\(a::TYPE r). \v. body[True/b] + RULE: forall r (a :: TYPE r). f @r @a True = $sf @r @a void# + +The void argument must follow the foralls, lest the forall be +ill-kinded. See Note [Worker/wrapper needs to add void arg last] in +GHC.Core.Opt.WorkWrap.Utils. + Note [generaliseDictPats] ~~~~~~~~~~~~~~~~~~~~~~~~~ Consider these two rules (#21831, item 2): @@ -2075,36 +2083,45 @@ And /now/ "SPEC:foo" is clearly more specific: we can instantiate the new "SC:foo" to match the (prefix of) "SPEC:foo". -} -calcSpecInfo :: Id -- The original function - -> CallPat -- Call pattern - -> [Var] -- Extra bndrs - -> ( [Var] -- Demand-decorated binders - , DmdSig -- Strictness of specialised thing - , Arity, Maybe JoinArity ) -- Arities of specialised thing +calcSpecInfo :: Id -- The original function + -> [InVar] -- Lambda binders of original RHS + -> CallPat -- Call pattern + -> [Var] -- Extra bndrs + -> ( [Var] -- Demand-decorated lambda binders + -- for RHS of specialised function + , [Var] -- Args for call site + , DmdSig ) -- Strictness of specialised thing -- Calculate bits of IdInfo for the specialised function -- See Note [Transfer strictness] -- See Note [Strictness information in worker binders] -calcSpecInfo fn (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs - | isJoinId fn -- Join points have strictness and arity for LHS only - = ( bndrs_w_dmds - , mkClosedDmdSig qvar_dmds div - , count isId qvars - , Just (length qvars) ) - | otherwise - = ( bndrs_w_dmds - , mkClosedDmdSig (qvar_dmds ++ extra_dmds) div - , count isId qvars + count isId extra_bndrs - , Nothing ) +calcSpecInfo fn arg_bndrs (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs + = ( spec_lam_bndrs_w_dmds + , spec_call_args + , mkClosedDmdSig [idDemandInfo b | b <- spec_lam_bndrs_w_dmds, isId b] div ) where DmdSig (DmdType _ fn_dmds div) = idDmdSig fn - val_pats = filterOut isTypeArg pats -- value args at call sites, used to determine how many demands to drop - -- from the original functions demand and for setting up dmd_env. + val_pats = filterOut isTypeArg pats + -- Value args at call sites, used to determine how many demands to drop + -- from the original functions demand and for setting up dmd_env. + dmd_env = go emptyVarEnv fn_dmds val_pats qvar_dmds = [ lookupVarEnv dmd_env qv `orElse` topDmd | qv <- qvars, isId qv ] extra_dmds = dropList val_pats fn_dmds - bndrs_w_dmds = set_dmds qvars qvar_dmds - ++ set_dmds extra_bndrs extra_dmds + -- Annotate the variables with the strictness information from + -- the function (see Note [Strictness information in worker binders]) + qvars_w_dmds = set_dmds qvars qvar_dmds + extras_w_dmds = set_dmds extra_bndrs extra_dmds + spec_lam_bndrs_w_dmds = final_qvars_w_dmds ++ extras_w_dmds + + (final_qvars_w_dmds, spec_call_args) + | needsVoidWorkerArg fn arg_bndrs (qvars ++ extra_bndrs) + -- Usual w/w hack to avoid generating + -- a spec_rhs of unlifted or ill-kinded type and no args. + -- See Note [SpecConstr void argument insertion] + = ( qvars_w_dmds ++ [voidArgId], qvars ++ [voidPrimId] ) + | otherwise + = ( qvars_w_dmds, qvars ) set_dmds :: [Var] -> [Demand] -> [Var] set_dmds [] _ = [] @@ -2112,8 +2129,6 @@ calcSpecInfo fn (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs set_dmds (v:vs) ds@(d:ds') | isTyVar v = v : set_dmds vs ds | otherwise = setIdDemandInfo v d : set_dmds vs ds' - dmd_env = go emptyVarEnv fn_dmds val_pats - go :: DmdEnv -> [Demand] -> [CoreExpr] -> DmdEnv -- We've filtered out all the type patterns already go env (d:ds) (pat : pats) = go (go_one env d pat) ds pats @@ -2127,7 +2142,6 @@ calcSpecInfo fn (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs = go env ds args go_one env _ _ = env - {- Note [spec_usg includes rhs_usg] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -9,7 +9,7 @@ A library for the ``worker\/wrapper'' back-end to the strictness analyser module GHC.Core.Opt.WorkWrap.Utils ( WwOpts(..), mkWwBodies, mkWWstr, mkWWstr_one - , needsVoidWorkerArg, addVoidWorkerArg + , needsVoidWorkerArg , DataConPatContext(..) , UnboxingDecision(..), canUnboxArg , findTypeShape, IsRecDataConResult(..), isRecDataCon @@ -377,25 +377,34 @@ We use the state-token type which generates no code. -- Note [Preserving float barriers]. needsVoidWorkerArg :: Id -> [Var] -> [Var] -> Bool needsVoidWorkerArg fn_id wrap_args work_args - = not (isJoinId fn_id) && no_value_arg -- See Note [Protecting the last value argument] - || needs_float_barrier -- See Note [Preserving float barriers] + = thunk_problem -- See Note [Protecting the last value argument] + || needs_float_barrier -- See Note [Preserving float barriers] where - no_value_arg = all (not . isId) work_args + -- thunk_problem: see Note [Protecting the last value argument] + -- For join points we are only worried about (4), not (1-4). + -- And (4) can't happen if (null work_args) + -- (We could be more clever, by looking at the result type, but + -- this approach is simple and conservative.) + thunk_problem | isJoinId fn_id = no_value_arg && not (null work_args) + | otherwise = no_value_arg + no_value_arg = not (any isId work_args) + + -- needs_float_barrier: see Note [Preserving float barriers] + needs_float_barrier = wrap_had_barrier && not work_has_barrier is_float_barrier v = isId v && hasNoOneShotInfo (idOneShotInfo v) wrap_had_barrier = any is_float_barrier wrap_args work_has_barrier = any is_float_barrier work_args - needs_float_barrier = wrap_had_barrier && not work_has_barrier --- | Inserts a `Void#` arg before the first argument. --- --- Why as the first argument? See Note [SpecConstr needs to add void args first] --- in SpecConstr. +-- | Inserts a `Void#` arg as the last argument. +-- Why last? See Note [Worker/wrapper needs to add void arg last] addVoidWorkerArg :: [Var] -> [StrictnessMark] - -> ([Var], -- Lambda bound args - [Var], -- Args at call site - [StrictnessMark]) -- str semantics for the worker args. + -> ( [Var] -- Lambda bound args + , [Var] -- Args at call site + , [StrictnessMark]) -- str semantics for the worker args addVoidWorkerArg work_args str_marks - = (voidArgId : work_args, voidPrimId:work_args, NotMarkedStrict:str_marks) + = ( work_args ++ [voidArgId] + , work_args ++ [voidPrimId] + , str_marks ++ [NotMarkedStrict] ) {- Note [Protecting the last value argument] @@ -403,8 +412,8 @@ Note [Protecting the last value argument] If the user writes (\_ -> E), they might be intentionally disallowing the sharing of E. Since absence analysis and worker-wrapper are keen to remove such unused arguments, we add in a void argument to prevent -the function from becoming a thunk. Three reasons why turning a function -into a thunk might be bad: +the function from becoming a thunk. Here are several reasons why turning +a function into a thunk might be bad: 1) It can create a space leak. e.g. f x = let y () = [1..x] @@ -423,7 +432,19 @@ into a thunk might be bad: g = \x. 30# Removing the \x would leave an unlifted binding. -NB: none of these apply to a join point. +4) It can create a worker of ill-kinded type (#22275). Consider + f :: forall r (a :: TYPE r). () -> a + f x = f x + Here `x` is absent, but if we simply drop it we'd end up with + $wf :: forall r (a :: TYPE r). a + But alas $wf's type is ill-kinded: the kind of (/\r (a::TYPE r).a) + is (TYPE r), which mentions the bound variable `r`. See also + Note [Worker/wrapper needs to add void arg last] + +See also Note [Preserving float barriers] + +NB: Of these, only (1-3) don't apply to a join point, which can be +unlifted even if the RHS is not ok-for-speculation. Note [Preserving float barriers] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -457,7 +478,7 @@ which some are absent or one-shot and the resulting worker arguments: * \a{Abs}.\b{os}.\c{os}... ==> \b{os}.\c{os}.\(_::Void#)... Wrapper arg `a` was the only float barrier and had been dropped. Hence Void# - * \a{Abs,os}.\b{os}.\c... ==> \b{os}.\c... +p * \a{Abs,os}.\b{os}.\c... ==> \b{os}.\c... Worker arg `c` is a float barrier. * \a.\b{Abs}.\c{os}... ==> \a.\c{os}... Worker arg `a` is a float barrier. @@ -469,6 +490,27 @@ which some are absent or one-shot and the resulting worker arguments: Executable examples in T21150. +Note [Worker/wrapper needs to add void arg last] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider point (4) of Note [Protecting the last value argument] + + f :: forall r (a :: TYPE r). () -> a + f x = f x + +As pointed out in (4) we need to add a void argument. But if we add +it /first/ we'd get + + $wf :: Void# -> forall r (a :: TYPE r). a + $wf = ... + +But alas $wf's type is /still/ still-kinded, just as before in (4). +Solution is simple: put the void argument /last/: + + $wf :: forall r (a :: TYPE r). Void# -> a + $wf = ... + +c.f Note [SpecConstr void argument insertion] in GHC.Core.Opt.SpecConstr + Note [Join points and beta-redexes] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Originally, the worker would invoke the original function by calling it with ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1337,7 +1337,7 @@ ty_con_app_fun_maybe many_ty_co tc args | otherwise = Nothing -mkFunctionType :: Mult -> Type -> Type -> Type +mkFunctionType :: HasDebugCallStack => Mult -> Type -> Type -> Type -- ^ This one works out the FunTyFlag from the argument type -- See GHC.Types.Var Note [FunTyFlag] mkFunctionType mult arg_ty res_ty ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -158,7 +158,7 @@ coreAltsType :: [CoreAlt] -> Type coreAltsType (alt:_) = coreAltType alt coreAltsType [] = panic "coreAltsType" -mkLamType :: Var -> Type -> Type +mkLamType :: HasDebugCallStack => Var -> Type -> Type -- ^ Makes a @(->)@ type or an implicit forall type, depending -- on whether it is given a type variable or a term variable. -- This is used, for example, when producing the type of a lambda. ===================================== testsuite/tests/simplCore/should_compile/T13143.stderr ===================================== @@ -1,14 +1,14 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 71, types: 41, coercions: 0, joins: 0/0} + = {terms: 71, types: 40, coercions: 0, joins: 0/0} Rec { -- RHS size: {terms: 4, types: 3, coercions: 0, joins: 0/0} T13143.$wf [InlPrag=NOINLINE, Occ=LoopBreaker] - :: (# #) -> forall {a}. a + :: forall {a}. (# #) -> a [GblId, Arity=1, Str=b, Cpr=b, Unf=OtherCon []] -T13143.$wf = \ _ [Occ=Dead] (@a) -> T13143.$wf GHC.Prim.(##) @a +T13143.$wf = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##) end Rec } -- RHS size: {terms: 4, types: 3, coercions: 0, joins: 0/0} @@ -17,55 +17,60 @@ f [InlPrag=NOINLINE[final]] :: forall a. Int -> a Arity=1, Str=b, Cpr=b, - 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=True) - Tmpl= \ (@a) _ [Occ=Dead] -> T13143.$wf GHC.Prim.(##) @a}] -f = \ (@a) _ [Occ=Dead] -> T13143.$wf GHC.Prim.(##) @a + Tmpl= \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##)}] +f = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##) -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T13143.$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}] T13143.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T13143.$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}] T13143.$trModule3 = GHC.Types.TrNameS T13143.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T13143.$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}] T13143.$trModule2 = "T13143"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T13143.$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}] 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}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T13143.$trModule = GHC.Types.Module T13143.$trModule3 T13143.$trModule1 --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -lvl :: forall {a}. a +-- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} +lvl :: Int [GblId, Str=b, Cpr=b] -lvl = T13143.$wf GHC.Prim.(##) +lvl = T13143.$wf @Int GHC.Prim.(##) Rec { --- RHS size: {terms: 28, types: 8, coercions: 0, joins: 0/0} +-- RHS size: {terms: 28, types: 7, coercions: 0, joins: 0/0} T13143.$wg [InlPrag=[2], Occ=LoopBreaker] :: Bool -> Bool -> GHC.Prim.Int# -> GHC.Prim.Int# [GblId[StrictWorker([!, !])], @@ -94,8 +99,8 @@ g [InlPrag=[2]] :: Bool -> Bool -> Int -> Int Arity=3, Str=<1L><1L><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=3,unsat_ok=True,boring_ok=False) Tmpl= \ (ds [Occ=Once1] :: Bool) (ds1 [Occ=Once1] :: Bool) ===================================== testsuite/tests/simplCore/should_compile/T18328.stderr ===================================== @@ -1,84 +1,90 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 65, types: 53, coercions: 0, joins: 1/1} + = {terms: 69, types: 55, coercions: 0, joins: 1/1} --- RHS size: {terms: 38, types: 23, coercions: 0, joins: 1/1} +-- RHS size: {terms: 42, types: 25, coercions: 0, joins: 1/1} T18328.$wf [InlPrag=[2]] :: forall {a}. GHC.Prim.Int# -> [a] -> [a] -> [a] -[GblId, +[GblId[StrictWorker([~, !])], Arity=3, Str=, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [176 0 0] 306 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [176 0 0] 306 0}] T18328.$wf - = \ (@a) (ww :: GHC.Prim.Int#) (w :: [a]) (w1 :: [a]) -> + = \ (@a) (ww :: GHC.Prim.Int#) (ys :: [a]) (eta :: [a]) -> join { - $wj [InlPrag=NOINLINE, Dmd=ML] :: forall {p}. [a] - [LclId[JoinId(1)]] - $wj (@p) + $wj [InlPrag=NOINLINE, Dmd=MC(1,L)] :: forall {p}. (# #) -> [a] + [LclId[JoinId(2)(Nothing)], Arity=1, Str=, Unf=OtherCon []] + $wj (@p) _ [Occ=Dead, OS=OneShot] = case ww of { - __DEFAULT -> ++ @a w (++ @a w (++ @a w w1)); - 3# -> ++ @a w (++ @a w (++ @a w (++ @a w w1))) + __DEFAULT -> ++ @a ys (++ @a ys (++ @a ys eta)); + 3# -> ++ @a ys (++ @a ys (++ @a ys (++ @a ys eta))) } } in case ww of { - __DEFAULT -> ++ @a w w1; - 1# -> jump $wj @Integer; - 2# -> jump $wj @Integer; - 3# -> jump $wj @Integer + __DEFAULT -> ++ @a ys eta; + 1# -> jump $wj @Integer GHC.Prim.(##); + 2# -> jump $wj @Integer GHC.Prim.(##); + 3# -> jump $wj @Integer GHC.Prim.(##) } -- RHS size: {terms: 11, types: 9, coercions: 0, joins: 0/0} f [InlPrag=[2]] :: forall a. Int -> [a] -> [a] -> [a] [GblId, Arity=3, - Str=<1P(SL)>, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Str=<1!P(SL)>, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) Tmpl= \ (@a) - (w [Occ=Once1!] :: Int) - (w1 [Occ=Once1] :: [a]) - (w2 [Occ=Once1] :: [a]) -> - case w of { GHC.Types.I# ww [Occ=Once1] -> - T18328.$wf @a ww w1 w2 + (x [Occ=Once1!] :: Int) + (ys [Occ=Once1] :: [a]) + (eta [Occ=Once1] :: [a]) -> + case x of { GHC.Types.I# ww [Occ=Once1] -> + T18328.$wf @a ww ys eta }}] -f = \ (@a) (w :: Int) (w1 :: [a]) (w2 :: [a]) -> - case w of { GHC.Types.I# ww -> T18328.$wf @a ww w1 w2 } +f = \ (@a) (x :: Int) (ys :: [a]) (eta :: [a]) -> + case x of { GHC.Types.I# ww -> T18328.$wf @a ww ys eta } -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule3 = GHC.Types.TrNameS T18328.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule2 = "T18328"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T18328.$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}] T18328.$trModule1 = GHC.Types.TrNameS T18328.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T18328.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T18328.$trModule = GHC.Types.Module T18328.$trModule3 T18328.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T22725.hs ===================================== @@ -0,0 +1,6 @@ +module M where + +import GHC.Exts (TYPE) + +f :: forall r (a :: TYPE r). () -> a +f x = f x ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -462,3 +462,4 @@ test('T22272', normal, multimod_compile, ['T22272', '-O -fexpose-all-unfoldings test('T22459', normal, compile, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) test('T22662', normal, compile, ['']) +test('T22725', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bcd9dda363313e1adf4b164602c4f911dc4ca9ee -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bcd9dda363313e1adf4b164602c4f911dc4ca9ee You're receiving 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 Jan 10 19:05:25 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Tue, 10 Jan 2023 14:05:25 -0500 Subject: [Git][ghc/ghc][wip/specialize-hdoc] Add 'docWithStyle' to improve codegen Message-ID: <63bdb6f56d59b_3b1bf9526206368c8@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/specialize-hdoc at Glasgow Haskell Compiler / GHC Commits: 3d333485 by Krzysztof Gogolewski at 2023-01-10T20:05:06+01:00 Add 'docWithStyle' to improve codegen This new combinator docWithStyle :: IsOutput doc => doc -> (PprStyle -> SDoc) -> doc let us remove the need for code to be polymorphic in HDoc when not used in code style. Metric Decrease: ManyConstructors T13035 T1969 - - - - - 5 changed files: - compiler/GHC/Types/CostCentre.hs - compiler/GHC/Types/Name.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Unit/Types.hs - compiler/GHC/Utils/Outputable.hs Changes: ===================================== compiler/GHC/Types/CostCentre.hs ===================================== @@ -265,10 +265,8 @@ instance Outputable CostCentre where ppr = pprCostCentre pprCostCentre :: IsLine doc => CostCentre -> doc -pprCostCentre cc = docWithContext $ \ sty -> - if codeStyle (sdocStyle sty) - then ppCostCentreLbl cc - else ftext (costCentreUserNameFS cc) +pprCostCentre cc = docWithStyle (ppCostCentreLbl cc) + (\_ -> ftext (costCentreUserNameFS cc)) {-# SPECIALISE pprCostCentre :: CostCentre -> SDoc #-} {-# SPECIALISE pprCostCentre :: CostCentre -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable ===================================== compiler/GHC/Types/Name.hs ===================================== @@ -627,21 +627,30 @@ instance OutputableBndr Name where pprName :: forall doc. IsLine doc => Name -> doc pprName name@(Name {n_sort = sort, n_uniq = uniq, n_occ = occ}) - = docWithContext $ \ctx -> - let sty = sdocStyle ctx - debug = sdocPprDebug ctx - listTuplePuns = sdocListTuplePuns ctx - in handlePuns listTuplePuns (namePun_maybe name) $ - case sort of - WiredIn mod _ builtin -> pprExternal debug sty uniq mod occ True builtin - External mod -> pprExternal debug sty uniq mod occ False UserSyntax - System -> pprSystem debug sty uniq occ - Internal -> pprInternal debug sty uniq occ + = docWithStyle codeDoc normalDoc where - -- Print GHC.Types.List as [], etc. - handlePuns :: Bool -> Maybe FastString -> doc -> doc - handlePuns True (Just pun) _ = ftext pun - handlePuns _ _ r = r + codeDoc = case sort of + WiredIn mod _ _ -> pprModule mod <> char '_' <> ppr_z_occ_name occ + External mod -> pprModule mod <> char '_' <> ppr_z_occ_name occ + -- In code style, always qualify + -- ToDo: maybe we could print all wired-in things unqualified + -- in code style, to reduce symbol table bloat? + System -> pprUniqueAlways uniq + Internal -> pprUniqueAlways uniq + + normalDoc sty = + getPprDebug $ \debug -> + sdocOption sdocListTuplePuns $ \listTuplePuns -> + handlePuns listTuplePuns (namePun_maybe name) $ + case sort of + WiredIn mod _ builtin -> pprExternal debug sty uniq mod occ True builtin + External mod -> pprExternal debug sty uniq mod occ False UserSyntax + System -> pprSystem debug sty uniq occ + Internal -> pprInternal debug sty uniq occ + + handlePuns :: Bool -> Maybe FastString -> SDoc -> SDoc + handlePuns True (Just pun) _ = ftext pun + handlePuns _ _ r = r {-# SPECIALISE pprName :: Name -> SDoc #-} {-# SPECIALISE pprName :: Name -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable @@ -674,12 +683,8 @@ pprTickyName this_mod name pprNameUnqualified :: Name -> SDoc pprNameUnqualified Name { n_occ = occ } = ppr_occ_name occ -pprExternal :: IsLine doc => Bool -> PprStyle -> Unique -> Module -> OccName -> Bool -> BuiltInSyntax -> doc +pprExternal :: Bool -> PprStyle -> Unique -> Module -> OccName -> Bool -> BuiltInSyntax -> SDoc pprExternal debug sty uniq mod occ is_wired is_builtin - | codeStyle sty = pprModule mod <> char '_' <> ppr_z_occ_name occ - -- In code style, always qualify - -- ToDo: maybe we could print all wired-in things unqualified - -- in code style, to reduce symbol table bloat? | debug = pp_mod <> ppr_occ_name occ <> braces (hsep [if is_wired then text "(w)" else empty, pprNameSpaceBrief (occNameSpace occ), @@ -695,9 +700,8 @@ pprExternal debug sty uniq mod occ is_wired is_builtin pp_mod = ppUnlessOption sdocSuppressModulePrefixes (pprModule mod <> dot) -pprInternal :: IsLine doc => Bool -> PprStyle -> Unique -> OccName -> doc +pprInternal :: Bool -> PprStyle -> Unique -> OccName -> SDoc pprInternal debug sty uniq occ - | codeStyle sty = pprUniqueAlways uniq | debug = ppr_occ_name occ <> braces (hsep [pprNameSpaceBrief (occNameSpace occ), pprUnique uniq]) | dumpStyle sty = ppr_occ_name occ <> ppr_underscore_unique uniq @@ -706,9 +710,8 @@ pprInternal debug sty uniq occ | otherwise = ppr_occ_name occ -- User style -- Like Internal, except that we only omit the unique in Iface style -pprSystem :: IsLine doc => Bool -> PprStyle -> Unique -> OccName -> doc -pprSystem debug sty uniq occ - | codeStyle sty = pprUniqueAlways uniq +pprSystem :: Bool -> PprStyle -> Unique -> OccName -> SDoc +pprSystem debug _sty uniq occ | debug = ppr_occ_name occ <> ppr_underscore_unique uniq <> braces (pprNameSpaceBrief (occNameSpace occ)) | otherwise = ppr_occ_name occ <> ppr_underscore_unique uniq @@ -717,7 +720,7 @@ pprSystem debug sty uniq occ -- so print the unique -pprModulePrefix :: IsLine doc => PprStyle -> Module -> OccName -> doc +pprModulePrefix :: PprStyle -> Module -> OccName -> SDoc -- Print the "M." part of a name, based on whether it's in scope or not -- See Note [Printing original names] in GHC.Types.Name.Ppr pprModulePrefix sty mod occ = ppUnlessOption sdocSuppressModulePrefixes $ @@ -728,20 +731,20 @@ pprModulePrefix sty mod occ = ppUnlessOption sdocSuppressModulePrefixes $ <> pprModuleName (moduleName mod) <> dot -- scope either NameUnqual -> empty -- In scope unqualified -pprUnique :: IsLine doc => Unique -> doc +pprUnique :: Unique -> SDoc -- Print a unique unless we are suppressing them pprUnique uniq = ppUnlessOption sdocSuppressUniques $ pprUniqueAlways uniq -ppr_underscore_unique :: IsLine doc => Unique -> doc +ppr_underscore_unique :: Unique -> SDoc -- Print an underscore separating the name from its unique -- But suppress it if we aren't printing the uniques anyway ppr_underscore_unique uniq = ppUnlessOption sdocSuppressUniques $ char '_' <> pprUniqueAlways uniq -ppr_occ_name :: IsLine doc => OccName -> doc +ppr_occ_name :: OccName -> SDoc ppr_occ_name occ = ftext (occNameFS occ) -- Don't use pprOccName; instead, just print the string of the OccName; -- we print the namespace in the debug stuff above ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -200,7 +200,7 @@ pprNonVarNameSpace :: NameSpace -> SDoc pprNonVarNameSpace VarName = empty pprNonVarNameSpace ns = pprNameSpace ns -pprNameSpaceBrief :: IsLine doc => NameSpace -> doc +pprNameSpaceBrief :: NameSpace -> SDoc pprNameSpaceBrief DataName = char 'd' pprNameSpaceBrief VarName = char 'v' pprNameSpaceBrief TvName = text "tv" @@ -278,10 +278,9 @@ instance OutputableBndr OccName where pprOccName :: IsLine doc => OccName -> doc pprOccName (OccName sp occ) - = docWithContext $ \ sty -> - if codeStyle (sdocStyle sty) - then ztext (zEncodeFS occ) - else ftext occ <> whenPprDebug (braces (pprNameSpaceBrief sp)) + = docWithStyle (ztext (zEncodeFS occ)) (\_ -> ftext occ <> whenPprDebug (braces (pprNameSpaceBrief sp))) +{-# SPECIALIZE pprOccName :: OccName -> SDoc #-} +{-# SPECIALIZE pprOccName :: OccName -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable {- ************************************************************************ ===================================== compiler/GHC/Unit/Types.hs ===================================== @@ -166,7 +166,7 @@ instance Outputable InstantiatedModule where instance Outputable InstantiatedUnit where ppr = pprInstantiatedUnit -pprInstantiatedUnit :: IsLine doc => InstantiatedUnit -> doc +pprInstantiatedUnit :: InstantiatedUnit -> SDoc pprInstantiatedUnit uid = -- getPprStyle $ \sty -> pprUnitId cid <> @@ -180,8 +180,6 @@ pprInstantiatedUnit uid = where cid = instUnitInstanceOf uid insts = instUnitInsts uid -{-# SPECIALIZE pprInstantiatedUnit :: InstantiatedUnit -> SDoc #-} -{-# SPECIALIZE pprInstantiatedUnit :: InstantiatedUnit -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable -- | Class for types that are used as unit identifiers (UnitKey, UnitId, Unit) -- @@ -203,14 +201,13 @@ instance IsUnitId u => IsUnitId (GenUnit u) where unitFS HoleUnit = holeFS pprModule :: IsLine doc => Module -> doc -pprModule mod@(Module p n) = docWithContext (doc . sdocStyle) +pprModule mod@(Module p n) = docWithStyle code doc where - doc sty - | codeStyle sty = - (if p == mainUnit + code = (if p == mainUnit then empty -- never qualify the main package in code else ztext (zEncodeFS (unitFS p)) <> char '_') <> pprModuleName n + doc sty | qualModule sty mod = case p of HoleUnit -> angleBrackets (pprModuleName n) @@ -352,12 +349,10 @@ stableUnitCmp p1 p2 = unitFS p1 `lexicalCompareFS` unitFS p2 instance Outputable Unit where ppr pk = pprUnit pk -pprUnit :: IsLine doc => Unit -> doc +pprUnit :: Unit -> SDoc pprUnit (RealUnit (Definite d)) = pprUnitId d pprUnit (VirtUnit uid) = pprInstantiatedUnit uid pprUnit HoleUnit = ftext holeFS -{-# SPECIALIZE pprUnit :: Unit -> SDoc #-} -{-# SPECIALIZE pprUnit :: Unit -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable instance Show Unit where show = unitString @@ -535,12 +530,8 @@ instance Uniquable UnitId where instance Outputable UnitId where ppr = pprUnitId -pprUnitId :: IsLine doc => UnitId -> doc -pprUnitId (UnitId fs) = dualLine (sdocOption sdocUnitIdForUser ($ fs)) (ftext fs) - -- see Note [Pretty-printing UnitId] in GHC.Unit - -- also see Note [dualLine and dualDoc] in GHC.Utils.Outputable -{-# SPECIALIZE pprUnitId :: UnitId -> SDoc #-} -{-# SPECIALIZE pprUnitId :: UnitId -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable +pprUnitId :: UnitId -> SDoc +pprUnitId (UnitId fs) = sdocOption sdocUnitIdForUser ($ fs) -- | A 'DefUnitId' is an 'UnitId' with the invariant that -- it only refers to a definite library; i.e., one we have generated ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -126,6 +126,7 @@ import GHC.Data.FastString import qualified GHC.Utils.Ppr as Pretty import qualified GHC.Utils.Ppr.Colour as Col import GHC.Utils.Ppr ( Doc, Mode(..) ) +import GHC.Utils.Panic.Plain (assert) import GHC.Serialized import GHC.LanguageExtensions (Extension) import GHC.Utils.GlobalVars( unsafeHasPprDebug ) @@ -855,9 +856,10 @@ ppWhenOption f doc = sdocOption f $ \case False -> empty {-# INLINE CONLIKE ppUnlessOption #-} -ppUnlessOption :: IsLine doc => (SDocContext -> Bool) -> doc -> doc -ppUnlessOption f doc = docWithContext $ - \ctx -> if f ctx then empty else doc +ppUnlessOption :: (SDocContext -> Bool) -> SDoc -> SDoc +ppUnlessOption f doc = sdocOption f $ \case + True -> empty + False -> doc -- | Apply the given colour\/style for the argument. -- @@ -1040,10 +1042,7 @@ instance Outputable ModuleName where pprModuleName :: IsLine doc => ModuleName -> doc pprModuleName (ModuleName nm) = - docWithContext $ \ctx -> - if codeStyle (sdocStyle ctx) - then ztext (zEncodeFS nm) - else ftext nm + docWithStyle (ztext (zEncodeFS nm)) (\_ -> ftext nm) {-# SPECIALIZE pprModuleName :: ModuleName -> SDoc #-} {-# SPECIALIZE pprModuleName :: ModuleName -> HLine #-} -- see Note [SPECIALIZE to HDoc] @@ -1633,6 +1632,7 @@ IsOutput, that allows these combinators to be generic over both variants: class IsOutput doc where empty :: doc docWithContext :: (SDocContext -> doc) -> doc + docWithStyle :: doc -> (PprStyle -> SDoc) -> doc class IsOutput doc => IsLine doc class (IsOutput doc, IsLine (Line doc)) => IsDoc doc @@ -1669,13 +1669,22 @@ arguments depending on the type they are instantiated at. They serve as a difficult to make completely equivalent under both printer implementations. These operations should generally be avoided, as they can result in surprising -changes in behavior when the printer implementation is changed. However, in -certain cases, the alternative is even worse. For example, we use dualLine in -the implementation of pprUnitId, as the hack we use for printing unit ids -(see Note [Pretty-printing UnitId] in GHC.Unit) is difficult to adapt to HLine -and is not necessary for code paths that use it, anyway. - -Use these operations wisely. -} +changes in behavior when the printer implementation is changed. +Right now, they are used only when outputting debugging comments in +codegen, as it is difficult to adapt that code to use HLine and not necessary. + +Use these operations wisely. + +Note [docWithStyle] +~~~~~~~~~~~~~~~~~~~ +Sometimes when printing, we consult the printing style. This can be done +with 'docWithStyle c f'. This is similar to 'docWithContext (f . sdocStyle)', +but: +* For code style, 'docWithStyle c f' will return 'c'. +* For other styles, 'docWithStyle c f', will call 'f style', but expect + an SDoc rather than doc. This removes the need to write code polymorphic + in SDoc and HDoc, since the latter is used only for code style. +-} -- | Represents a single line of output that can be efficiently printed directly -- to a 'System.IO.Handle' (actually a 'BufHandle'). @@ -1700,7 +1709,7 @@ pattern HDoc f <- HDoc' f {-# COMPLETE HDoc #-} bPutHDoc :: BufHandle -> SDocContext -> HDoc -> IO () -bPutHDoc h ctx (HDoc f) = f ctx h +bPutHDoc h ctx (HDoc f) = assert (codeStyle (sdocStyle ctx)) (f ctx h) -- | A superclass for 'IsLine' and 'IsDoc' that provides an identity, 'empty', -- as well as access to the shared 'SDocContext'. @@ -1709,6 +1718,7 @@ bPutHDoc h ctx (HDoc f) = f ctx h class IsOutput doc where empty :: doc docWithContext :: (SDocContext -> doc) -> doc + docWithStyle :: doc -> (PprStyle -> SDoc) -> doc -- see Note [docWithStyle] -- | A class of types that represent a single logical line of text, with support -- for horizontal composition. @@ -1779,6 +1789,11 @@ instance IsOutput SDoc where {-# INLINE CONLIKE empty #-} docWithContext = sdocWithContext {-# INLINE docWithContext #-} + docWithStyle c f = sdocWithContext (\ctx -> let sty = sdocStyle ctx + in if codeStyle sty then c + else f sty) + -- see Note [docWithStyle] + {-# INLINE CONLIKE docWithStyle #-} instance IsLine SDoc where char c = docToSDoc $ Pretty.char c @@ -1823,12 +1838,18 @@ instance IsOutput HLine where {-# INLINE empty #-} docWithContext f = HLine $ \ctx h -> runHLine (f ctx) ctx h {-# INLINE CONLIKE docWithContext #-} + docWithStyle (HLine c) _ = HLine $ \ctx h -> assert (codeStyle (sdocStyle ctx)) (c ctx h) + -- see Note [docWithStyle] + {-# INLINE CONLIKE docWithStyle #-} instance IsOutput HDoc where empty = HDoc (\_ _ -> pure ()) {-# INLINE empty #-} docWithContext f = HDoc $ \ctx h -> runHDoc (f ctx) ctx h {-# INLINE CONLIKE docWithContext #-} + docWithStyle (HDoc c) _ = HDoc $ \ctx h -> assert (codeStyle (sdocStyle ctx)) (c ctx h) + -- see Note [docWithStyle] + {-# INLINE CONLIKE docWithStyle #-} instance IsLine HLine where char c = HLine (\_ h -> bPutChar h c) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3d333485d8fcf9019b77a89b71431d83a0b5a8fa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3d333485d8fcf9019b77a89b71431d83a0b5a8fa You're receiving 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 Jan 10 19:15:19 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 10 Jan 2023 14:15:19 -0500 Subject: [Git][ghc/ghc][wip/T22428] Fix contification with stable unfoldings (#22428) Message-ID: <63bdb94742c55_3b1bf91d2c59a8639230@gitlab.mail> Sebastian Graf pushed to branch wip/T22428 at Glasgow Haskell Compiler / GHC Commits: 3583c57a by Sebastian Graf at 2023-01-10T20:12:01+01:00 Fix contification with stable unfoldings (#22428) Many functions now return a `TailUsageDetails` that adorns a `UsageDetails` with a `JoinArity` that reflects the number of join point binders around the body for which the `UsageDetails` was computed. `TailUsageDetails` is now returned by `occAnalLamTail` as well as `occAnalUnfolding` and `occAnalRules`. I adjusted `Note [Join points and unfoldings/rules]` and `Note [Adjusting right-hand sides]` to account for the new machinery. I also wrote a new `Note [Join arity prediction based on joinRhsArity]` and refer to it when we combine `TailUsageDetails` for a recursive RHS. I also renamed * `occAnalLam` to `occAnalLamTail` * `adjustRhsUsage` to `adjustTailUsage` * a few other less important functions and properly documented the that each call of `occAnalLamTail` must pair up with `adjustTailUsage`. I removed `Note [Unfoldings and join points]` because it was redundant with `Note [Occurrences in stable unfoldings]`. While in town, I refactored `mkLoopBreakerNodes` so that it returns a condensed `NodeDetails` called `SimpleNodeDetails`. Fixes #22428. The refactoring seems to have quite beneficial effect on ghc/alloc performance: ``` CoOpt_Read(normal) ghc/alloc 784,778,420 768,091,176 -2.1% GOOD T12150(optasm) ghc/alloc 77,762,270 75,986,720 -2.3% GOOD T12425(optasm) ghc/alloc 85,740,186 84,641,712 -1.3% GOOD T13056(optasm) ghc/alloc 306,104,656 299,811,632 -2.1% GOOD T13253(normal) ghc/alloc 350,233,952 346,004,008 -1.2% T14683(normal) ghc/alloc 2,800,514,792 2,754,651,360 -1.6% T15304(normal) ghc/alloc 1,230,883,318 1,215,978,336 -1.2% T15630(normal) ghc/alloc 153,379,590 151,796,488 -1.0% T16577(normal) ghc/alloc 7,356,797,056 7,244,194,416 -1.5% T17516(normal) ghc/alloc 1,718,941,448 1,692,157,288 -1.6% T19695(normal) ghc/alloc 1,485,794,632 1,458,022,112 -1.9% T21839c(normal) ghc/alloc 437,562,314 431,295,896 -1.4% GOOD T21839r(normal) ghc/alloc 446,927,580 440,615,776 -1.4% GOOD geo. mean -0.5% minimum -2.3% maximum +0.2% ``` Metric Decrease: CoOpt_Read T12150 T12425 T13056 T21839c T21839r T9961 - - - - - 7 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Data/Graph/Directed.hs - compiler/GHC/Utils/Misc.hs - + testsuite/tests/simplCore/should_compile/T22428.hs - + testsuite/tests/simplCore/should_compile/T22428.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -132,6 +132,9 @@ joinRhsArity :: CoreExpr -> JoinArity -- Join points are supposed to have manifestly-visible -- lambdas at the top: no ticks, no casts, nothing -- Moreover, type lambdas count in JoinArity +-- NB: For non-recursive bindings, the join arity of the binding may actually be +-- less that the number of manifestly-visible lambdas. +-- See Note [Join arity prediction based on joinRhsArity] in GHC.Core.Opt.OccurAnal joinRhsArity (Lam _ e) = 1 + joinRhsArity e joinRhsArity _ = 0 ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -59,7 +59,7 @@ import GHC.Builtin.Names( runRWKey ) import GHC.Unit.Module( Module ) import Data.List (mapAccumL, mapAccumR) -import Data.List.NonEmpty (NonEmpty (..), nonEmpty) +import Data.List.NonEmpty (NonEmpty (..)) import qualified Data.List.NonEmpty as NE {- @@ -510,6 +510,16 @@ of the file. at any of the definitions. This is done by Simplify.simplRecBind, when it calls addLetIdInfo. +Note [TailUsageDetails when forming Rec groups] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `TailUsageDetails` stored in the `nd_uds` field of a `NodeDetails` is +computed by `occAnalLamTail` applied to the RHS, not `occAnalExpr`. +That is because the binding might still become a *non-recursive join point* in +the AcyclicSCC case of dependency analysis! +Hence we do the delayed `adjustTailUsage` in `occAnalRec`/`tagRecBinders` to get +a regular, adjusted UsageDetails. +See Note [Join points and unfoldings/rules] for more details on the contract. + Note [Stable unfoldings] ~~~~~~~~~~~~~~~~~~~~~~~~ None of the above stuff about RULES applies to a stable unfolding @@ -608,6 +618,65 @@ tail call with `n` arguments (counting both value and type arguments). Otherwise 'occ_tail' will be 'NoTailCallInfo'. The tail call info flows bottom-up with the rest of 'OccInfo' until it goes on the binder. +Note [Join arity prediction based on joinRhsArity] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In general, the join arity from tail occurrences of a join point (O) may be +higher or lower than the manifest join arity of the join body (M). E.g., + + -- M > O: + let f x y = x + y -- M = 2 + in if b then f 1 else f 2 -- O = 1 + ==> { Contify for join arity 1 } + join f x = \y -> x + y + in if b then jump f 1 else jump f 2 + + -- M < O + let f = id -- M = 0 + in if ... then f 12 else f 13 -- O = 1 + ==> { Contify for join arity 1, eta-expand f } + join f x = id x + in if b then jump f 12 else jump f 13 + +But for *recursive* let, it is crucial that both arities match up, consider + + letrec f x y = if ... then f x else True + in f 42 + +Here, M=2 but O=1. If we settled for a joinrec arity of 1, the recursive jump +would not happen in a tail context! Contification is invalid here. +So indeed it is crucial to demand that M=O. + +(Side note: Actually, we could be more specific: Let O1 be the join arity of +occurrences from the letrec RHS and O2 the join arity from the let body. Then +we need M=O1 and M<=O2 and could simply eta-expand the RHS to match O2 later. +M=O is the specific case where we don't want to eta-expand. Neither the join +points paper nor GHC does this at the moment.) + +We can capitalise on this observation and conclude that *if* f could become a +joinrec (without eta-expansion), it will have join arity M. +Now, M is just the result of 'joinRhsArity', a rather simple, local analysis. +It is also the join arity inside the 'TailUsageDetails' returned by +'occAnalLamTail', so we can predict join arity without doing any fixed-point +iteration or really doing any deep traversal of let body or RHS at all. +We check for M in the 'adjustTailUsage' call inside 'tagRecBinders'. + +All this is quite apparent if you look at the contification transformation in +Fig. 5 of "Compiling without Continuations" (which does not account for +eta-expansion at all, mind you). The letrec case looks like this + + letrec f = /\as.\xs. L[us] in L'[es] + ... and a bunch of conditions establishing that f only occurs + in app heads of join arity (len as + len xs) inside us and es ... + +The syntactic form `/\as.\xs. L[us]` forces M=O iff `f` occurs in `us`. However, +for non-recursive functions, this is the definition of contification from the +paper: + + let f = /\as.\xs.u in L[es] ... conditions ... + +Note that u could be a lambda itself, as we have seen. No relationship between M +and O to exploit here. + Note [Join points and unfoldings/rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider @@ -618,8 +687,10 @@ Consider Before j is inlined, we'll have occurrences of j2 in both j's RHS and in its stable unfolding. We want to discover -j2 as a join point. So we must do the adjustRhsUsage thing -on j's RHS. That's why we pass mb_join_arity to calcUnfolding. +j2 as a join point. So 'occAnalUnfolding' returns an unadjusted +'TailUsageDetails', like 'occAnalLamTail'. We adjust the usage details of the +unfolding to the actual join arity using the same 'adjustTailArity' as for +the RHS, see Note [Adjusting right-hand sides]. Same with rules. Suppose we have: @@ -636,14 +707,31 @@ up. So provided the join-point arity of k matches the args of the rule we can allow the tail-call info from the RHS of the rule to propagate. -* Wrinkle for Rec case. In the recursive case we don't know the - join-point arity in advance, when calling occAnalUnfolding and - occAnalRules. (See makeNode.) We don't want to pass Nothing, - because then a recursive joinrec might lose its join-poin-hood - when SpecConstr adds a RULE. So we just make do with the - *current* join-poin-hood, stored in the Id. +* Note that the join arity of the RHS and that of the unfolding or RULE might + mismatch: + + let j x y = j2 (x+x) + {-# INLINE[2] j = \x. g #-} + {-# RULE forall x y z. j x y z = h 17 #-} + in j 1 2 - In the non-recursive case things are simple: see occAnalNonRecBind + So it is crucial that we adjust each TailUsageDetails individually + with the actual join arity 2 here before we combine with `andUDs`. + Here, that means losing tail call info on `g` and `h`. + +* Wrinkle for Rec case: We store one TailUsageDetails in the node Details for + RHS, unfolding and RULE combined. Clearly, if they don't agree on their join + arity, we have to do some adjusting. We choose to adjust to the join arity + of the RHS, because that is likely the join arity that the join point will + have; see Note [Join arity prediction based on joinRhsArity]. + + If the guess is correct, then tail calls in the RHS are preserved; a necessary + condition for the whole binding becoming a joinrec. + The guess can only be incorrect in the 'AcyclicSCC' case when the binding + becomes a non-recursive join point with a different join arity. But then the + eventual call to 'adjustTailUsage' in 'tagRecBinders'/'occAnalRec' will + be with a different join arity and destroy unsound tail call info with + 'markNonTail'. * Wrinkle for RULES. Suppose the example was a bit different: let j :: Int -> Int @@ -669,28 +757,21 @@ propagate. This appears to be very rare in practice. TODO Perhaps we should gather statistics to be sure. -Note [Unfoldings and join points] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We assume that anything in an unfolding occurs multiple times, since -unfoldings are often copied (that's the whole point!). But we still -need to track tail calls for the purpose of finding join points. - - ------------------------------------------------------------ Note [Adjusting right-hand sides] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There's a bit of a dance we need to do after analysing a lambda expression or a right-hand side. In particular, we need to - a) call 'markAllInsideLam' *unless* the binding is for a thunk, a one-shot - lambda, or a non-recursive join point; and - b) call 'markAllNonTail' *unless* the binding is for a join point, and - the RHS has the right arity; e.g. + a) call 'markAllNonTail' *unless* the binding is for a join point, and + the TailUsageDetails from the RHS has the right join arity; e.g. join j x y = case ... of A -> j2 p B -> j2 q in j a b Here we want the tail calls to j2 to be tail calls of the whole expression + b) call 'markAllInsideLam' *unless* the binding is for a thunk, a one-shot + lambda, or a non-recursive join point Some examples, with how the free occurrences in e (assumed not to be a value lambda) get marked: @@ -707,26 +788,39 @@ lambda) get marked: There are a few other caveats; most importantly, if we're marking a binding as 'AlwaysTailCalled', it's *going* to be a join point, so we treat it as one so that the effect cascades properly. Consequently, at the time the RHS is -analysed, we won't know what adjustments to make; thus 'occAnalLamOrRhs' must -return the unadjusted 'UsageDetails', to be adjusted by 'adjustRhsUsage' once -join-point-hood has been decided. - -Thus the overall sequence taking place in 'occAnalNonRecBind' and -'occAnalRecBind' is as follows: - - 1. Call 'occAnalLamOrRhs' to find usage information for the RHS. - 2. Call 'tagNonRecBinder' or 'tagRecBinders', which decides whether to make +analysed, we won't know what adjustments to make; thus 'occAnalLamTail' must +return the unadjusted 'TailUsageDetails', to be adjusted by 'adjustTailUsage' +once join-point-hood has been decided and eventual one-shot annotations have +been added through 'markNonRecJoinOneShots'. + +It is not so simple to see that 'occAnalNonRecBind' and 'occAnalRecBind' indeed +perform a similar sequence of steps. Thus, here is an interleaving of events +of both functions, serving as a specification: + + 1. Call 'occAnalLamTail' to find usage information for the RHS. + Recursive case: 'makeNode' + Non-recursive case: 'occAnalNonRecBind' + 2. (Analyse the binding's scope. Done in 'occAnalBind'/`occAnal Let{}`. + Same whether recursive or not.) + 3. Call 'tagNonRecBinder' or 'tagRecBinders', which decides whether to make the binding a join point. - 3. Call 'adjustRhsUsage' accordingly. (Done as part of 'tagRecBinders' when - recursive.) - -(In the recursive case, this logic is spread between 'makeNode' and -'occAnalRec'.) + Cyclic Recursive case: 'mkLoopBreakerNodes' + Acyclic Recursive case: `occAnalRec AcyclicSCC{}` + Non-recursive case: 'occAnalNonRecBind' + 4. Non-recursive join point: Call 'markNonRecJoinOneShots' so that e.g., + FloatOut sees one-shot annotations on lambdas + Acyclic Recursive case: `occAnalRec AcyclicSCC{}` calls 'adjustNonRecRhs' + Non-recursive case: 'occAnalNonRecBind' calls 'adjustNonRecRhs' + 5. Call 'adjustTailUsage' accordingly. + Cyclic Recursive case: 'tagRecBinders' + Acyclic Recursive case: 'adjustNonRecRhs' + Non-recursive case: 'adjustNonRecRhs' -} - data WithUsageDetails a = WithUsageDetails !UsageDetails !a +data WithTailUsageDetails a = WithTailUsageDetails !TailUsageDetails !a + ------------------------------------------------------------------ -- occAnalBind ------------------------------------------------------------------ @@ -750,19 +844,17 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage | isTyVar bndr -- A type let; we don't gather usage info = WithUsageDetails body_usage [NonRec bndr rhs] - | not (bndr `usedIn` body_usage) -- It's not mentioned - = WithUsageDetails body_usage [] + | not (bndr `usedIn` body_usage) + = WithUsageDetails body_usage [] -- See Note [Dead code] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr rhs'] + = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr final_rhs] where - (body_usage', tagged_bndr) = tagNonRecBinder lvl body_usage bndr - final_bndr = tagged_bndr `setIdUnfolding` unf' - `setIdSpecialisation` mkRuleInfo rules' - rhs_usage = rhs_uds `andUDs` unf_uds `andUDs` rule_uds + WithUsageDetails body_usage' tagged_bndr = tagNonRecBinder lvl body_usage bndr -- Get the join info from the *new* decision -- See Note [Join points and unfoldings/rules] + -- => join arity O of Note [Join arity prediction based on joinRhsArity] mb_join_arity = willBeJoinId_maybe tagged_bndr is_join_point = isJust mb_join_arity @@ -773,17 +865,28 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- See Note [Sources of one-shot information] rhs_env = env1 { occ_one_shots = argOneShots dmd } - (WithUsageDetails rhs_uds rhs') = occAnalRhs rhs_env NonRecursive mb_join_arity rhs + -- See Note [Join arity prediction based on joinRhsArity] + -- Match join arity O from mb_join_arity with manifest join arity M as + -- returned by of occAnalLamTail. It's totally OK for them to mismatch; + -- hence adjust the UDs from the RHS + WithUsageDetails adj_rhs_uds final_rhs + = adjustNonRecRhs mb_join_arity $ occAnalLamTail rhs_env rhs + rhs_usage = adj_rhs_uds `andUDs` adj_unf_uds `andUDs` adj_rule_uds + final_bndr = tagged_bndr `setIdSpecialisation` mkRuleInfo rules' + `setIdUnfolding` unf2 --------- Unfolding --------- - -- See Note [Unfoldings and join points] + -- See Note [Join points and unfoldings/rules] unf | isId bndr = idUnfolding bndr | otherwise = NoUnfolding - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env NonRecursive mb_join_arity unf + WithTailUsageDetails unf_uds unf1 = occAnalUnfolding rhs_env unf + unf2 = markNonRecUnfoldingOneShots mb_join_arity unf1 + adj_unf_uds = adjustTailArity mb_join_arity unf_uds --------- Rules --------- -- See Note [Rules are extra RHSs] and Note [Rule dependency info] - rules_w_uds = occAnalRules rhs_env mb_join_arity bndr + -- and Note [Join points and unfoldings/rules] + rules_w_uds = occAnalRules rhs_env bndr rules' = map fstOf3 rules_w_uds imp_rule_uds = impRulesScopeUsage (lookupImpRules imp_rule_edges bndr) -- imp_rule_uds: consider @@ -794,8 +897,9 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- that g is (since the RULE might turn g into h), so -- we make g mention h. - rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds - add_rule_uds (_, l, r) uds = l `andUDs` r `andUDs` uds + adj_rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds + add_rule_uds (_, l, r) uds + = l `andUDs` adjustTailArity mb_join_arity r `andUDs` uds ---------- occ = idOccInfo tagged_bndr @@ -820,7 +924,7 @@ occAnalRecBind :: OccEnv -> TopLevelFlag -> ImpRuleEdges -> [(Var,CoreExpr)] occAnalRecBind !env lvl imp_rule_edges pairs body_usage = foldr (occAnalRec rhs_env lvl) (WithUsageDetails body_usage []) sccs where - sccs :: [SCC Details] + sccs :: [SCC NodeDetails] sccs = {-# SCC "occAnalBind.scc" #-} stronglyConnCompFromEdgedVerticesUniq nodes @@ -832,27 +936,41 @@ occAnalRecBind !env lvl imp_rule_edges pairs body_usage bndr_set = mkVarSet bndrs rhs_env = env `addInScope` bndrs +adjustNonRecRhs :: Maybe JoinArity -> WithTailUsageDetails CoreExpr -> WithUsageDetails CoreExpr +-- ^ This function concentrates shared logic between occAnalNonRecBind and the +-- AcyclicSCC case of occAnalRec. +-- * It applies 'markNonRecJoinOneShots' to the RHS +-- * and returns the adjusted rhs UsageDetails combined with the body usage +adjustNonRecRhs mb_join_arity (WithTailUsageDetails rhs_tuds rhs) + = WithUsageDetails rhs_uds' rhs' + where + --------- Marking (non-rec) join binders one-shot --------- + !rhs' | Just ja <- mb_join_arity = markNonRecJoinOneShots ja rhs + | otherwise = rhs + --------- Adjusting right-hand side usage --------- + rhs_uds' = adjustTailUsage mb_join_arity rhs' rhs_tuds ----------------------------- occAnalRec :: OccEnv -> TopLevelFlag - -> SCC Details + -> SCC NodeDetails -> WithUsageDetails [CoreBind] -> WithUsageDetails [CoreBind] -- The NonRec case is just like a Let (NonRec ...) above -occAnalRec !_ lvl (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = rhs - , nd_uds = rhs_uds })) +occAnalRec !_ lvl + (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = wtuds })) (WithUsageDetails body_uds binds) | not (bndr `usedIn` body_uds) = WithUsageDetails body_uds binds -- See Note [Dead code] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_uds' `andUDs` rhs_uds') - (NonRec tagged_bndr rhs : binds) + = WithUsageDetails (body_uds' `andUDs` rhs_uds') (NonRec bndr' rhs' : binds) where - (body_uds', tagged_bndr) = tagNonRecBinder lvl body_uds bndr - rhs_uds' = adjustRhsUsage mb_join_arity rhs rhs_uds + WithUsageDetails body_uds' tagged_bndr = tagNonRecBinder lvl body_uds bndr mb_join_arity = willBeJoinId_maybe tagged_bndr + WithUsageDetails rhs_uds' rhs' = adjustNonRecRhs mb_join_arity wtuds + !unf' = markNonRecUnfoldingOneShots mb_join_arity (idUnfolding tagged_bndr) + !bndr' = tagged_bndr `setIdUnfolding` unf' -- The Rec case is the interesting one -- See Note [Recursive bindings: the grand plan] @@ -873,7 +991,7 @@ occAnalRec env lvl (CyclicSCC details_s) (WithUsageDetails body_uds binds) -- Make the nodes for the loop-breaker analysis -- See Note [Choosing loop breakers] for loop_breaker_nodes final_uds :: UsageDetails - loop_breaker_nodes :: [LetrecNode] + loop_breaker_nodes :: [LoopBreakerNode] (WithUsageDetails final_uds loop_breaker_nodes) = mkLoopBreakerNodes env lvl body_uds details_s ------------------------------ @@ -1102,7 +1220,7 @@ type Binding = (Id,CoreExpr) loopBreakNodes :: Int -> VarSet -- Binders whose dependencies may be "missing" -- See Note [Weak loop breakers] - -> [LetrecNode] + -> [LoopBreakerNode] -> [Binding] -- Append these to the end -> [Binding] @@ -1121,7 +1239,7 @@ loopBreakNodes depth weak_fvs nodes binds CyclicSCC nodes -> reOrderNodes depth weak_fvs nodes binds ---------------------------------- -reOrderNodes :: Int -> VarSet -> [LetrecNode] -> [Binding] -> [Binding] +reOrderNodes :: Int -> VarSet -> [LoopBreakerNode] -> [Binding] -> [Binding] -- Choose a loop breaker, mark it no-inline, -- and call loopBreakNodes on the rest reOrderNodes _ _ [] _ = panic "reOrderNodes" @@ -1133,7 +1251,7 @@ reOrderNodes depth weak_fvs (node : nodes) binds (map (nodeBinding mk_loop_breaker) chosen_nodes ++ binds) where (chosen_nodes, unchosen) = chooseLoopBreaker approximate_lb - (nd_score (node_payload node)) + (snd_score (node_payload node)) [node] [] nodes approximate_lb = depth >= 2 @@ -1142,8 +1260,8 @@ reOrderNodes depth weak_fvs (node : nodes) binds -- After two iterations (d=0, d=1) give up -- and approximate, returning to d=0 -nodeBinding :: (Id -> Id) -> LetrecNode -> Binding -nodeBinding set_id_occ (node_payload -> ND { nd_bndr = bndr, nd_rhs = rhs}) +nodeBinding :: (Id -> Id) -> LoopBreakerNode -> Binding +nodeBinding set_id_occ (node_payload -> SND { snd_bndr = bndr, snd_rhs = rhs}) = (set_id_occ bndr, rhs) mk_loop_breaker :: Id -> Id @@ -1163,13 +1281,13 @@ mk_non_loop_breaker weak_fvs bndr tail_info = tailCallInfo (idOccInfo bndr) ---------------------------------- -chooseLoopBreaker :: Bool -- True <=> Too many iterations, - -- so approximate - -> NodeScore -- Best score so far - -> [LetrecNode] -- Nodes with this score - -> [LetrecNode] -- Nodes with higher scores - -> [LetrecNode] -- Unprocessed nodes - -> ([LetrecNode], [LetrecNode]) +chooseLoopBreaker :: Bool -- True <=> Too many iterations, + -- so approximate + -> NodeScore -- Best score so far + -> [LoopBreakerNode] -- Nodes with this score + -> [LoopBreakerNode] -- Nodes with higher scores + -> [LoopBreakerNode] -- Unprocessed nodes + -> ([LoopBreakerNode], [LoopBreakerNode]) -- This loop looks for the bind with the lowest score -- to pick as the loop breaker. The rest accumulate in chooseLoopBreaker _ _ loop_nodes acc [] @@ -1189,7 +1307,7 @@ chooseLoopBreaker approx_lb loop_sc loop_nodes acc (node : nodes) | otherwise -- Worse score so don't pick it = chooseLoopBreaker approx_lb loop_sc loop_nodes (node : acc) nodes where - sc = nd_score (node_payload node) + sc = snd_score (node_payload node) {- Note [Complexity of loop breaking] @@ -1322,16 +1440,21 @@ ToDo: try using the occurrence info for the inline'd binder. ************************************************************************ -} -type LetrecNode = Node Unique Details -- Node comes from Digraph - -- The Unique key is gotten from the Id -data Details - = ND { nd_bndr :: Id -- Binder +-- | Digraph node as constructed by 'makeNode' and consumed by 'occAnalRec'. +-- The Unique key is gotten from the Id. +type LetrecNode = Node Unique NodeDetails - , nd_rhs :: CoreExpr -- RHS, already occ-analysed +-- | Node details as consumed by 'occAnalRec'. +data NodeDetails + = ND { nd_bndr :: Id -- Binder - , nd_uds :: UsageDetails -- Usage from RHS, and RULES, and stable unfoldings - -- ignoring phase (ie assuming all are active) - -- See Note [Forming Rec groups] + , nd_rhs :: !(WithTailUsageDetails CoreExpr) + -- ^ RHS, already occ-analysed + -- With TailUsageDetails from RHS, and RULES, and stable unfoldings, + -- ignoring phase (ie assuming all are active). + -- NB: Unadjusted TailUsageDetails, as if this Node becomes a + -- non-recursive join point! + -- See Note [TailUsageDetails when forming Rec groups] , nd_inl :: IdSet -- Free variables of the stable unfolding and the RHS -- but excluding any RULES @@ -1348,18 +1471,33 @@ data Details , nd_active_rule_fvs :: IdSet -- Variables bound in this Rec group that are free -- in the RHS of an active rule for this bndr -- See Note [Rules and loop breakers] - - , nd_score :: NodeScore } -instance Outputable Details where +instance Outputable NodeDetails where ppr nd = text "ND" <> braces (sep [ text "bndr =" <+> ppr (nd_bndr nd) - , text "uds =" <+> ppr (nd_uds nd) + , text "uds =" <+> ppr uds , text "inl =" <+> ppr (nd_inl nd) , text "simple =" <+> ppr (nd_simple nd) , text "active_rule_fvs =" <+> ppr (nd_active_rule_fvs nd) - , text "score =" <+> ppr (nd_score nd) + ]) + where WithTailUsageDetails uds _ = nd_rhs nd + +-- | Digraph with simplified and completely occurrence analysed +-- 'SimpleNodeDetails', retaining just the info we need for breaking loops. +type LoopBreakerNode = Node Unique SimpleNodeDetails + +-- | Condensed variant of 'NodeDetails' needed during loop breaking. +data SimpleNodeDetails + = SND { snd_bndr :: IdWithOccInfo -- OccInfo accurate + , snd_rhs :: CoreExpr -- properly occur-analysed + , snd_score :: NodeScore + } + +instance Outputable SimpleNodeDetails where + ppr nd = text "SND" <> braces + (sep [ text "bndr =" <+> ppr (snd_bndr nd) + , text "score =" <+> ppr (snd_score nd) ]) -- The NodeScore is compared lexicographically; @@ -1387,52 +1525,59 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) -- explained in Note [Deterministic SCC] in GHC.Data.Graph.Directed. where details = ND { nd_bndr = bndr' - , nd_rhs = rhs' - , nd_uds = scope_uds + , nd_rhs = WithTailUsageDetails scope_uds rhs' , nd_inl = inl_fvs , nd_simple = null rules_w_uds && null imp_rule_info , nd_weak_fvs = weak_fvs - , nd_active_rule_fvs = active_rule_fvs - , nd_score = pprPanic "makeNodeDetails" (ppr bndr) } + , nd_active_rule_fvs = active_rule_fvs } bndr' = bndr `setIdUnfolding` unf' `setIdSpecialisation` mkRuleInfo rules' - inl_uds = rhs_uds `andUDs` unf_uds - scope_uds = inl_uds `andUDs` rule_uds + -- NB: Both adj_unf_uds and adj_rule_uds have been adjusted to match the + -- JoinArity rhs_ja of unadj_rhs_uds. + unadj_inl_uds = unadj_rhs_uds `andUDs` adj_unf_uds + unadj_scope_uds = unadj_inl_uds `andUDs` adj_rule_uds + scope_uds = TUD rhs_ja unadj_scope_uds -- Note [Rules are extra RHSs] -- Note [Rule dependency info] - scope_fvs = udFreeVars bndr_set scope_uds + scope_fvs = udFreeVars bndr_set unadj_scope_uds -- scope_fvs: all occurrences from this binder: RHS, unfolding, -- and RULES, both LHS and RHS thereof, active or inactive - inl_fvs = udFreeVars bndr_set inl_uds + inl_fvs = udFreeVars bndr_set unadj_inl_uds -- inl_fvs: vars that would become free if the function was inlined. -- We conservatively approximate that by thefree vars from the RHS -- and the unfolding together. -- See Note [inl_fvs] - mb_join_arity = isJoinId_maybe bndr - -- Get join point info from the *current* decision - -- We don't know what the new decision will be! - -- Using the old decision at least allows us to - -- preserve existing join point, even RULEs are added - -- See Note [Join points and unfoldings/rules] --------- Right hand side --------- -- Constructing the edges for the main Rec computation -- See Note [Forming Rec groups] - -- Do not use occAnalRhs because we don't yet know the final - -- answer for mb_join_arity; instead, do the occAnalLam call from - -- occAnalRhs, and postpone adjustRhsUsage until occAnalRec - rhs_env = rhsCtxt env - (WithUsageDetails rhs_uds rhs') = occAnalLam rhs_env rhs + -- and Note [TailUsageDetails when forming Rec groups] + -- Compared to occAnalNonRecBind, we can't yet adjust the RHS because + -- (a) we don't yet know the final joinpointhood. It might not become a + -- join point after all! + -- (b) we don't even know whether it stays a recursive RHS after the SCC + -- analysis we are about to seed! So we can't markAllInsideLam in + -- advance, because if it ends up as a non-recursive join point we'll + -- consider it as one-shot and don't need to markAllInsideLam. + -- Instead, do the occAnalLamTail call here and postpone adjustTailUsage + -- until occAnalRec. In effect, we pretend that the RHS becomes a + -- non-recursive join point and fix up later with adjustTailUsage. + rhs_env = rhsCtxt env + WithTailUsageDetails (TUD rhs_ja unadj_rhs_uds) rhs' = occAnalLamTail rhs_env rhs + -- corresponding call to adjustTailUsage in occAnalRec and tagRecBinders --------- Unfolding --------- - -- See Note [Unfoldings and join points] + -- See Note [Join points and unfoldings/rules] unf = realIdUnfolding bndr -- realIdUnfolding: Ignore loop-breaker-ness -- here because that is what we are setting! - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env Recursive mb_join_arity unf + WithTailUsageDetails unf_tuds unf' = occAnalUnfolding rhs_env unf + adj_unf_uds = adjustTailArity (Just rhs_ja) unf_tuds + -- `rhs_ja` is `joinRhsArity rhs` and is the prediction for source M + -- of Note [Join arity prediction based on joinRhsArity] --------- IMP-RULES -------- is_active = occ_rule_act env :: Activation -> Bool @@ -1441,11 +1586,15 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) imp_rule_fvs = impRulesActiveFvs is_active bndr_set imp_rule_info --------- All rules -------- + -- See Note [Join points and unfoldings/rules] + -- `rhs_ja` is `joinRhsArity rhs'` and is the prediction for source M + -- of Note [Join arity prediction based on joinRhsArity] rules_w_uds :: [(CoreRule, UsageDetails, UsageDetails)] - rules_w_uds = occAnalRules rhs_env mb_join_arity bndr + rules_w_uds = [ (r,l,adjustTailArity (Just rhs_ja) rhs_tuds) + | (r,l,rhs_tuds) <- occAnalRules rhs_env bndr ] rules' = map fstOf3 rules_w_uds - rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds + adj_rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds add_rule_uds (_, l, r) uds = l `andUDs` r `andUDs` uds -------- active_rule_fvs ------------ @@ -1463,8 +1612,8 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) mkLoopBreakerNodes :: OccEnv -> TopLevelFlag -> UsageDetails -- for BODY of let - -> [Details] - -> WithUsageDetails [LetrecNode] -- adjusted + -> [NodeDetails] + -> WithUsageDetails [LoopBreakerNode] -- with OccInfo up-to-date -- See Note [Choosing loop breakers] -- This function primarily creates the Nodes for the -- loop-breaker SCC analysis. More specifically: @@ -1477,10 +1626,10 @@ mkLoopBreakerNodes :: OccEnv -> TopLevelFlag mkLoopBreakerNodes !env lvl body_uds details_s = WithUsageDetails final_uds (zipWithEqual "mkLoopBreakerNodes" mk_lb_node details_s bndrs') where - (final_uds, bndrs') = tagRecBinders lvl body_uds details_s + WithUsageDetails final_uds bndrs' = tagRecBinders lvl body_uds details_s mk_lb_node nd@(ND { nd_bndr = old_bndr, nd_inl = inl_fvs }) new_bndr - = DigraphNode { node_payload = new_nd + = DigraphNode { node_payload = simple_nd , node_key = varUnique old_bndr , node_dependencies = nonDetKeysUniqSet lb_deps } -- It's OK to use nonDetKeysUniqSet here as @@ -1488,7 +1637,8 @@ mkLoopBreakerNodes !env lvl body_uds details_s -- in nondeterministic order as explained in -- Note [Deterministic SCC] in GHC.Data.Graph.Directed. where - new_nd = nd { nd_bndr = new_bndr, nd_score = score } + WithTailUsageDetails _ rhs = nd_rhs nd + simple_nd = SND { snd_bndr = new_bndr, snd_rhs = rhs, snd_score = score } score = nodeScore env new_bndr lb_deps nd lb_deps = extendFvs_ rule_fv_env inl_fvs -- See Note [Loop breaker dependencies] @@ -1524,10 +1674,10 @@ group { f1 = e1; ...; fn = en } are: nodeScore :: OccEnv -> Id -- Binder with new occ-info -> VarSet -- Loop-breaker dependencies - -> Details + -> NodeDetails -> NodeScore nodeScore !env new_bndr lb_deps - (ND { nd_bndr = old_bndr, nd_rhs = bind_rhs }) + (ND { nd_bndr = old_bndr, nd_rhs = WithTailUsageDetails _ bind_rhs }) | not (isId old_bndr) -- A type or coercion variable is never a loop breaker = (100, 0, False) @@ -1748,7 +1898,7 @@ lambda and casts, e.g. * Occurrence analyser: we just mark each binder in the lambda-group (here: x,y,z) with its occurrence info in the *body* of the - lambda-group. See occAnalLam. + lambda-group. See occAnalLamTail. * Simplifier. The simplifier is careful when partially applying lambda-groups. See the call to zapLambdaBndrs in @@ -1804,25 +1954,31 @@ zapLambdaBndrs fun arg_count zap_bndr b | isTyVar b = b | otherwise = zapLamIdInfo b -occAnalLam :: OccEnv -> CoreExpr -> (WithUsageDetails CoreExpr) --- See Note [Occurrence analysis for lambda binders] +occAnalLamTail :: OccEnv -> CoreExpr -> WithTailUsageDetails CoreExpr +-- ^ See Note [Occurrence analysis for lambda binders]. -- It does the following: -- * Sets one-shot info on the lambda binder from the OccEnv, and -- removes that one-shot info from the OccEnv -- * Sets the OccEnv to OccVanilla when going under a value lambda -- * Tags each lambda with its occurrence information -- * Walks through casts +-- * Package up the analysed lambda with its manifest join arity +-- -- This function does /not/ do -- markAllInsideLam or -- markAllNonTail --- The caller does that, either in occAnal (Lam {}), or in adjustRhsUsage +-- The caller does that, via adjustTailUsage (mostly calls go through +-- adjustNonRecRhs). Every call to occAnalLamTail must ultimately call +-- adjustTailUsage to discharge the assumed join arity. +-- +-- In effect, the analysis result is for a non-recursive join point with +-- manifest arity and adjustTailUsage does the fixup. -- See Note [Adjusting right-hand sides] - -occAnalLam env (Lam bndr expr) +occAnalLamTail env (Lam bndr expr) | isTyVar bndr - = let env1 = addOneInScope env bndr - WithUsageDetails usage expr' = occAnalLam env1 expr - in WithUsageDetails usage (Lam bndr expr') + , let env1 = addOneInScope env bndr + , WithTailUsageDetails (TUD ja usage) expr' <- occAnalLamTail env1 expr + = WithTailUsageDetails (TUD (ja+1) usage) (Lam bndr expr') -- Important: Keep the 'env' unchanged so that with a RHS like -- \(@ x) -> K @x (f @x) -- we'll see that (K @x (f @x)) is in a OccRhs, and hence refrain @@ -1840,14 +1996,14 @@ occAnalLam env (Lam bndr expr) env1 = env { occ_encl = OccVanilla, occ_one_shots = env_one_shots' } env2 = addOneInScope env1 bndr - (WithUsageDetails usage expr') = occAnalLam env2 expr + WithTailUsageDetails (TUD ja usage) expr' = occAnalLamTail env2 expr (usage', bndr2) = tagLamBinder usage bndr1 - in WithUsageDetails usage' (Lam bndr2 expr') + in WithTailUsageDetails (TUD (ja+1) usage') (Lam bndr2 expr') -- For casts, keep going in the same lambda-group -- See Note [Occurrence analysis for lambda binders] -occAnalLam env (Cast expr co) - = let (WithUsageDetails usage expr') = occAnalLam env expr +occAnalLamTail env (Cast expr co) + = let WithTailUsageDetails (TUD ja usage) expr' = occAnalLamTail env expr -- usage1: see Note [Gather occurrences of coercion variables] usage1 = addManyOccs usage (coVarsOfCo co) @@ -1857,15 +2013,16 @@ occAnalLam env (Cast expr co) _ -> usage1 -- usage3: you might think this was not necessary, because of - -- the markAllNonTail in adjustRhsUsage; but not so! For a - -- join point, adjustRhsUsage doesn't do this; yet if there is + -- the markAllNonTail in adjustTailUsage; but not so! For a + -- join point, adjustTailUsage doesn't do this; yet if there is -- a cast, we must! Also: why markAllNonTail? See -- GHC.Core.Lint: Note Note [Join points and casts] usage3 = markAllNonTail usage2 - in WithUsageDetails usage3 (Cast expr' co) + in WithTailUsageDetails (TUD ja usage3) (Cast expr' co) -occAnalLam env expr = occAnal env expr +occAnalLamTail env expr = case occAnal env expr of + WithUsageDetails usage expr' -> WithTailUsageDetails (TUD 0 usage) expr' {- Note [Occ-anal and cast worker/wrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1885,8 +2042,8 @@ RHS. So it'll get a Many occ-info. (Maybe Cast w/w should create a stable unfolding, which would obviate this Note; but that seems a bit of a heavyweight solution.) -We only need to this in occAnalLam, not occAnal, because the top leve -of a right hand side is handled by occAnalLam. +We only need to this in occAnalLamTail, not occAnal, because the top leve +of a right hand side is handled by occAnalLamTail. -} @@ -1896,57 +2053,23 @@ of a right hand side is handled by occAnalLam. * * ********************************************************************* -} -occAnalRhs :: OccEnv -> RecFlag -> Maybe JoinArity - -> CoreExpr -- RHS - -> WithUsageDetails CoreExpr -occAnalRhs !env is_rec mb_join_arity rhs - = let (WithUsageDetails usage rhs1) = occAnalLam env rhs - -- We call occAnalLam here, not occAnalExpr, so that it doesn't - -- do the markAllInsideLam and markNonTailCall stuff before - -- we've had a chance to help with join points; that comes next - rhs2 = markJoinOneShots is_rec mb_join_arity rhs1 - rhs_usage = adjustRhsUsage mb_join_arity rhs2 usage - in WithUsageDetails rhs_usage rhs2 - - - -markJoinOneShots :: RecFlag -> Maybe JoinArity -> CoreExpr -> CoreExpr --- For a /non-recursive/ join point we can mark all --- its join-lambda as one-shot; and it's a good idea to do so -markJoinOneShots NonRecursive (Just join_arity) rhs - = go join_arity rhs - where - go 0 rhs = rhs - go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) - (go (n-1) rhs) - go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. - -- e.g. let j = case ... in j True - -- This will become an arity-1 join point after the - -- simplifier has eta-expanded it; but it may not have - -- enough lambdas /yet/. (Lint checks that JoinIds do - -- have enough lambdas.) -markJoinOneShots _ _ rhs - = rhs - occAnalUnfolding :: OccEnv - -> RecFlag - -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Unfolding - -> WithUsageDetails Unfolding + -> WithTailUsageDetails Unfolding -- Occurrence-analyse a stable unfolding; --- discard a non-stable one altogether. -occAnalUnfolding !env is_rec mb_join_arity unf +-- discard a non-stable one altogether and return empty usage details. +occAnalUnfolding !env unf = case unf of unf@(CoreUnfolding { uf_tmpl = rhs, uf_src = src }) | isStableSource src -> let - (WithUsageDetails usage rhs') = occAnalRhs env is_rec mb_join_arity rhs + WithTailUsageDetails (TUD rhs_ja usage) rhs' = occAnalLamTail env rhs unf' | noBinderSwaps env = unf -- Note [Unfoldings and rules] | otherwise = unf { uf_tmpl = rhs' } - in WithUsageDetails (markAllMany usage) unf' + in WithTailUsageDetails (TUD rhs_ja (markAllMany usage)) unf' -- markAllMany: see Note [Occurrences in stable unfoldings] - | otherwise -> WithUsageDetails emptyDetails unf + | otherwise -> WithTailUsageDetails (TUD 0 emptyDetails) unf -- For non-Stable unfoldings we leave them undisturbed, but -- don't count their usage because the simplifier will discard them. -- We leave them undisturbed because nodeScore uses their size info @@ -1955,29 +2078,26 @@ occAnalUnfolding !env is_rec mb_join_arity unf -- scope remain in scope; there is no cloning etc. unf@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) - -> WithUsageDetails final_usage (unf { df_args = args' }) + -> WithTailUsageDetails (TUD 0 final_usage) (unf { df_args = args' }) where env' = env `addInScope` bndrs (WithUsageDetails usage args') = occAnalList env' args - final_usage = markAllManyNonTail (delDetailsList usage bndrs) - `addLamCoVarOccs` bndrs - `delDetailsList` bndrs + final_usage = usage `addLamCoVarOccs` bndrs `delDetailsList` bndrs -- delDetailsList; no need to use tagLamBinders because we -- never inline DFuns so the occ-info on binders doesn't matter - unf -> WithUsageDetails emptyDetails unf + unf -> WithTailUsageDetails (TUD 0 emptyDetails) unf occAnalRules :: OccEnv - -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Id -- Get rules from here -> [(CoreRule, -- Each (non-built-in) rule UsageDetails, -- Usage details for LHS - UsageDetails)] -- Usage details for RHS -occAnalRules !env mb_join_arity bndr + TailUsageDetails)] -- Usage details for RHS +occAnalRules !env bndr = map occ_anal_rule (idCoreRules bndr) where occ_anal_rule rule@(Rule { ru_bndrs = bndrs, ru_args = args, ru_rhs = rhs }) - = (rule', lhs_uds', rhs_uds') + = (rule', lhs_uds', TUD rhs_ja rhs_uds') where env' = env `addInScope` bndrs rule' | noBinderSwaps env = rule -- Note [Unfoldings and rules] @@ -1990,14 +2110,11 @@ occAnalRules !env mb_join_arity bndr (WithUsageDetails rhs_uds rhs') = occAnal env' rhs -- Note [Rules are extra RHSs] -- Note [Rule dependency info] - rhs_uds' = markAllNonTailIf (not exact_join) $ - markAllMany $ + rhs_uds' = markAllMany $ rhs_uds `delDetailsList` bndrs + rhs_ja = length args -- See Note [Join points and unfoldings/rules] - exact_join = exactJoin mb_join_arity args - -- See Note [Join points and unfoldings/rules] - - occ_anal_rule other_rule = (other_rule, emptyDetails, emptyDetails) + occ_anal_rule other_rule = (other_rule, emptyDetails, TUD 0 emptyDetails) {- Note [Join point RHSs] ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2032,6 +2149,8 @@ Another way to think about it: if we inlined g as-is into multiple call sites, now there's be multiple calls to f. Bottom line: treat all occurrences in a stable unfolding as "Many". +We still leave tail call information intact, though, as to not spoil +potential join points. Note [Unfoldings and rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2209,10 +2328,7 @@ occAnal env app@(App _ _) = occAnalApp env (collectArgsTicks tickishFloatable app) occAnal env expr@(Lam {}) - = let (WithUsageDetails usage expr') = occAnalLam env expr - final_usage = markAllInsideLamIf (not (isOneShotFun expr')) $ - markAllNonTail usage - in WithUsageDetails final_usage expr' + = adjustNonRecRhs Nothing $ occAnalLamTail env expr -- mb_join_arity == Nothing <=> markAllManyNonTail occAnal env (Case scrut bndr ty alts) = let @@ -2287,7 +2403,7 @@ occAnalApp !env (Var fun, args, ticks) -- This caused #18296 | fun `hasKey` runRWKey , [t1, t2, arg] <- args - , let (WithUsageDetails usage arg') = occAnalRhs env NonRecursive (Just 1) arg + , WithUsageDetails usage arg' <- adjustNonRecRhs (Just 1) $ occAnalLamTail env arg = WithUsageDetails usage (mkTicks ticks $ mkApps (Var fun) [t1, t2, arg']) occAnalApp env (Var fun_id, args, ticks) @@ -2872,7 +2988,6 @@ lookupBndrSwap env@(OccEnv { occ_bs_env = bs_env }) bndr case lookupBndrSwap env bndr1 of (fun, fun_id) -> (mkCastMCo fun mco, fun_id) } - {- Historical note [Proxy let-bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We used to do the binder-swap transformation by introducing @@ -2998,6 +3113,19 @@ data UsageDetails instance Outputable UsageDetails where ppr ud = ppr (ud_env (flattenUsageDetails ud)) +-- | Captures the result of applying 'occAnalLamTail' to a function `\xyz.body`. +-- The TailUsageDetails records +-- * the number of lambdas (including type lambdas: a JoinArity) +-- * UsageDetails for the `body`, unadjusted by `adjustTailUsage`. +-- If the binding turns out to be a join point with the indicated join +-- arity, this unadjusted usage details is just what we need; otherwise we +-- need to discard tail calls. That's what `adjustTailUsage` does. +data TailUsageDetails = TUD !JoinArity !UsageDetails + +instance Outputable TailUsageDetails where + ppr (TUD ja uds) = lambda <> ppr ja <> ppr uds + + ------------------- -- UsageDetails API @@ -3139,24 +3267,49 @@ flattenUsageDetails ud@(UD { ud_env = env }) ------------------- -- See Note [Adjusting right-hand sides] -adjustRhsUsage :: Maybe JoinArity - -> CoreExpr -- Rhs, AFTER occ anal - -> UsageDetails -- From body of lambda +adjustTailUsage :: Maybe JoinArity + -> CoreExpr -- Rhs, AFTER occAnalLamTail + -> TailUsageDetails -- From body of lambda -> UsageDetails -adjustRhsUsage mb_join_arity rhs usage +adjustTailUsage mb_join_arity rhs (TUD rhs_ja usage) = -- c.f. occAnal (Lam {}) markAllInsideLamIf (not one_shot) $ markAllNonTailIf (not exact_join) $ usage where one_shot = isOneShotFun rhs - exact_join = exactJoin mb_join_arity bndrs - (bndrs,_) = collectBinders rhs + exact_join = mb_join_arity == Just rhs_ja + +adjustTailArity :: Maybe JoinArity -> TailUsageDetails -> UsageDetails +adjustTailArity mb_rhs_ja (TUD ud_ja usage) = + markAllNonTailIf (mb_rhs_ja /= Just ud_ja) usage + +markNonRecJoinOneShots :: JoinArity -> CoreExpr -> CoreExpr +-- For a /non-recursive/ join point we can mark all +-- its join-lambda as one-shot; and it's a good idea to do so +markNonRecJoinOneShots join_arity rhs + = go join_arity rhs + where + go 0 rhs = rhs + go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) + (go (n-1) rhs) + go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. + -- e.g. let j = case ... in j True + -- This will become an arity-1 join point after the + -- simplifier has eta-expanded it; but it may not have + -- enough lambdas /yet/. (Lint checks that JoinIds do + -- have enough lambdas.) -exactJoin :: Maybe JoinArity -> [a] -> Bool -exactJoin Nothing _ = False -exactJoin (Just join_arity) args = args `lengthIs` join_arity - -- Remember join_arity includes type binders +markNonRecUnfoldingOneShots :: Maybe JoinArity -> Unfolding -> Unfolding +-- ^ Apply 'markNonRecJoinOneShots' to a stable unfolding +markNonRecUnfoldingOneShots mb_join_arity unf + | Just ja <- mb_join_arity + , CoreUnfolding{uf_src=src,uf_tmpl=tmpl} <- unf + , isStableSource src + , let !tmpl' = markNonRecJoinOneShots ja tmpl + = unf{uf_tmpl=tmpl'} + | otherwise + = unf type IdWithOccInfo = Id @@ -3192,8 +3345,8 @@ tagLamBinder usage bndr tagNonRecBinder :: TopLevelFlag -- At top level? -> UsageDetails -- Of scope -> CoreBndr -- Binder - -> (UsageDetails, -- Details with binder removed - IdWithOccInfo) -- Tagged binder + -> WithUsageDetails -- Details with binder removed + IdWithOccInfo -- Tagged binder tagNonRecBinder lvl usage binder = let @@ -3205,37 +3358,34 @@ tagNonRecBinder lvl usage binder binder' = setBinderOcc occ' binder usage' = usage `delDetails` binder in - usage' `seq` (usage', binder') + WithUsageDetails usage' binder' tagRecBinders :: TopLevelFlag -- At top level? -> UsageDetails -- Of body of let ONLY - -> [Details] - -> (UsageDetails, -- Adjusted details for whole scope, + -> [NodeDetails] + -> WithUsageDetails -- Adjusted details for whole scope, -- with binders removed - [IdWithOccInfo]) -- Tagged binders + [IdWithOccInfo] -- Tagged binders -- Substantially more complicated than non-recursive case. Need to adjust RHS -- details *before* tagging binders (because the tags depend on the RHSes). tagRecBinders lvl body_uds details_s = let bndrs = map nd_bndr details_s - rhs_udss = map nd_uds details_s - -- 1. Determine join-point-hood of whole group, as determined by - -- the *unadjusted* usage details - unadj_uds = foldr andUDs body_uds rhs_udss + -- 1. See Note [Join arity prediction based on joinRhsArity] + -- Determine possible join-point-hood of whole group, by testing for + -- manifest join arity M. + -- This (re-)asserts that makeNode had made tuds for that same arity M! + unadj_uds = foldr (andUDs . test_manifest_arity) body_uds details_s + test_manifest_arity ND{nd_rhs=WithTailUsageDetails tuds rhs} + = adjustTailArity (Just (joinRhsArity rhs)) tuds - -- This is only used in `mb_join_arity`, to adjust each `Details` in `details_s`, thus, - -- when `bndrs` is non-empty. So, we only write `maybe False` as `decideJoinPointHood` - -- takes a `NonEmpty CoreBndr`; the default value `False` won't affect program behavior. - will_be_joins = maybe False (decideJoinPointHood lvl unadj_uds) (nonEmpty bndrs) - - -- 2. Adjust usage details of each RHS, taking into account the - -- join-point-hood decision - rhs_udss' = [ adjustRhsUsage (mb_join_arity bndr) rhs rhs_uds - | ND { nd_bndr = bndr, nd_uds = rhs_uds - , nd_rhs = rhs } <- details_s ] + bndr_ne = expectNonEmpty "List of binders is never empty" bndrs + will_be_joins = decideJoinPointHood lvl unadj_uds bndr_ne mb_join_arity :: Id -> Maybe JoinArity + -- mb_join_arity: See Note [Join arity prediction based on joinRhsArity] + -- This is the source O mb_join_arity bndr -- Can't use willBeJoinId_maybe here because we haven't tagged -- the binder yet (the tag depends on these adjustments!) @@ -3247,6 +3397,12 @@ tagRecBinders lvl body_uds details_s = assert (not will_be_joins) -- Should be AlwaysTailCalled if Nothing -- we are making join points! + -- 2. Adjust usage details of each RHS, taking into account the + -- join-point-hood decision + rhs_udss' = [ adjustTailUsage (mb_join_arity bndr) rhs rhs_tuds -- matching occAnalLamTail in makeNode + | ND { nd_bndr = bndr, nd_rhs = WithTailUsageDetails rhs_tuds rhs } + <- details_s ] + -- 3. Compute final usage details from adjusted RHS details adj_uds = foldr andUDs body_uds rhs_udss' @@ -3257,7 +3413,7 @@ tagRecBinders lvl body_uds details_s -- 5. Drop the binders from the adjusted details and return usage' = adj_uds `delDetailsList` bndrs in - (usage', bndrs') + WithUsageDetails usage' bndrs' setBinderOcc :: OccInfo -> CoreBndr -> CoreBndr setBinderOcc occ_info bndr @@ -3271,12 +3427,13 @@ setBinderOcc occ_info bndr | otherwise = setIdOccInfo bndr occ_info --- | Decide whether some bindings should be made into join points or not. +-- | Decide whether some bindings should be made into join points or not, based +-- on its occurrences. This is -- Returns `False` if they can't be join points. Note that it's an -- all-or-nothing decision, as if multiple binders are given, they're -- assumed to be mutually recursive. -- --- It must, however, be a final decision. If we say "True" for 'f', +-- It must, however, be a final decision. If we say `True` for 'f', -- and then subsequently decide /not/ make 'f' into a join point, then -- the decision about another binding 'g' might be invalidated if (say) -- 'f' tail-calls 'g'. ===================================== compiler/GHC/Data/Graph/Directed.hs ===================================== @@ -4,6 +4,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE DeriveFunctor #-} module GHC.Data.Graph.Directed ( Graph, graphFromEdgedVerticesOrd, graphFromEdgedVerticesUniq, @@ -108,7 +109,7 @@ data Node key payload = DigraphNode { node_payload :: payload, -- ^ User data node_key :: key, -- ^ User defined node id node_dependencies :: [key] -- ^ Dependencies/successors of the node - } + } deriving Functor instance (Outputable a, Outputable b) => Outputable (Node a b) where ===================================== compiler/GHC/Utils/Misc.hs ===================================== @@ -35,7 +35,7 @@ module GHC.Utils.Misc ( equalLength, compareLength, leLength, ltLength, isSingleton, only, expectOnly, GHC.Utils.Misc.singleton, - notNull, snocView, + notNull, expectNonEmpty, snocView, chunkList, @@ -481,7 +481,6 @@ expectOnly _ (a:_) = a #endif expectOnly msg _ = panic ("expectOnly: " ++ msg) - -- | Split a list into chunks of /n/ elements chunkList :: Int -> [a] -> [[a]] chunkList _ [] = [] @@ -500,6 +499,16 @@ changeLast [] _ = panic "changeLast" changeLast [_] x = [x] changeLast (x:xs) x' = x : changeLast xs x' +-- | Like @expectJust msg . nonEmpty@; a better alternative to 'NE.fromList'. +expectNonEmpty :: HasCallStack => String -> [a] -> NonEmpty a +{-# INLINE expectNonEmpty #-} +expectNonEmpty _ (x:xs) = x:|xs +expectNonEmpty msg [] = expectNonEmptyPanic msg + +expectNonEmptyPanic :: String -> a +expectNonEmptyPanic msg = panic ("expectNonEmpty: " ++ msg) +{-# NOINLINE expectNonEmptyPanic #-} + -- | Apply an effectful function to the last list element. mapLastM :: Functor f => (a -> f a) -> NonEmpty a -> f (NonEmpty a) mapLastM f (x:|[]) = NE.singleton <$> f x ===================================== testsuite/tests/simplCore/should_compile/T22428.hs ===================================== @@ -0,0 +1,9 @@ +module T22428 where + +f :: Integer -> Integer -> Integer +f x y = go y + where + go :: Integer -> Integer + go 0 = x + go n = go (n-1) + {-# INLINE go #-} ===================================== testsuite/tests/simplCore/should_compile/T22428.stderr ===================================== @@ -0,0 +1,45 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 32, types: 14, coercions: 0, joins: 1/1} + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22428.f1 :: Integer +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22428.f1 = GHC.Num.Integer.IS 1# + +-- RHS size: {terms: 28, types: 10, coercions: 0, joins: 1/1} +f :: Integer -> Integer -> Integer +[GblId, + Arity=2, + Str=<1L>, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 0] 156 0}] +f = \ (x :: Integer) (y :: Integer) -> + joinrec { + go [InlPrag=INLINE (sat-args=1), Occ=LoopBreaker, Dmd=SC(S,L)] + :: Integer -> Integer + [LclId[JoinId(1)(Just [!])], + Arity=1, + Str=<1L>, + Unf=Unf{Src=StableUser, TopLvl=False, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=False,boring_ok=False)}] + go (ds :: Integer) + = case ds of wild { + GHC.Num.Integer.IS x1 -> + case x1 of { + __DEFAULT -> jump go (GHC.Num.Integer.integerSub wild T22428.f1); + 0# -> x + }; + GHC.Num.Integer.IP x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1); + GHC.Num.Integer.IN x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1) + }; } in + jump go y + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -451,6 +451,7 @@ test('T22375', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeab # One module, T21851_2.hs, has OPTIONS_GHC -ddump-simpl # Expecting to see $s$wwombat 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']) @@ -462,3 +463,6 @@ test('T22272', normal, multimod_compile, ['T22272', '-O -fexpose-all-unfoldings test('T22459', normal, compile, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) test('T22662', normal, compile, ['']) + +# go should become a join point +test('T22428', [grep_errmsg(r'jump go') ], compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeable-binds -dsuppress-unfoldings']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3583c57a7fe897e3446ee5e707d757b8e3722810 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3583c57a7fe897e3446ee5e707d757b8e3722810 You're receiving 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 Jan 10 21:11:48 2023 From: gitlab at gitlab.haskell.org (Adam Gundry (@adamgundry)) Date: Tue, 10 Jan 2023 16:11:48 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/amg/warning-refactoring Message-ID: <63bdd494c0fd_3b1bf91d2c59a8685580@gitlab.mail> Adam Gundry pushed new branch wip/amg/warning-refactoring at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/amg/warning-refactoring You're receiving 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 Jan 10 21:32:17 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 10 Jan 2023 16:32:17 -0500 Subject: [Git][ghc/ghc][wip/T20666] 20 commits: Add support for sized literals in the bytecode interpreter. Message-ID: <63bdd9618aeb9_3b1bf952620687815@gitlab.mail> Simon Peyton Jones pushed to branch wip/T20666 at Glasgow Haskell Compiler / GHC Commits: 28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00 Add support for sized literals in the bytecode interpreter. The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945 - - - - - ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00 rts: MUT_VAR is not a StgMutArrPtrs There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs. - - - - - 6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s - - - - - 73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. - - - - - 8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 5d65773e by John Ericson at 2023-01-09T20:39:27-05:00 Remove RTS hack for configuring See the brand new Note [Undefined symbols in the RTS] for additional details. - - - - - e3fff751 by Sebastian Graf at 2023-01-09T20:40:02-05:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - d53f6f4d by Oleg Grenrus at 2023-01-09T21:11:02-05:00 Add safe list indexing operator: !? With Joachim's amendments. Implements https://github.com/haskell/core-libraries-committee/issues/110 - - - - - cfaf1ad7 by Nicolas Trangez at 2023-01-09T21:11:03-05:00 rts, tests: limit thread name length to 15 bytes On Linux, `pthread_setname_np` (or rather, the kernel) only allows for thread names up to 16 bytes, including the terminating null byte. This commit adds a note pointing this out in `createOSThread`, and fixes up two instances where a thread name of more than 15 characters long was used (in the RTS, and in a test-case). Fixes: #22366 Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796 - - - - - 64286132 by Matthew Pickering at 2023-01-09T21:11:03-05:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 4724e8d1 by Matthew Pickering at 2023-01-09T21:11:04-05:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. This completes the fix for #22429 - - - - - 2e926b88 by Georgi Lyubenov at 2023-01-09T21:11:07-05:00 Fix outdated link to Happy section on sequences - - - - - 146a1458 by Matthew Pickering at 2023-01-09T21:11:07-05:00 Revert "NCG(x86): Compile add+shift as lea if possible." This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a. See #22666 and #21777 - - - - - 14aa3236 by Richard Eisenberg at 2023-01-10T21:32:46+00:00 Refactor the treatment of loopy superclass dicts This patch completely re-engineers how we deal with loopy superclass dictionaries in instance declarations. It fixes #20666 and #19690 The highlights are * Recognise that the loopy-superclass business should use precisely the Paterson conditions. This is much much nicer. See Note [Recursive superclasses] in GHC.Tc.TyCl.Instance * With that in mind, define "Paterson-smaller" in Note [Paterson conditions] in GHC.Tc.Validity, and the new data type `PatersonSize` in GHC.Tc.Utils.TcType, along with functions to compute and compare PatsonSizes * Use the new PatersonSize stuff when solving superclass constraints See Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance * In GHC.Tc.Solver.Monad.lookupInInerts, add a missing call to prohibitedSuperClassSolve. This was the original cause of #20666. * Treat (TypeError "stuff") as having PatersonSize zero. See Note [Paterson size for type family applications] in GHC.Tc.Utils.TcType. * Treat the head of a Wanted quantified constraint in the same way as the superclass of an instance decl; this is what fixes #19690. See GHC.Tc.Solver.Canonical Note [Solving a Wanted forall-constraint] (Thanks to Matthew Craven for this insight.) This entailed refactoring the GivenSc constructor of CtOrigin a bit, to say whether it comes from an instance decl or quantified constraint. * Some refactoring way in which redundant constraints are reported; we don't want to complain about the extra, apparently-redundant constraints that we must add to an instance decl because of the loopy-superclass thing. I moved some work from GHC.Tc.Errors to GHC.Tc.Solver. * Add a new section to the user manual to describe the loopy superclass issue and what rules it follows. - - - - - 30 changed files: - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/StgToByteCode.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Infer.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Match.hs-boot - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/InertSet.hs - compiler/GHC/Tc/Solver/Interact.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1e8add793017a235f0723a60be4cc605865fb688...14aa3236f3828d4953d852d63a09c78084bfebc8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1e8add793017a235f0723a60be4cc605865fb688...14aa3236f3828d4953d852d63a09c78084bfebc8 You're receiving 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 Jan 10 21:42:32 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 10 Jan 2023 16:42:32 -0500 Subject: [Git][ghc/ghc][wip/T22502] Fix finaliseArgBoxities for OPAQUE function Message-ID: <63bddbc869f42_3b1bf95632469235@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22502 at Glasgow Haskell Compiler / GHC Commits: 7376bf18 by Simon Peyton Jones at 2023-01-10T21:42:47+00:00 Fix finaliseArgBoxities for OPAQUE function We never do worker wrapper for OPAQUE functions, so we must zap the unboxing info during strictness analysis. This patch fixes #22502 - - - - - 3 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - + testsuite/tests/simplCore/should_compile/T22502.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -41,7 +41,6 @@ import GHC.Core.Opt.Arity ( typeArity ) import GHC.Utils.Misc import GHC.Utils.Panic import GHC.Utils.Panic.Plain -import GHC.Data.Maybe import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set @@ -1078,9 +1077,8 @@ dmdAnalRhsSig top_lvl rec_flag env let_dmd id rhs WithDmdType rhs_dmd_ty rhs' = dmdAnal env rhs_dmd rhs DmdType rhs_fv rhs_dmds rhs_div = rhs_dmd_ty - -- See Note [Boxity for bottoming functions] - (final_rhs_dmds, final_rhs) = finaliseArgBoxities env id threshold_arity rhs' rhs_div - `orElse` (rhs_dmds, rhs') + (final_rhs_dmds, final_rhs) = finaliseArgBoxities env id threshold_arity + rhs_dmds rhs_div rhs' sig = mkDmdSigForArity threshold_arity (DmdType sig_fv final_rhs_dmds rhs_div) @@ -1259,7 +1257,9 @@ The threshold we use is * Ordinary bindings: idArity f. Why idArity arguments? Because that's a conservative estimate of how many arguments we must feed a function before it does anything interesting with - them. Also it elegantly subsumes the trivial RHS and PAP case. + them. Also it elegantly subsumes the trivial RHS and PAP case. E.g. for + f = g + we want to use a threshold arity based on g, not 0! idArity is /at least/ the number of manifest lambdas, but might be higher for PAPs and trivial RHS (see Note [Demand analysis for trivial right-hand sides]). @@ -1909,21 +1909,37 @@ spendTopBudget m (MkB n bg) = MkB (n-m) bg positiveTopBudget :: Budgets -> Bool positiveTopBudget (MkB n _) = n >= 0 -finaliseArgBoxities :: AnalEnv -> Id -> Arity -> CoreExpr -> Divergence - -> Maybe ([Demand], CoreExpr) -finaliseArgBoxities env fn arity rhs div - | arity > count isId bndrs -- Can't find enough binders - = Nothing -- This happens if we have f = g - -- Then there are no binders; we don't worker/wrapper; and we - -- simply want to give f the same demand signature as g - - | otherwise -- NB: arity is the threshold_arity, which might be less than +finaliseArgBoxities :: AnalEnv -> Id -> Arity + -> [Demand] -> Divergence + -> CoreExpr -> ([Demand], CoreExpr) +finaliseArgBoxities env fn threshold_arity rhs_dmds div rhs + + -- Check for an OPAQUE function: see Note [OPAQUE pragma] + -- In that case, trim off all boxity info from argument demands + -- See Note [The OPAQUE pragma and avoiding the reboxing of arguments] + | isOpaquePragma (idInlinePragma fn) + , let trimmed_rhs_dmds = map trimBoxity rhs_dmds + = (trimmed_rhs_dmds, add_demands trimmed_rhs_dmds rhs) + + -- Check that we have enough visible binders to match the + -- threshold arity; if not, we won't do worker/wrapper + -- This happens if we have simply {f = g} or a PAP {f = h 13} + -- we simply want to give f the same demand signature as g + -- How can such bindings arise? Perhaps from {-# NOLINE[2] f #-}, + -- or if the call to `f` is currently not-applied (map f xs). + -- It's a bit of a corner case. Anyway for now we pass on the + -- unadulterated demands from the RHS, without any boxity trimming. + | threshold_arity > count isId bndrs + = (rhs_dmds, rhs) + + -- The normal case + | otherwise -- NB: threshold_arity might be less than -- manifest arity for join points = -- pprTrace "finaliseArgBoxities" ( -- vcat [text "function:" <+> ppr fn -- , text "dmds before:" <+> ppr (map idDemandInfo (filter isId bndrs)) -- , text "dmds after: " <+> ppr arg_dmds' ]) $ - Just (arg_dmds', add_demands arg_dmds' rhs) + (arg_dmds', add_demands arg_dmds' rhs) -- add_demands: we must attach the final boxities to the lambda-binders -- of the function, both because that's kosher, and because CPR analysis -- uses the info on the binders directly. @@ -1941,7 +1957,7 @@ finaliseArgBoxities env fn arity rhs div (remaining_budget, arg_dmds') = go_args (MkB max_wkr_args remaining_budget) arg_triples arg_triples :: [(Type, StrictnessMark, Demand)] - arg_triples = take arity $ + arg_triples = take threshold_arity $ [ (bndr_ty, NotMarkedStrict, get_dmd bndr bndr_ty) | bndr <- bndrs , isRuntimeVar bndr, let bndr_ty = idType bndr ] @@ -1957,14 +1973,9 @@ finaliseArgBoxities env fn arity rhs div | is_bot_fn = unboxDeeplyDmd dmd -- See Note [Boxity for bottoming functions], case (B) - | is_opaque = trimBoxity dmd - -- See Note [OPAQUE pragma] - -- See Note [The OPAQUE pragma and avoiding the reboxing of arguments] - | otherwise = dmd where - dmd = idDemandInfo bndr - is_opaque = isOpaquePragma (idInlinePragma fn) + dmd = idDemandInfo bndr -- is_bot_fn: see Note [Boxity for bottoming functions] is_bot_fn = div == botDiv @@ -2027,6 +2038,10 @@ finaliseArgBoxities env fn arity rhs div add_demands (dmd:dmds) (Lam v e) | isTyVar v = Lam v (add_demands (dmd:dmds) e) | otherwise = Lam (v `setIdDemandInfo` dmd) (add_demands dmds e) + add_demands dmds (Cast e co) = Cast (add_demands dmds e) co + -- This case happens for an OPAQUE function, which may look like + -- f = (\x y. blah) |> co + -- We give it strictness but no boxity (#22502) add_demands dmds e = pprPanic "add_demands" (ppr dmds $$ ppr e) finaliseLetBoxity ===================================== testsuite/tests/simplCore/should_compile/T22502.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +module M where + +import GHC.Exts +import GHC.IO + +data T a = MkT !Bool !a + +fun :: T a -> IO a +{-# OPAQUE fun #-} +fun (MkT _ x) = IO $ \s -> noinline seq# x s +-- evaluate/seq# should not produce its own eval for x +-- since it is properly tagged (from a strict field) + +-- uses noinline to prevent caseRules from eliding the seq# in Core ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -462,3 +462,4 @@ test('T22272', normal, multimod_compile, ['T22272', '-O -fexpose-all-unfoldings test('T22459', normal, compile, ['']) test('T22623', normal, multimod_compile, ['T22623', '-O -v0']) test('T22662', normal, compile, ['']) +test('T22502', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7376bf1892bbe33161e050f58328cf0166370125 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7376bf1892bbe33161e050f58328cf0166370125 You're receiving 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 Jan 10 22:03:28 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 10 Jan 2023 17:03:28 -0500 Subject: [Git][ghc/ghc][wip/T22719] Document the semantics of pattern bindings a bit better Message-ID: <63bde0b03e590_3b1bf9526346986f5@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22719 at Glasgow Haskell Compiler / GHC Commits: dae63714 by Simon Peyton Jones at 2023-01-10T22:03:56+00:00 Document the semantics of pattern bindings a bit better This MR is in response to the discussion on #22719 - - - - - 6 changed files: - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Expr.hs - docs/users_guide/exts/strict.rst - + testsuite/tests/deSugar/should_compile/T22719.hs - + testsuite/tests/deSugar/should_compile/T22719.stderr - testsuite/tests/deSugar/should_compile/all.T Changes: ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -86,7 +86,7 @@ module GHC.Hs.Utils( mkLetStmt, -- * Collecting binders - isUnliftedHsBind, isBangedHsBind, + isUnliftedHsBind, isUnliftedHsBinds, isBangedHsBind, collectLocalBinders, collectHsValBinders, collectHsBindListBinders, collectHsIdBinders, @@ -905,55 +905,106 @@ to return a [Name] or [Id]. Before renaming the record punning and wild-card mechanism makes it hard to know what is bound. So these functions should not be applied to (HsSyn RdrName) -Note [Unlifted id check in isUnliftedHsBind] +Note [isUnliftedHsBind] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The function isUnliftedHsBind is used to complain if we make a top-level -binding for a variable of unlifted type. +The function isUnliftedHsBind tells if the binding binds a variable of +unlifted type. e.g. -Such a binding is illegal if the top-level binding would be unlifted; -but also if the local letrec generated by desugaring AbsBinds would be. -E.g. - f :: Num a => (# a, a #) - g :: Num a => a -> a - f = ...g... - g = ...g... + - I# x = blah + - Just (I# x) = blah -The top-level bindings for f,g are not unlifted (because of the Num a =>), -but the local, recursive, monomorphic bindings are: +isUnliftedHsBind is used in two ways: +* To complain if we make a top-level binding for a variable of unlifted + type. E.g. any of the above bindings are illegal at top level + +* To generate a case expression for a non-recursive local let. E.g. + let Just (I# x) = blah in body + ==> + case blah of Just (I# x) -> body + See GHC.HsToCore.Expr.dsUnliftedBind. + +Wrinkles: + +(W1) For AbsBinds we must check if the local letrec generated by desugaring + AbsBinds would be unlifted; so we just recurse into the abs_binds. E.g. + f :: Num a => (# a, a #) + g :: Num a => a -> a + f = ...g... + g = ...g... + + The top-level bindings for f,g are not unlifted (because of the Num a =>), + but the local, recursive, monomorphic bindings are: t = /\a \(d:Num a). letrec fm :: (# a, a #) = ...g... gm :: a -> a = ...f... in (fm, gm) -Here the binding for 'fm' is illegal. So generally we check the abe_mono types. + Here the binding for 'fm' is illegal. So we recurse into the abs_binds + +(W2) BUT we have a special case when abs_sig is true; + see Note [The abs_sig field of AbsBinds] in GHC.Hs.Binds + +(W3) isUnliftedHsBind returns False even if the binding itself is + unlifted, provided it binds only lifted variables. E.g. + - (# a,b #) = (# reverse xs, xs #) + + - x = sqrt# y# :: Float# + + - type Unl :: UnliftedType + data Unl = MkUnl Int + MkUnl z = blah -BUT we have a special case when abs_sig is true; - see Note [The abs_sig field of AbsBinds] in GHC.Hs.Binds + In each case the RHS of the "=" has unlifted type, but isUnliftedHsBind + returns False. Reason: see GHC Proposal #35 + https://github.com/ghc-proposals/ghc-proposals/blob/master/ + proposals/0035-unbanged-strict-patterns.rst + +(W4) In particular, (W3) applies to a pattern that binds no variables at all. + So { _ = sqrt# y :: Float# } returns False from isUnliftedHsBind, but + { x = sqrt# y :: Float# } returns True. + This is arguably a bit confusing (see #22719) -} ----------------- Bindings -------------------------- -- | Should we treat this as an unlifted bind? This will be true for any -- bind that binds an unlifted variable, but we must be careful around --- AbsBinds. See Note [Unlifted id check in isUnliftedHsBind]. For usage +-- AbsBinds. See Note [isUnliftedHsBind]. For usage -- information, see Note [Strict binds checks] is GHC.HsToCore.Binds. isUnliftedHsBind :: HsBind GhcTc -> Bool -- works only over typechecked binds -isUnliftedHsBind bind - | XHsBindsLR (AbsBinds { abs_exports = exports, abs_sig = has_sig }) <- bind - = if has_sig - then any (is_unlifted_id . abe_poly) exports - else any (is_unlifted_id . abe_mono) exports +isUnliftedHsBind (XHsBindsLR (AbsBinds { abs_exports = exports + , abs_sig = has_sig + , abs_binds = binds })) + | has_sig = any (is_unlifted_id . abe_poly) exports + | otherwise = isUnliftedHsBinds binds + -- See wrinkle (W1) and (W2) in Note [isUnliftedHsBind] -- If has_sig is True we will never generate a binding for abe_mono, -- so we don't need to worry about it being unlifted. The abe_poly -- binding might not be: e.g. forall a. Num a => (# a, a #) + -- If has_sig is False, just recurse - | otherwise - = any is_unlifted_id (collectHsBindBinders CollNoDictBinders bind) - where - is_unlifted_id id = isUnliftedType (idType id) - -- bindings always have a fixed RuntimeRep, so it's OK - -- to call isUnliftedType here +isUnliftedHsBind (FunBind { fun_id = L _ fun }) + = is_unlifted_id fun + +isUnliftedHsBind (VarBind { var_id = var }) + = is_unlifted_id var + +isUnliftedHsBind (PatBind { pat_lhs = pat }) + = any is_unlifted_id (collectPatBinders CollNoDictBinders pat) + -- If we changed our view on (W3) you could add + -- || isUnliftedType pat_ty + -- to this check + +isUnliftedHsBind (PatSynBind {}) = panic "isUnliftedBind: PatSynBind" + +isUnliftedHsBinds :: LHsBinds GhcTc -> Bool +isUnliftedHsBinds = anyBag (isUnliftedHsBind . unLoc) + +is_unlifted_id :: Id -> Bool +is_unlifted_id id = isUnliftedType (idType id) + -- Bindings always have a fixed RuntimeRep, so it's OK + -- to call isUnliftedType here -- | Is a binding a strict variable or pattern bind (e.g. @!x = ...@)? isBangedHsBind :: HsBind GhcTc -> Bool ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -197,7 +197,7 @@ dsUnliftedBind (FunBind { fun_id = L l fun ; let rhs' = core_wrap (mkOptTickBox tick rhs) ; return (bindNonRec fun rhs' body) } -dsUnliftedBind (PatBind {pat_lhs = pat, pat_rhs = grhss +dsUnliftedBind (PatBind { pat_lhs = pat, pat_rhs = grhss , pat_ext = (ty, _) }) body = -- let C x# y# = rhs in body -- ==> case rhs of C x# y# -> body ===================================== docs/users_guide/exts/strict.rst ===================================== @@ -377,21 +377,36 @@ Haskell Report. Replace the "Translation" there with the following one. Given ``let { bind1 ... bindn } in body``: -.. admonition:: FORCE - - Replace any binding ``!p = e`` with ``v = case e of p -> (x1, ..., xn); (x1, ..., xn) = v`` and replace - ``body`` with ``v seq body``, where ``v`` is fresh. This translation works fine if - ``p`` is already a variable ``x``, but can obviously be optimised by not - introducing a fresh variable ``v``. - .. admonition:: SPLIT - Replace any binding ``p = e``, where ``p`` is not a variable, with + Given a binding ``p = e``, where ``p`` is not a variable or a bang pattern, + where ``x1...xn`` are the variables bound by ``p``, + and all these binders have lifted type: + replace the binding with ``v = e; x1 = case v of p -> x1; ...; xn = case v of p -> xn``, where ``v`` is fresh and ``x1``.. ``xn`` are the bound variables of ``p``. Again if ``e`` is a variable, this can be optimised by not introducing a fresh variable. +.. admonition:: FORCE + + Given a binding binding ``!p = e``, where ``x1...xn`` are the variables bound by ``p``, + and all these binders have lifted type: + replace the binding with ``v = case e of p -> (x1, ..., xn); (x1, ..., xn) = v`` and replace + ``body`` with ``v seq body``, where ``v`` is fresh. This translation works fine if + ``p`` is already a variable ``x``, but can obviously be optimised by not + introducing a fresh variable ``v``. This transformation is illegal at the top + level of a module (since there is no ``body``), so such bindings are rejected. + +.. admonition:: CASE + + Given a binding binding ``p = e``, where ``x1...xn`` are the variables bound by ``p``, + and any of the binders has unlifted type: + replace the binding with nothing at all, and replace + ``body`` with ``case e of p -> body``. This applies even if ``p`` binds no variables at all. + This transformation is illegal at the top + level of a module, so such bindings are rejected. + The result will be a (possibly) recursive set of bindings, binding only simple variables on the left hand side. (One could go one step further, as in the Haskell Report and make the recursive bindings ===================================== testsuite/tests/deSugar/should_compile/T22719.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE UnliftedDatatypes #-} +{-# OPTIONS_GHC -Wall #-} + +module T22719 where + +import GHC.Exts + +type T :: UnliftedType +data T = T + +f :: Int -> T +f 0 = T +f n = f (n-1) + +-- ex1 is lazy in (f 7) +ex1 :: () +ex1 = let _ = f 7 in () + +-- ex2 is strict in (f 10) +ex2 :: () +ex2 = let _a = f 10 in () ===================================== testsuite/tests/deSugar/should_compile/T22719.stderr ===================================== @@ -0,0 +1,30 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 25, types: 10, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +ex1 :: () +[GblId, Unf=OtherCon []] +ex1 = GHC.Tuple.Prim.() + +Rec { +-- RHS size: {terms: 15, types: 5, coercions: 0, joins: 0/0} +f [Occ=LoopBreaker] :: Int -> T +[GblId, Arity=1, Unf=OtherCon []] +f = \ (ds :: Int) -> + case ds of wild { I# ds1 -> + case ds1 of { + __DEFAULT -> f (- @Int GHC.Num.$fNumInt wild (GHC.Types.I# 1#)); + 0# -> T22719.T + } + } +end Rec } + +-- RHS size: {terms: 6, types: 1, coercions: 0, joins: 0/0} +ex2 :: () +[GblId] +ex2 = case f (GHC.Types.I# 10#) of { T -> GHC.Tuple.Prim.() } + + + ===================================== testsuite/tests/deSugar/should_compile/all.T ===================================== @@ -112,3 +112,4 @@ test('T16615', normal, compile, ['-ddump-ds -dsuppress-uniques']) test('T18112', [grep_errmsg('cast')], compile, ['-ddump-ds']) test('T19969', normal, compile, ['-ddump-simpl -dsuppress-uniques']) test('T19883', normal, compile, ['']) +test('T22719', normal, compile, ['-ddump-simpl -dsuppress-uniques -dno-typeable-binds']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dae6371493faef399011758753f13fd53e365bac -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dae6371493faef399011758753f13fd53e365bac You're receiving 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 Jan 10 22:24:21 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 10 Jan 2023 17:24:21 -0500 Subject: [Git][ghc/ghc][wip/T22719] Document the semantics of pattern bindings a bit better Message-ID: <63bde5953f72f_3b1bf93c57d8c699384@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22719 at Glasgow Haskell Compiler / GHC Commits: a53f939e by Simon Peyton Jones at 2023-01-10T22:24:47+00:00 Document the semantics of pattern bindings a bit better This MR is in response to the discussion on #22719 - - - - - 6 changed files: - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Expr.hs - docs/users_guide/exts/strict.rst - + testsuite/tests/deSugar/should_compile/T22719.hs - + testsuite/tests/deSugar/should_compile/T22719.stderr - testsuite/tests/deSugar/should_compile/all.T Changes: ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -86,7 +86,7 @@ module GHC.Hs.Utils( mkLetStmt, -- * Collecting binders - isUnliftedHsBind, isBangedHsBind, + isUnliftedHsBind, isUnliftedHsBinds, isBangedHsBind, collectLocalBinders, collectHsValBinders, collectHsBindListBinders, collectHsIdBinders, @@ -905,55 +905,106 @@ to return a [Name] or [Id]. Before renaming the record punning and wild-card mechanism makes it hard to know what is bound. So these functions should not be applied to (HsSyn RdrName) -Note [Unlifted id check in isUnliftedHsBind] +Note [isUnliftedHsBind] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The function isUnliftedHsBind is used to complain if we make a top-level -binding for a variable of unlifted type. +The function isUnliftedHsBind tells if the binding binds a variable of +unlifted type. e.g. -Such a binding is illegal if the top-level binding would be unlifted; -but also if the local letrec generated by desugaring AbsBinds would be. -E.g. - f :: Num a => (# a, a #) - g :: Num a => a -> a - f = ...g... - g = ...g... + - I# x = blah + - Just (I# x) = blah -The top-level bindings for f,g are not unlifted (because of the Num a =>), -but the local, recursive, monomorphic bindings are: +isUnliftedHsBind is used in two ways: +* To complain if we make a top-level binding for a variable of unlifted + type. E.g. any of the above bindings are illegal at top level + +* To generate a case expression for a non-recursive local let. E.g. + let Just (I# x) = blah in body + ==> + case blah of Just (I# x) -> body + See GHC.HsToCore.Expr.dsUnliftedBind. + +Wrinkles: + +(W1) For AbsBinds we must check if the local letrec generated by desugaring + AbsBinds would be unlifted; so we just recurse into the abs_binds. E.g. + f :: Num a => (# a, a #) + g :: Num a => a -> a + f = ...g... + g = ...g... + + The top-level bindings for f,g are not unlifted (because of the Num a =>), + but the local, recursive, monomorphic bindings are: t = /\a \(d:Num a). letrec fm :: (# a, a #) = ...g... gm :: a -> a = ...f... in (fm, gm) -Here the binding for 'fm' is illegal. So generally we check the abe_mono types. + Here the binding for 'fm' is illegal. So we recurse into the abs_binds + +(W2) BUT we have a special case when abs_sig is true; + see Note [The abs_sig field of AbsBinds] in GHC.Hs.Binds + +(W3) isUnliftedHsBind returns False even if the binding itself is + unlifted, provided it binds only lifted variables. E.g. + - (# a,b #) = (# reverse xs, xs #) + + - x = sqrt# y# :: Float# + + - type Unl :: UnliftedType + data Unl = MkUnl Int + MkUnl z = blah -BUT we have a special case when abs_sig is true; - see Note [The abs_sig field of AbsBinds] in GHC.Hs.Binds + In each case the RHS of the "=" has unlifted type, but isUnliftedHsBind + returns False. Reason: see GHC Proposal #35 + https://github.com/ghc-proposals/ghc-proposals/blob/master/ + proposals/0035-unbanged-strict-patterns.rst + +(W4) In particular, (W3) applies to a pattern that binds no variables at all. + So { _ = sqrt# y :: Float# } returns False from isUnliftedHsBind, but + { x = sqrt# y :: Float# } returns True. + This is arguably a bit confusing (see #22719) -} ----------------- Bindings -------------------------- -- | Should we treat this as an unlifted bind? This will be true for any -- bind that binds an unlifted variable, but we must be careful around --- AbsBinds. See Note [Unlifted id check in isUnliftedHsBind]. For usage +-- AbsBinds. See Note [isUnliftedHsBind]. For usage -- information, see Note [Strict binds checks] is GHC.HsToCore.Binds. isUnliftedHsBind :: HsBind GhcTc -> Bool -- works only over typechecked binds -isUnliftedHsBind bind - | XHsBindsLR (AbsBinds { abs_exports = exports, abs_sig = has_sig }) <- bind - = if has_sig - then any (is_unlifted_id . abe_poly) exports - else any (is_unlifted_id . abe_mono) exports +isUnliftedHsBind (XHsBindsLR (AbsBinds { abs_exports = exports + , abs_sig = has_sig + , abs_binds = binds })) + | has_sig = any (is_unlifted_id . abe_poly) exports + | otherwise = isUnliftedHsBinds binds + -- See wrinkle (W1) and (W2) in Note [isUnliftedHsBind] -- If has_sig is True we will never generate a binding for abe_mono, -- so we don't need to worry about it being unlifted. The abe_poly -- binding might not be: e.g. forall a. Num a => (# a, a #) + -- If has_sig is False, just recurse - | otherwise - = any is_unlifted_id (collectHsBindBinders CollNoDictBinders bind) - where - is_unlifted_id id = isUnliftedType (idType id) - -- bindings always have a fixed RuntimeRep, so it's OK - -- to call isUnliftedType here +isUnliftedHsBind (FunBind { fun_id = L _ fun }) + = is_unlifted_id fun + +isUnliftedHsBind (VarBind { var_id = var }) + = is_unlifted_id var + +isUnliftedHsBind (PatBind { pat_lhs = pat }) + = any is_unlifted_id (collectPatBinders CollNoDictBinders pat) + -- If we changed our view on (W3) you could add + -- || isUnliftedType pat_ty + -- to this check + +isUnliftedHsBind (PatSynBind {}) = panic "isUnliftedBind: PatSynBind" + +isUnliftedHsBinds :: LHsBinds GhcTc -> Bool +isUnliftedHsBinds = anyBag (isUnliftedHsBind . unLoc) + +is_unlifted_id :: Id -> Bool +is_unlifted_id id = isUnliftedType (idType id) + -- Bindings always have a fixed RuntimeRep, so it's OK + -- to call isUnliftedType here -- | Is a binding a strict variable or pattern bind (e.g. @!x = ...@)? isBangedHsBind :: HsBind GhcTc -> Bool ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -197,7 +197,7 @@ dsUnliftedBind (FunBind { fun_id = L l fun ; let rhs' = core_wrap (mkOptTickBox tick rhs) ; return (bindNonRec fun rhs' body) } -dsUnliftedBind (PatBind {pat_lhs = pat, pat_rhs = grhss +dsUnliftedBind (PatBind { pat_lhs = pat, pat_rhs = grhss , pat_ext = (ty, _) }) body = -- let C x# y# = rhs in body -- ==> case rhs of C x# y# -> body ===================================== docs/users_guide/exts/strict.rst ===================================== @@ -377,21 +377,36 @@ Haskell Report. Replace the "Translation" there with the following one. Given ``let { bind1 ... bindn } in body``: -.. admonition:: FORCE - - Replace any binding ``!p = e`` with ``v = case e of p -> (x1, ..., xn); (x1, ..., xn) = v`` and replace - ``body`` with ``v seq body``, where ``v`` is fresh. This translation works fine if - ``p`` is already a variable ``x``, but can obviously be optimised by not - introducing a fresh variable ``v``. - .. admonition:: SPLIT - Replace any binding ``p = e``, where ``p`` is not a variable, with + Given a binding ``p = e``, where ``p`` is not a variable or a bang pattern, + where ``x1...xn`` are the variables bound by ``p``, + and all these binders have lifted type: + replace the binding with ``v = e; x1 = case v of p -> x1; ...; xn = case v of p -> xn``, where ``v`` is fresh and ``x1``.. ``xn`` are the bound variables of ``p``. Again if ``e`` is a variable, this can be optimised by not introducing a fresh variable. +.. admonition:: FORCE + + Given a binding binding ``!p = e``, where ``x1...xn`` are the variables bound by ``p``, + and all these binders have lifted type: + replace the binding with ``v = case e of p -> (x1, ..., xn); (x1, ..., xn) = v`` and replace + ``body`` with ``v seq body``, where ``v`` is fresh. This translation works fine if + ``p`` is already a variable ``x``, but can obviously be optimised by not + introducing a fresh variable ``v``. This transformation is illegal at the top + level of a module (since there is no ``body``), so such bindings are rejected. + +.. admonition:: CASE + + Given a binding binding ``p = e``, where ``x1...xn`` are the variables bound by ``p``, + and any of the binders has unlifted type: + replace the binding with nothing at all, and replace + ``body`` with ``case e of p -> body``. This applies even if ``p`` binds no variables at all. + This transformation is illegal at the top + level of a module, so such bindings are rejected. + The result will be a (possibly) recursive set of bindings, binding only simple variables on the left hand side. (One could go one step further, as in the Haskell Report and make the recursive bindings @@ -463,6 +478,42 @@ Same again, only with a pattern binding: :: The final form is just what we want: a simple case expression. +Rule (FORCE) applies even if the pattern binds no variables:: + + let !(True,False) = e in body + + ===> (FORCE) + let v = case e of (True,False) -> () in v `seq` body + + ===> (inline, simplify) + case e of (True,False) -> body + +That is, we force ``e`` and check that it has the right form before proceeding with ``body``. + +Note that (CASE) applies only when any of the binders is unlifted; +it is irrelevant whether the binding *itself* is unlifted (see +`GHC proposal #35 `__). +For example (see :ref:`primitives`). + + let (# a::Int, b::Bool #) = e in body + ===> let v = case e of (# a,b #) -> (a,b) + a = case v of (a,b) -> a + b = case v of (a,b) -> b + in body + +Here is an example with an unlifted data type:: + + type T :: UnliftedType + data T = MkT Int + f1 x = let MkT y = blah in body1 + f2 x = let z :: T = blah in body2 + f3 x = let _ :: T = blah in body3 + +In ``f1``, even though ``T`` is an unlifted type the pattern ``MkT y`` binds a lifted +variable ``y``, ,so (SPLIT) applies, and ``blah`` is not evaluated until ``body1`` evaluates ``y``. +In contrast, in ``f2`` the pattern ``z :: T`` binds a variable ``z`` of unlifted type, so rule (CASE) applies +and the let-binding is strict. In ``f3`` the pattern binds no variables, so again it it lazy like ``f1``. + Here is a recursive case :: letrec xs :: [Int] -- Recursive ===================================== testsuite/tests/deSugar/should_compile/T22719.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE UnliftedDatatypes #-} +{-# OPTIONS_GHC -Wall #-} + +module T22719 where + +import GHC.Exts + +type T :: UnliftedType +data T = T + +f :: Int -> T +f 0 = T +f n = f (n-1) + +-- ex1 is lazy in (f 7) +ex1 :: () +ex1 = let _ = f 7 in () + +-- ex2 is strict in (f 10) +ex2 :: () +ex2 = let _a = f 10 in () ===================================== testsuite/tests/deSugar/should_compile/T22719.stderr ===================================== @@ -0,0 +1,30 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 25, types: 10, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +ex1 :: () +[GblId, Unf=OtherCon []] +ex1 = GHC.Tuple.Prim.() + +Rec { +-- RHS size: {terms: 15, types: 5, coercions: 0, joins: 0/0} +f [Occ=LoopBreaker] :: Int -> T +[GblId, Arity=1, Unf=OtherCon []] +f = \ (ds :: Int) -> + case ds of wild { I# ds1 -> + case ds1 of { + __DEFAULT -> f (- @Int GHC.Num.$fNumInt wild (GHC.Types.I# 1#)); + 0# -> T22719.T + } + } +end Rec } + +-- RHS size: {terms: 6, types: 1, coercions: 0, joins: 0/0} +ex2 :: () +[GblId] +ex2 = case f (GHC.Types.I# 10#) of { T -> GHC.Tuple.Prim.() } + + + ===================================== testsuite/tests/deSugar/should_compile/all.T ===================================== @@ -112,3 +112,4 @@ test('T16615', normal, compile, ['-ddump-ds -dsuppress-uniques']) test('T18112', [grep_errmsg('cast')], compile, ['-ddump-ds']) test('T19969', normal, compile, ['-ddump-simpl -dsuppress-uniques']) test('T19883', normal, compile, ['']) +test('T22719', normal, compile, ['-ddump-simpl -dsuppress-uniques -dno-typeable-binds']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a53f939e9f898e57cc14f5c526c8b54c2720787b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a53f939e9f898e57cc14f5c526c8b54c2720787b You're receiving 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 Jan 10 22:35:47 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 10 Jan 2023 17:35:47 -0500 Subject: [Git][ghc/ghc][wip/T22719] Document the semantics of pattern bindings a bit better Message-ID: <63bde84399d65_3b1bf91fb12f147016ca@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22719 at Glasgow Haskell Compiler / GHC Commits: 8d7abaa6 by Simon Peyton Jones at 2023-01-10T22:36:08+00:00 Document the semantics of pattern bindings a bit better This MR is in response to the discussion on #22719 - - - - - 6 changed files: - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Expr.hs - docs/users_guide/exts/strict.rst - + testsuite/tests/deSugar/should_compile/T22719.hs - + testsuite/tests/deSugar/should_compile/T22719.stderr - testsuite/tests/deSugar/should_compile/all.T Changes: ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -86,7 +86,7 @@ module GHC.Hs.Utils( mkLetStmt, -- * Collecting binders - isUnliftedHsBind, isBangedHsBind, + isUnliftedHsBind, isUnliftedHsBinds, isBangedHsBind, collectLocalBinders, collectHsValBinders, collectHsBindListBinders, collectHsIdBinders, @@ -905,55 +905,106 @@ to return a [Name] or [Id]. Before renaming the record punning and wild-card mechanism makes it hard to know what is bound. So these functions should not be applied to (HsSyn RdrName) -Note [Unlifted id check in isUnliftedHsBind] +Note [isUnliftedHsBind] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The function isUnliftedHsBind is used to complain if we make a top-level -binding for a variable of unlifted type. +The function isUnliftedHsBind tells if the binding binds a variable of +unlifted type. e.g. -Such a binding is illegal if the top-level binding would be unlifted; -but also if the local letrec generated by desugaring AbsBinds would be. -E.g. - f :: Num a => (# a, a #) - g :: Num a => a -> a - f = ...g... - g = ...g... + - I# x = blah + - Just (I# x) = blah -The top-level bindings for f,g are not unlifted (because of the Num a =>), -but the local, recursive, monomorphic bindings are: +isUnliftedHsBind is used in two ways: +* To complain if we make a top-level binding for a variable of unlifted + type. E.g. any of the above bindings are illegal at top level + +* To generate a case expression for a non-recursive local let. E.g. + let Just (I# x) = blah in body + ==> + case blah of Just (I# x) -> body + See GHC.HsToCore.Expr.dsUnliftedBind. + +Wrinkles: + +(W1) For AbsBinds we must check if the local letrec generated by desugaring + AbsBinds would be unlifted; so we just recurse into the abs_binds. E.g. + f :: Num a => (# a, a #) + g :: Num a => a -> a + f = ...g... + g = ...g... + + The top-level bindings for f,g are not unlifted (because of the Num a =>), + but the local, recursive, monomorphic bindings are: t = /\a \(d:Num a). letrec fm :: (# a, a #) = ...g... gm :: a -> a = ...f... in (fm, gm) -Here the binding for 'fm' is illegal. So generally we check the abe_mono types. + Here the binding for 'fm' is illegal. So we recurse into the abs_binds + +(W2) BUT we have a special case when abs_sig is true; + see Note [The abs_sig field of AbsBinds] in GHC.Hs.Binds + +(W3) isUnliftedHsBind returns False even if the binding itself is + unlifted, provided it binds only lifted variables. E.g. + - (# a,b #) = (# reverse xs, xs #) + + - x = sqrt# y# :: Float# + + - type Unl :: UnliftedType + data Unl = MkUnl Int + MkUnl z = blah -BUT we have a special case when abs_sig is true; - see Note [The abs_sig field of AbsBinds] in GHC.Hs.Binds + In each case the RHS of the "=" has unlifted type, but isUnliftedHsBind + returns False. Reason: see GHC Proposal #35 + https://github.com/ghc-proposals/ghc-proposals/blob/master/ + proposals/0035-unbanged-strict-patterns.rst + +(W4) In particular, (W3) applies to a pattern that binds no variables at all. + So { _ = sqrt# y :: Float# } returns False from isUnliftedHsBind, but + { x = sqrt# y :: Float# } returns True. + This is arguably a bit confusing (see #22719) -} ----------------- Bindings -------------------------- -- | Should we treat this as an unlifted bind? This will be true for any -- bind that binds an unlifted variable, but we must be careful around --- AbsBinds. See Note [Unlifted id check in isUnliftedHsBind]. For usage +-- AbsBinds. See Note [isUnliftedHsBind]. For usage -- information, see Note [Strict binds checks] is GHC.HsToCore.Binds. isUnliftedHsBind :: HsBind GhcTc -> Bool -- works only over typechecked binds -isUnliftedHsBind bind - | XHsBindsLR (AbsBinds { abs_exports = exports, abs_sig = has_sig }) <- bind - = if has_sig - then any (is_unlifted_id . abe_poly) exports - else any (is_unlifted_id . abe_mono) exports +isUnliftedHsBind (XHsBindsLR (AbsBinds { abs_exports = exports + , abs_sig = has_sig + , abs_binds = binds })) + | has_sig = any (is_unlifted_id . abe_poly) exports + | otherwise = isUnliftedHsBinds binds + -- See wrinkle (W1) and (W2) in Note [isUnliftedHsBind] -- If has_sig is True we will never generate a binding for abe_mono, -- so we don't need to worry about it being unlifted. The abe_poly -- binding might not be: e.g. forall a. Num a => (# a, a #) + -- If has_sig is False, just recurse - | otherwise - = any is_unlifted_id (collectHsBindBinders CollNoDictBinders bind) - where - is_unlifted_id id = isUnliftedType (idType id) - -- bindings always have a fixed RuntimeRep, so it's OK - -- to call isUnliftedType here +isUnliftedHsBind (FunBind { fun_id = L _ fun }) + = is_unlifted_id fun + +isUnliftedHsBind (VarBind { var_id = var }) + = is_unlifted_id var + +isUnliftedHsBind (PatBind { pat_lhs = pat }) + = any is_unlifted_id (collectPatBinders CollNoDictBinders pat) + -- If we changed our view on (W3) you could add + -- || isUnliftedType pat_ty + -- to this check + +isUnliftedHsBind (PatSynBind {}) = panic "isUnliftedBind: PatSynBind" + +isUnliftedHsBinds :: LHsBinds GhcTc -> Bool +isUnliftedHsBinds = anyBag (isUnliftedHsBind . unLoc) + +is_unlifted_id :: Id -> Bool +is_unlifted_id id = isUnliftedType (idType id) + -- Bindings always have a fixed RuntimeRep, so it's OK + -- to call isUnliftedType here -- | Is a binding a strict variable or pattern bind (e.g. @!x = ...@)? isBangedHsBind :: HsBind GhcTc -> Bool ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -197,7 +197,7 @@ dsUnliftedBind (FunBind { fun_id = L l fun ; let rhs' = core_wrap (mkOptTickBox tick rhs) ; return (bindNonRec fun rhs' body) } -dsUnliftedBind (PatBind {pat_lhs = pat, pat_rhs = grhss +dsUnliftedBind (PatBind { pat_lhs = pat, pat_rhs = grhss , pat_ext = (ty, _) }) body = -- let C x# y# = rhs in body -- ==> case rhs of C x# y# -> body ===================================== docs/users_guide/exts/strict.rst ===================================== @@ -377,20 +377,35 @@ Haskell Report. Replace the "Translation" there with the following one. Given ``let { bind1 ... bindn } in body``: +.. admonition:: SPLIT + + Given a binding ``p = e``, where ``p`` is not a variable or a bang pattern, + and ``x1...xn`` are the variables bound by ``p``, + and all these binders have lifted type: + replace the binding with + ``v = e; x1 = case v of p -> x1; ...; xn = case v of p -> xn``, where + ``v`` is fresh. + (If ``e`` is a variable, this can be optimised by not introducing a + fresh variable.) + .. admonition:: FORCE - Replace any binding ``!p = e`` with ``v = case e of p -> (x1, ..., xn); (x1, ..., xn) = v`` and replace + Given a bang-pattern binding ``!p = e``, where ``x1...xn`` are the variables bound by ``p``, + and all these binders have lifted type: + replace the binding with ``v = case e of p -> (x1, ..., xn); (x1, ..., xn) = v`` and replace ``body`` with ``v seq body``, where ``v`` is fresh. This translation works fine if ``p`` is already a variable ``x``, but can obviously be optimised by not - introducing a fresh variable ``v``. + introducing a fresh variable ``v``. This transformation is illegal at the top + level of a module (since there is no ``body``), so such bindings are rejected. -.. admonition:: SPLIT +.. admonition:: CASE - Replace any binding ``p = e``, where ``p`` is not a variable, with - ``v = e; x1 = case v of p -> x1; ...; xn = case v of p -> xn``, where - ``v`` is fresh and ``x1``.. ``xn`` are the bound variables of ``p``. - Again if ``e`` is a variable, this can be optimised by not introducing a - fresh variable. + Given a pattern binding ``p = e``, where ``x1...xn`` are the variables bound by ``p``, + and any of the binders has unlifted type: + replace the binding with nothing at all, and replace + ``body`` with ``case e of p -> body``. + This transformation is illegal at the top + level of a module, so such bindings are rejected. The result will be a (possibly) recursive set of bindings, binding only simple variables on the left hand side. (One could go one step @@ -463,6 +478,43 @@ Same again, only with a pattern binding: :: The final form is just what we want: a simple case expression. +Rule (FORCE) applies even if the pattern binds no variables:: + + let !(True,False) = e in body + + ===> (FORCE) + let v = case e of (True,False) -> () in v `seq` body + + ===> (inline, simplify) + case e of (True,False) -> body + +That is, we force ``e`` and check that it has the right form before proceeding with ``body``. + +Note that (CASE) applies only when any of the *binders* is unlifted; +it is irrelevant whether the binding *itself* is unlifted (see +`GHC proposal #35 `__). +For example (see :ref:`primitives`):: + + let (# a::Int, b::Bool #) = e in body + ===> (SPLIT) + let v = case e of (# a,b #) -> (a,b) + a = case v of (a,b) -> a + b = case v of (a,b) -> b + in body + +Here is an example with an unlifted data type:: + + type T :: UnliftedType + data T = MkT Int + f1 x = let MkT y = blah in body1 + f2 x = let z :: T = blah in body2 + f3 x = let _ :: T = blah in body3 + +In ``f1``, even though ``T`` is an unlifted type, the pattern ``MkT y`` binds a lifted +variable ``y``, so (SPLIT) applies, and ``blah`` is not evaluated until ``body1`` evaluates ``y``. +In contrast, in ``f2`` the pattern ``z :: T`` binds a variable ``z`` of unlifted type, so (CASE) applies +and the let-binding is strict. In ``f3`` the pattern binds no variables, so again it is lazy like ``f1``. + Here is a recursive case :: letrec xs :: [Int] -- Recursive ===================================== testsuite/tests/deSugar/should_compile/T22719.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE UnliftedDatatypes #-} +{-# OPTIONS_GHC -Wall #-} + +module T22719 where + +import GHC.Exts + +type T :: UnliftedType +data T = T + +f :: Int -> T +f 0 = T +f n = f (n-1) + +-- ex1 is lazy in (f 7) +ex1 :: () +ex1 = let _ = f 7 in () + +-- ex2 is strict in (f 10) +ex2 :: () +ex2 = let _a = f 10 in () ===================================== testsuite/tests/deSugar/should_compile/T22719.stderr ===================================== @@ -0,0 +1,30 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 25, types: 10, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +ex1 :: () +[GblId, Unf=OtherCon []] +ex1 = GHC.Tuple.Prim.() + +Rec { +-- RHS size: {terms: 15, types: 5, coercions: 0, joins: 0/0} +f [Occ=LoopBreaker] :: Int -> T +[GblId, Arity=1, Unf=OtherCon []] +f = \ (ds :: Int) -> + case ds of wild { I# ds1 -> + case ds1 of { + __DEFAULT -> f (- @Int GHC.Num.$fNumInt wild (GHC.Types.I# 1#)); + 0# -> T22719.T + } + } +end Rec } + +-- RHS size: {terms: 6, types: 1, coercions: 0, joins: 0/0} +ex2 :: () +[GblId] +ex2 = case f (GHC.Types.I# 10#) of { T -> GHC.Tuple.Prim.() } + + + ===================================== testsuite/tests/deSugar/should_compile/all.T ===================================== @@ -112,3 +112,4 @@ test('T16615', normal, compile, ['-ddump-ds -dsuppress-uniques']) test('T18112', [grep_errmsg('cast')], compile, ['-ddump-ds']) test('T19969', normal, compile, ['-ddump-simpl -dsuppress-uniques']) test('T19883', normal, compile, ['']) +test('T22719', normal, compile, ['-ddump-simpl -dsuppress-uniques -dno-typeable-binds']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8d7abaa6740664c62c0dbd343a202e1b7ca825e4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8d7abaa6740664c62c0dbd343a202e1b7ca825e4 You're receiving 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 Jan 10 23:48:29 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Tue, 10 Jan 2023 18:48:29 -0500 Subject: [Git][ghc/ghc][wip/specialize-hdoc] Add 'docWithStyle' to improve codegen Message-ID: <63bdf94ddef40_3b1bf9526347070c3@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/specialize-hdoc at Glasgow Haskell Compiler / GHC Commits: f893d982 by Krzysztof Gogolewski at 2023-01-11T00:48:09+01:00 Add 'docWithStyle' to improve codegen This new combinator docWithStyle :: IsOutput doc => doc -> (PprStyle -> SDoc) -> doc let us remove the need for code to be polymorphic in HDoc when not used in code style. Metric Decrease: ManyConstructors T13035 T1969 - - - - - 5 changed files: - compiler/GHC/Types/CostCentre.hs - compiler/GHC/Types/Name.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Unit/Types.hs - compiler/GHC/Utils/Outputable.hs Changes: ===================================== compiler/GHC/Types/CostCentre.hs ===================================== @@ -265,10 +265,8 @@ instance Outputable CostCentre where ppr = pprCostCentre pprCostCentre :: IsLine doc => CostCentre -> doc -pprCostCentre cc = docWithContext $ \ sty -> - if codeStyle (sdocStyle sty) - then ppCostCentreLbl cc - else ftext (costCentreUserNameFS cc) +pprCostCentre cc = docWithStyle (ppCostCentreLbl cc) + (\_ -> ftext (costCentreUserNameFS cc)) {-# SPECIALISE pprCostCentre :: CostCentre -> SDoc #-} {-# SPECIALISE pprCostCentre :: CostCentre -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable ===================================== compiler/GHC/Types/Name.hs ===================================== @@ -627,21 +627,30 @@ instance OutputableBndr Name where pprName :: forall doc. IsLine doc => Name -> doc pprName name@(Name {n_sort = sort, n_uniq = uniq, n_occ = occ}) - = docWithContext $ \ctx -> - let sty = sdocStyle ctx - debug = sdocPprDebug ctx - listTuplePuns = sdocListTuplePuns ctx - in handlePuns listTuplePuns (namePun_maybe name) $ - case sort of - WiredIn mod _ builtin -> pprExternal debug sty uniq mod occ True builtin - External mod -> pprExternal debug sty uniq mod occ False UserSyntax - System -> pprSystem debug sty uniq occ - Internal -> pprInternal debug sty uniq occ + = docWithStyle codeDoc normalDoc where - -- Print GHC.Types.List as [], etc. - handlePuns :: Bool -> Maybe FastString -> doc -> doc - handlePuns True (Just pun) _ = ftext pun - handlePuns _ _ r = r + codeDoc = case sort of + WiredIn mod _ _ -> pprModule mod <> char '_' <> ppr_z_occ_name occ + External mod -> pprModule mod <> char '_' <> ppr_z_occ_name occ + -- In code style, always qualify + -- ToDo: maybe we could print all wired-in things unqualified + -- in code style, to reduce symbol table bloat? + System -> pprUniqueAlways uniq + Internal -> pprUniqueAlways uniq + + normalDoc sty = + getPprDebug $ \debug -> + sdocOption sdocListTuplePuns $ \listTuplePuns -> + handlePuns listTuplePuns (namePun_maybe name) $ + case sort of + WiredIn mod _ builtin -> pprExternal debug sty uniq mod occ True builtin + External mod -> pprExternal debug sty uniq mod occ False UserSyntax + System -> pprSystem debug sty uniq occ + Internal -> pprInternal debug sty uniq occ + + handlePuns :: Bool -> Maybe FastString -> SDoc -> SDoc + handlePuns True (Just pun) _ = ftext pun + handlePuns _ _ r = r {-# SPECIALISE pprName :: Name -> SDoc #-} {-# SPECIALISE pprName :: Name -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable @@ -674,12 +683,8 @@ pprTickyName this_mod name pprNameUnqualified :: Name -> SDoc pprNameUnqualified Name { n_occ = occ } = ppr_occ_name occ -pprExternal :: IsLine doc => Bool -> PprStyle -> Unique -> Module -> OccName -> Bool -> BuiltInSyntax -> doc +pprExternal :: Bool -> PprStyle -> Unique -> Module -> OccName -> Bool -> BuiltInSyntax -> SDoc pprExternal debug sty uniq mod occ is_wired is_builtin - | codeStyle sty = pprModule mod <> char '_' <> ppr_z_occ_name occ - -- In code style, always qualify - -- ToDo: maybe we could print all wired-in things unqualified - -- in code style, to reduce symbol table bloat? | debug = pp_mod <> ppr_occ_name occ <> braces (hsep [if is_wired then text "(w)" else empty, pprNameSpaceBrief (occNameSpace occ), @@ -695,9 +700,8 @@ pprExternal debug sty uniq mod occ is_wired is_builtin pp_mod = ppUnlessOption sdocSuppressModulePrefixes (pprModule mod <> dot) -pprInternal :: IsLine doc => Bool -> PprStyle -> Unique -> OccName -> doc +pprInternal :: Bool -> PprStyle -> Unique -> OccName -> SDoc pprInternal debug sty uniq occ - | codeStyle sty = pprUniqueAlways uniq | debug = ppr_occ_name occ <> braces (hsep [pprNameSpaceBrief (occNameSpace occ), pprUnique uniq]) | dumpStyle sty = ppr_occ_name occ <> ppr_underscore_unique uniq @@ -706,9 +710,8 @@ pprInternal debug sty uniq occ | otherwise = ppr_occ_name occ -- User style -- Like Internal, except that we only omit the unique in Iface style -pprSystem :: IsLine doc => Bool -> PprStyle -> Unique -> OccName -> doc -pprSystem debug sty uniq occ - | codeStyle sty = pprUniqueAlways uniq +pprSystem :: Bool -> PprStyle -> Unique -> OccName -> SDoc +pprSystem debug _sty uniq occ | debug = ppr_occ_name occ <> ppr_underscore_unique uniq <> braces (pprNameSpaceBrief (occNameSpace occ)) | otherwise = ppr_occ_name occ <> ppr_underscore_unique uniq @@ -717,7 +720,7 @@ pprSystem debug sty uniq occ -- so print the unique -pprModulePrefix :: IsLine doc => PprStyle -> Module -> OccName -> doc +pprModulePrefix :: PprStyle -> Module -> OccName -> SDoc -- Print the "M." part of a name, based on whether it's in scope or not -- See Note [Printing original names] in GHC.Types.Name.Ppr pprModulePrefix sty mod occ = ppUnlessOption sdocSuppressModulePrefixes $ @@ -728,20 +731,20 @@ pprModulePrefix sty mod occ = ppUnlessOption sdocSuppressModulePrefixes $ <> pprModuleName (moduleName mod) <> dot -- scope either NameUnqual -> empty -- In scope unqualified -pprUnique :: IsLine doc => Unique -> doc +pprUnique :: Unique -> SDoc -- Print a unique unless we are suppressing them pprUnique uniq = ppUnlessOption sdocSuppressUniques $ pprUniqueAlways uniq -ppr_underscore_unique :: IsLine doc => Unique -> doc +ppr_underscore_unique :: Unique -> SDoc -- Print an underscore separating the name from its unique -- But suppress it if we aren't printing the uniques anyway ppr_underscore_unique uniq = ppUnlessOption sdocSuppressUniques $ char '_' <> pprUniqueAlways uniq -ppr_occ_name :: IsLine doc => OccName -> doc +ppr_occ_name :: OccName -> SDoc ppr_occ_name occ = ftext (occNameFS occ) -- Don't use pprOccName; instead, just print the string of the OccName; -- we print the namespace in the debug stuff above ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -200,7 +200,7 @@ pprNonVarNameSpace :: NameSpace -> SDoc pprNonVarNameSpace VarName = empty pprNonVarNameSpace ns = pprNameSpace ns -pprNameSpaceBrief :: IsLine doc => NameSpace -> doc +pprNameSpaceBrief :: NameSpace -> SDoc pprNameSpaceBrief DataName = char 'd' pprNameSpaceBrief VarName = char 'v' pprNameSpaceBrief TvName = text "tv" @@ -278,10 +278,9 @@ instance OutputableBndr OccName where pprOccName :: IsLine doc => OccName -> doc pprOccName (OccName sp occ) - = docWithContext $ \ sty -> - if codeStyle (sdocStyle sty) - then ztext (zEncodeFS occ) - else ftext occ <> whenPprDebug (braces (pprNameSpaceBrief sp)) + = docWithStyle (ztext (zEncodeFS occ)) (\_ -> ftext occ <> whenPprDebug (braces (pprNameSpaceBrief sp))) +{-# SPECIALIZE pprOccName :: OccName -> SDoc #-} +{-# SPECIALIZE pprOccName :: OccName -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable {- ************************************************************************ ===================================== compiler/GHC/Unit/Types.hs ===================================== @@ -166,7 +166,7 @@ instance Outputable InstantiatedModule where instance Outputable InstantiatedUnit where ppr = pprInstantiatedUnit -pprInstantiatedUnit :: IsLine doc => InstantiatedUnit -> doc +pprInstantiatedUnit :: InstantiatedUnit -> SDoc pprInstantiatedUnit uid = -- getPprStyle $ \sty -> pprUnitId cid <> @@ -180,8 +180,6 @@ pprInstantiatedUnit uid = where cid = instUnitInstanceOf uid insts = instUnitInsts uid -{-# SPECIALIZE pprInstantiatedUnit :: InstantiatedUnit -> SDoc #-} -{-# SPECIALIZE pprInstantiatedUnit :: InstantiatedUnit -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable -- | Class for types that are used as unit identifiers (UnitKey, UnitId, Unit) -- @@ -203,14 +201,13 @@ instance IsUnitId u => IsUnitId (GenUnit u) where unitFS HoleUnit = holeFS pprModule :: IsLine doc => Module -> doc -pprModule mod@(Module p n) = docWithContext (doc . sdocStyle) +pprModule mod@(Module p n) = docWithStyle code doc where - doc sty - | codeStyle sty = - (if p == mainUnit + code = (if p == mainUnit then empty -- never qualify the main package in code else ztext (zEncodeFS (unitFS p)) <> char '_') <> pprModuleName n + doc sty | qualModule sty mod = case p of HoleUnit -> angleBrackets (pprModuleName n) @@ -352,12 +349,10 @@ stableUnitCmp p1 p2 = unitFS p1 `lexicalCompareFS` unitFS p2 instance Outputable Unit where ppr pk = pprUnit pk -pprUnit :: IsLine doc => Unit -> doc +pprUnit :: Unit -> SDoc pprUnit (RealUnit (Definite d)) = pprUnitId d pprUnit (VirtUnit uid) = pprInstantiatedUnit uid pprUnit HoleUnit = ftext holeFS -{-# SPECIALIZE pprUnit :: Unit -> SDoc #-} -{-# SPECIALIZE pprUnit :: Unit -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable instance Show Unit where show = unitString @@ -535,12 +530,8 @@ instance Uniquable UnitId where instance Outputable UnitId where ppr = pprUnitId -pprUnitId :: IsLine doc => UnitId -> doc -pprUnitId (UnitId fs) = dualLine (sdocOption sdocUnitIdForUser ($ fs)) (ftext fs) - -- see Note [Pretty-printing UnitId] in GHC.Unit - -- also see Note [dualLine and dualDoc] in GHC.Utils.Outputable -{-# SPECIALIZE pprUnitId :: UnitId -> SDoc #-} -{-# SPECIALIZE pprUnitId :: UnitId -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable +pprUnitId :: UnitId -> SDoc +pprUnitId (UnitId fs) = sdocOption sdocUnitIdForUser ($ fs) -- | A 'DefUnitId' is an 'UnitId' with the invariant that -- it only refers to a definite library; i.e., one we have generated ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -126,6 +126,7 @@ import GHC.Data.FastString import qualified GHC.Utils.Ppr as Pretty import qualified GHC.Utils.Ppr.Colour as Col import GHC.Utils.Ppr ( Doc, Mode(..) ) +import GHC.Utils.Panic.Plain (assert) import GHC.Serialized import GHC.LanguageExtensions (Extension) import GHC.Utils.GlobalVars( unsafeHasPprDebug ) @@ -855,9 +856,10 @@ ppWhenOption f doc = sdocOption f $ \case False -> empty {-# INLINE CONLIKE ppUnlessOption #-} -ppUnlessOption :: IsLine doc => (SDocContext -> Bool) -> doc -> doc -ppUnlessOption f doc = docWithContext $ - \ctx -> if f ctx then empty else doc +ppUnlessOption :: (SDocContext -> Bool) -> SDoc -> SDoc +ppUnlessOption f doc = sdocOption f $ \case + True -> empty + False -> doc -- | Apply the given colour\/style for the argument. -- @@ -1040,10 +1042,7 @@ instance Outputable ModuleName where pprModuleName :: IsLine doc => ModuleName -> doc pprModuleName (ModuleName nm) = - docWithContext $ \ctx -> - if codeStyle (sdocStyle ctx) - then ztext (zEncodeFS nm) - else ftext nm + docWithStyle (ztext (zEncodeFS nm)) (\_ -> ftext nm) {-# SPECIALIZE pprModuleName :: ModuleName -> SDoc #-} {-# SPECIALIZE pprModuleName :: ModuleName -> HLine #-} -- see Note [SPECIALIZE to HDoc] @@ -1633,6 +1632,7 @@ IsOutput, that allows these combinators to be generic over both variants: class IsOutput doc where empty :: doc docWithContext :: (SDocContext -> doc) -> doc + docWithStyle :: doc -> (PprStyle -> SDoc) -> doc class IsOutput doc => IsLine doc class (IsOutput doc, IsLine (Line doc)) => IsDoc doc @@ -1669,13 +1669,22 @@ arguments depending on the type they are instantiated at. They serve as a difficult to make completely equivalent under both printer implementations. These operations should generally be avoided, as they can result in surprising -changes in behavior when the printer implementation is changed. However, in -certain cases, the alternative is even worse. For example, we use dualLine in -the implementation of pprUnitId, as the hack we use for printing unit ids -(see Note [Pretty-printing UnitId] in GHC.Unit) is difficult to adapt to HLine -and is not necessary for code paths that use it, anyway. - -Use these operations wisely. -} +changes in behavior when the printer implementation is changed. +Right now, they are used only when outputting debugging comments in +codegen, as it is difficult to adapt that code to use HLine and not necessary. + +Use these operations wisely. + +Note [docWithStyle] +~~~~~~~~~~~~~~~~~~~ +Sometimes when printing, we consult the printing style. This can be done +with 'docWithStyle c f'. This is similar to 'docWithContext (f . sdocStyle)', +but: +* For code style, 'docWithStyle c f' will return 'c'. +* For other styles, 'docWithStyle c f', will call 'f style', but expect + an SDoc rather than doc. This removes the need to write code polymorphic + in SDoc and HDoc, since the latter is used only for code style. +-} -- | Represents a single line of output that can be efficiently printed directly -- to a 'System.IO.Handle' (actually a 'BufHandle'). @@ -1700,7 +1709,7 @@ pattern HDoc f <- HDoc' f {-# COMPLETE HDoc #-} bPutHDoc :: BufHandle -> SDocContext -> HDoc -> IO () -bPutHDoc h ctx (HDoc f) = f ctx h +bPutHDoc h ctx (HDoc f) = assert (codeStyle (sdocStyle ctx)) (f ctx h) -- | A superclass for 'IsLine' and 'IsDoc' that provides an identity, 'empty', -- as well as access to the shared 'SDocContext'. @@ -1709,6 +1718,7 @@ bPutHDoc h ctx (HDoc f) = f ctx h class IsOutput doc where empty :: doc docWithContext :: (SDocContext -> doc) -> doc + docWithStyle :: doc -> (PprStyle -> SDoc) -> doc -- see Note [docWithStyle] -- | A class of types that represent a single logical line of text, with support -- for horizontal composition. @@ -1779,6 +1789,11 @@ instance IsOutput SDoc where {-# INLINE CONLIKE empty #-} docWithContext = sdocWithContext {-# INLINE docWithContext #-} + docWithStyle c f = sdocWithContext (\ctx -> let sty = sdocStyle ctx + in if codeStyle sty then c + else f sty) + -- see Note [docWithStyle] + {-# INLINE CONLIKE docWithStyle #-} instance IsLine SDoc where char c = docToSDoc $ Pretty.char c @@ -1823,12 +1838,16 @@ instance IsOutput HLine where {-# INLINE empty #-} docWithContext f = HLine $ \ctx h -> runHLine (f ctx) ctx h {-# INLINE CONLIKE docWithContext #-} + docWithStyle c _ = c -- see Note [docWithStyle] + {-# INLINE CONLIKE docWithStyle #-} instance IsOutput HDoc where empty = HDoc (\_ _ -> pure ()) {-# INLINE empty #-} docWithContext f = HDoc $ \ctx h -> runHDoc (f ctx) ctx h {-# INLINE CONLIKE docWithContext #-} + docWithStyle c _ = c -- see Note [docWithStyle] + {-# INLINE CONLIKE docWithStyle #-} instance IsLine HLine where char c = HLine (\_ h -> bPutChar h c) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f893d98267d1cadc62ef74cdd542c3dcc08b8aed -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f893d98267d1cadc62ef74cdd542c3dcc08b8aed You're receiving 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 Jan 10 23:58:03 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 10 Jan 2023 18:58:03 -0500 Subject: [Git][ghc/ghc][wip/darwin-ci] 2430 commits: Clarify that malloc, free etc. are the ones from stdlib.h Message-ID: <63bdfb8b3975b_3b1bf952620709190@gitlab.mail> Ben Gamari pushed to branch wip/darwin-ci at Glasgow Haskell Compiler / GHC Commits: 104bf6bf by Oleg Grenrus at 2021-09-22T08:23:08-04:00 Clarify that malloc, free etc. are the ones from stdlib.h - - - - - bb37026e by Aaron Allen at 2021-09-22T08:23:45-04:00 Convert Diagnostics in GHC.Tc.Gen.* (Part 2) Converts diagnostics in: (#20116) - GHC.Tc.Gen.Default - GHC.Tc.Gen.Export - - - - - 92257abd by Sylvain Henry at 2021-09-22T08:24:23-04:00 Link with libm dynamically (#19877) The compiler should be independent of the target. - - - - - b47fafd9 by alirezaghey at 2021-09-22T08:25:00-04:00 Fix minor inconsistency in documentation fixes #20388 - - - - - 3d328eb5 by Benjamin Maurer at 2021-09-22T08:25:37-04:00 Remove unused, undocumented debug/dump flag `-ddump-vt-trace`. See 20403. - - - - - 65c837a3 by Matthew Pickering at 2021-09-23T10:44:19+01:00 Typo [skip ci] - - - - - 69b35afd by Sven Tennie at 2021-09-23T15:59:38-04:00 deriveConstants: Add hie.yaml - - - - - 022d9717 by Sven Tennie at 2021-09-23T15:59:38-04:00 base: Generalize newStablePtrPrimMVar Make it polymorphic in the type of the MVar's value. This simple generalization makes it usable for `MVar a` instead of only `MVar ()` values. - - - - - 6f7f5990 by Sven Tennie at 2021-09-23T15:59:38-04:00 Introduce stack snapshotting / cloning (#18741) Add `StackSnapshot#` primitive type that represents a cloned stack (StgStack). The cloning interface consists of two functions, that clone either the treads own stack (cloneMyStack) or another threads stack (cloneThreadStack). The stack snapshot is offline/cold, i.e. it isn't evaluated any further. This is useful for analyses as it prevents concurrent modifications. For technical details, please see Note [Stack Cloning]. Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 29717ecb by Sven Tennie at 2021-09-23T15:59:38-04:00 Use Info Table Provenances to decode cloned stack (#18163) Emit an Info Table Provenance Entry (IPE) for every stack represeted info table if -finfo-table-map is turned on. To decode a cloned stack, lookupIPE() is used. It provides a mapping between info tables and their source location. Please see these notes for details: - [Stacktraces from Info Table Provenance Entries (IPE based stack unwinding)] - [Mapping Info Tables to Source Positions] Metric Increase: T12545 - - - - - aafda13d by Ben Gamari at 2021-09-23T16:00:17-04:00 ci: Drop redundant `cabal update`s `cabal update` is already implied by `ci.sh setup`. - - - - - ca88d91c by Ben Gamari at 2021-09-23T16:00:17-04:00 ci: Consolidate handling of cabal cache Previously the cache persistence was implemented as various ad-hoc `cp` commands at the end of the individual CI scripts. Here we move all of this logic into `ci.sh`. - - - - - cbfc0e93 by Ben Gamari at 2021-09-23T16:00:17-04:00 ci: Isolate build from HOME - - - - - 55112fbf by Ben Gamari at 2021-09-23T16:00:17-04:00 ci: Move phase timing logic into ci.sh - - - - - be11120f by Ben Gamari at 2021-09-23T16:00:17-04:00 ci: More surgical use of nix in Darwin builds - - - - - f48d747d by Ben Gamari at 2021-09-23T16:00:17-04:00 configure: Move nm search logic to new file - - - - - ee7bdc5c by Ben Gamari at 2021-09-23T16:00:18-04:00 configure: Add check for whether CC supports --target - - - - - 68509e1c by Ben Gamari at 2021-09-23T16:00:18-04:00 ci: Add version to cache key - - - - - dae4a068 by Ben Gamari at 2021-09-23T16:00:18-04:00 gitlab-ci: Ensure that CABAL_DIR is a Windows path Otherwise cabal-install falls over. - - - - - 1c91e721 by Ben Gamari at 2021-09-23T16:00:18-04:00 gitlab-ci: Use correct CABAL executable - - - - - 8a6598c7 by Ben Gamari at 2021-09-23T16:00:18-04:00 Ensure that cabal update is invoked before building - - - - - d7ee5295 by Ben Gamari at 2021-09-23T16:00:18-04:00 gitlab-ci: bash fixes - - - - - 98a30147 by GHC GitLab CI at 2021-09-23T16:00:18-04:00 hadrian: Pass CFLAGS to gmp configure - - - - - 02827066 by Ben Gamari at 2021-09-23T16:00:18-04:00 configure: Fix copy/paste error Previously both the --with-system-libffi path and the non--with-system-libffi path set CabalUseSystemLibFFI=True. This was wrong. - - - - - 316ac68f by Ben Gamari at 2021-09-23T16:00:18-04:00 configure: Clarify meaning of CabalHaveLibffi Previously the meaning of this flag was unclear and as a result I suspect that CabalHaveLibffi could be incorrectly False. - - - - - 552b32f1 by Ben Gamari at 2021-09-23T16:00:18-04:00 testsuite: Pass CFLAGS to hsc2hs tests - - - - - 7e19cb1c by Ben Gamari at 2021-09-23T16:00:18-04:00 testsuite: Fix ipeMap ipeMap.c failed to #include <string.h> - - - - - c9a87dca by Ben Gamari at 2021-09-23T16:00:18-04:00 testsuite: Make unsigned_reloc_macho_x64 and section_alignment makefile_tests - - - - - b30f90c4 by Ben Gamari at 2021-09-23T16:00:18-04:00 testsuite: Don't use cc directly in section_alignment test - - - - - a940ba7f by Ben Gamari at 2021-09-23T16:00:18-04:00 testsuite: Fix gnu sed-ism The BSD sed implementation doesn't allow `sed -i COMMAND FILE`; one must rather use `sed -i -e COMMAND FILE`. - - - - - e78752df by Ben Gamari at 2021-09-23T16:00:18-04:00 rts: Ensure that headers don't refer to undefined __STDC_VERSION__ Previously the C/C++ language version check in STG could throw an undefined macro warning due to __STDC_VERSION__ when compiled with a C++ compiler. Fix this by defining __STDC_VERSION__==0 when compiling with a C++ compiler. Fixes #20394. - - - - - 6716a4bd by Ben Gamari at 2021-09-23T16:00:18-04:00 gitlab-ci: Unset MACOSX_DEPLOYMENT_TARGET in stage0 build Otherwise we may get warnings from the toolchain if the bootstrap compiler was built with a different deployment target. - - - - - ac378d3e by Ben Gamari at 2021-09-23T16:00:18-04:00 testsuite: Ensure that C++11 is used in T20199 Otherwise we are dependent upon the C++ compiler's default language. - - - - - 33eb4a4e by Sylvain Henry at 2021-09-23T16:01:00-04:00 Constant-folding for timesInt2# (#20374) - - - - - 4b7ba3ae by Ben Gamari at 2021-09-24T23:14:31-04:00 gitlab-ci: Don't rely on $HOME when pushing test metrics As of cbfc0e933660626c9f4eaf5480076b6fcd31dceb we set $HOME to a non-existent directory to ensure hermeticity. - - - - - 8127520e by Ben Gamari at 2021-09-27T16:06:04+00:00 gitlab-ci: Ensure that temporary home exists - - - - - 0da019be by Artyom Kuznetsov at 2021-09-28T01:51:48-04:00 Remove NoGhcTc usage from HsMatchContext NoGhcTc is removed from HsMatchContext. As a result of this, HsMatchContext GhcTc is now a valid type that has Id in it, instead of Name and tcMatchesFun now takes Id instead of Name. - - - - - e38facf8 by Matthew Pickering at 2021-09-28T01:52:23-04:00 driver: Fix Ctrl-C handling with -j1 Even in -j1 we now fork all the work into it's own thread so that Ctrl-C exceptions are thrown on the main thread, which is blocked waiting for the work thread to finish. The default exception handler then picks up Ctrl-C exception and the dangling thread is killed. Fixes #20292 - - - - - 45a674aa by Sylvain Henry at 2021-09-28T01:53:01-04:00 Add `-dsuppress-core-sizes` flag (#20342) This flag is used to remove the output of core stats per binding in Core dumps. - - - - - 1935c42f by Matthew Pickering at 2021-09-28T01:53:36-04:00 hadrian: Reduce default verbosity This change reduces the default verbosity of error messages to omit the stack trace information from the printed output. For example, before all errors would have a long call trace: ``` Error when running Shake build system: at action, called at src/Rules.hs:39:19 in main:Rules at need, called at src/Rules.hs:61:5 in main:Rules * Depends on: _build/stage1/lib/package.conf.d/ghc-9.3.conf * Depends on: _build/stage1/compiler/build/libHSghc-9.3.a * Depends on: _build/stage1/compiler/build/GHC/Tc/Solver/Rewrite.o * Depends on: _build/stage1/compiler/build/GHC/Tc/Solver/Rewrite.o _build/stage1/compiler/build/GHC/Tc/Solver/Rewrite.hi at cmd', called at src/Builder.hs:330:23 in main:Builder at cmd, called at src/Builder.hs:432:8 in main:Builder * Raised the exception: ``` Which can be useful but it confusing for GHC rather than hadrian developers. Ticket #20386 - - - - - 219f7f50 by Matthew Pickering at 2021-09-28T01:53:36-04:00 hadrian: Remove deprecated tracing functions - - - - - 28963690 by Matthew Pickering at 2021-09-28T01:53:36-04:00 hadrian: Rework the verbosity levels Before we really only had two verbosity levels, normal and verbose. There are now three levels: Normal: Commands show stderr (no stdout) and minimal build failure messages. Verbose (-V): Commands also show stdout, build failure message contains callstack and additional information Diagnostic (-VV): Very verbose output showing all command lines and passing -v3 to cabal commands. -V is similar to the default verbosity from before (but a little more verbose) - - - - - 66c85e2e by Matthew Pickering at 2021-09-28T01:53:36-04:00 ci: Increase default verbosity level to `-V` (Verbose) Given the previous commit, `-V` allows us to see some useful information in CI (such as the call stack on failure) which normally people don't want to see. As a result the $VERBOSE variable now tweaks the diagnostic level one level higher (to Diagnostic), which produces a lot of output. - - - - - 58fea28e by Matthew Pickering at 2021-09-28T01:53:36-04:00 hadrian: Update documentation for new verbosity options - - - - - 26f24aec by Matthew Pickering at 2021-09-28T01:53:36-04:00 hadrian: Update comments on verbosity handling - - - - - 62b4a89b by taylorfausak at 2021-09-28T09:57:37-04:00 Remove outdated note about pragma layout - - - - - 028abd5b by Benjamin Maurer at 2021-09-28T09:58:13-04:00 Documented yet undocumented dump flags #18641 - - - - - b8d98827 by Richard Eisenberg at 2021-09-29T09:40:14-04:00 Compare FunTys as if they were TyConApps. See Note [Equality on FunTys] in TyCoRep. Close #17675. Close #17655, about documentation improvements included in this patch. Close #19677, about a further mistake around FunTy. test cases: typecheck/should_compile/T19677 - - - - - be77a9e0 by Fabian Thorand at 2021-09-29T09:40:51-04:00 Remove special case for large objects in allocateForCompact allocateForCompact() is called when the current allocation for the compact region does not fit in the nursery. It previously had a special case for objects exceeding the large object threshold. In that case, it would allocate a new compact region block just for that object. That led to a lot of small blocks being allocated in compact regions with a larger default block size (`autoBlockW`). This commit removes this special case because having a lot of small compact region blocks contributes significantly to memory fragmentation. The removal should be valid because - a more generic case for allocating a new compact region block follows at the end of allocateForCompact(), and that one takes `autoBlockW` into account - the reason for allocating separate blocks for large objects in the main heap seems to be to avoid copying during GCs, but once inside the compact region, the object will never be copied anyway. Fixes #18757. A regression test T18757 was added. - - - - - cd603062 by Kirill Zaborsky at 2021-09-29T09:41:27-04:00 Fix comment typos - - - - - 162492ea by Alexander Kjeldaas at 2021-09-29T09:41:27-04:00 Document interaction between unsafe FFI and GC In the multi-threaded RTS this can lead to hard to debug performance issues. - - - - - 361da88a by Kamil Dworakowski at 2021-09-29T09:42:04-04:00 Add a regression test for #17912 - - - - - 5cc4bd57 by Benjamin Maurer at 2021-09-29T09:42:41-04:00 Rectifying COMMENT and `mkComment` across platforms to work with SDoc and exhibit similar behaviors. Issue 20400 - - - - - a2be9f34 by Ziyang Liu at 2021-09-29T09:43:19-04:00 Document that `eqType`/`coreView` do not look through type families This isn't clear from the existing doc. - - - - - c668fd2c by Andrea Condoluci at 2021-09-29T09:44:04-04:00 TH stage restriction check for constructors, selectors, and class methods Closes ticket #17820. - - - - - d46e34d0 by Andrea Condoluci at 2021-09-29T09:44:04-04:00 Add tests for T17820 - - - - - 770fcac8 by Ben Gamari at 2021-09-29T09:44:40-04:00 GHC: Drop dead packageDbModules It was already commented out and contained a reference to the non-deterministic nameEnvElts so let's just drop it. - - - - - 42492b76 by Ben Gamari at 2021-09-29T09:44:40-04:00 compiler: Reimplement seqEltsUFM in terms of fold Rather than nonDetEltsUFM; this should eliminate some unnecessary list allocations. - - - - - 97ffd6d9 by Ben Gamari at 2021-09-29T09:44:40-04:00 compiler: Rewrite all eltsUFM occurrences to nonDetEltsUFM And remove the former. - - - - - df8c5961 by Ben Gamari at 2021-09-29T09:44:40-04:00 compiler: Fix name of GHC.Core.TyCon.Env.nameEnvElts Rename to nonDetTyConEnvElts. - - - - - 1f2ba67a by Ben Gamari at 2021-09-29T09:44:40-04:00 compiler: Make nubAvails deterministic Surprisingly this previously didn't appear to introduce any visible non-determinism but it seems worth avoiding non-determinism here. - - - - - 7c90a180 by Ben Gamari at 2021-09-29T09:44:40-04:00 compiler: Rename nameEnvElts -> nonDetNameEnvElts - - - - - 2e68d4fa by Ben Gamari at 2021-09-29T09:44:40-04:00 compiler: Use seqEltsNameEnv rather that nameEnvElts - - - - - f66eaefd by Ben Gamari at 2021-09-29T09:44:40-04:00 compiler: occEnvElts -> nonDetOccEnvElts - - - - - 594ee2f4 by Matthew Pickering at 2021-09-30T00:56:30-04:00 testsuite: Make cabal01 more robust to large environments Sebastian unfortunately wrote a very long commit message in !5667 which caused `xargs` to fail on windows because the environment was too big. Fortunately `xargs` and `rm` don't need anything from the environment so just run those commands in an empty environment (which is what env -i achieves). - - - - - c261f220 by Sebastian Graf at 2021-09-30T00:56:30-04:00 Nested CPR light unleashed (#18174) This patch enables worker/wrapper for nested constructed products, as described in `Note [Nested CPR]`. The machinery for expressing Nested CPR was already there, since !5054. Worker/wrapper is equipped to exploit Nested CPR annotations since !5338. CPR analysis already handles applications in batches since !5753. This patch just needs to flip a few more switches: 1. In `cprTransformDataConWork`, we need to look at the field expressions and their `CprType`s to see whether the evaluation of the expressions terminates quickly (= is in HNF) or if they are put in strict fields. If that is the case, then we retain their CPR info and may unbox nestedly later on. More details in `Note [Nested CPR]`. 2. Enable nested `ConCPR` signatures in `GHC.Types.Cpr`. 3. In the `asConCpr` call in `GHC.Core.Opt.WorkWrap.Utils`, pass CPR info of fields to the `Unbox`. 4. Instead of giving CPR signatures to DataCon workers and wrappers, we now have `cprTransformDataConWork` for workers and treat wrappers by analysing their unfolding. As a result, the code from GHC.Types.Id.Make went away completely. 5. I deactivated worker/wrappering for recursive DataCons and wrote a function `isRecDataCon` to detect them. We really don't want to give `repeat` or `replicate` the Nested CPR property. See Note [CPR for recursive data structures] for which kind of recursive DataCons we target. 6. Fix a couple of tests and their outputs. I also documented that CPR can destroy sharing and lead to asymptotic increase in allocations (which is tracked by #13331/#19326) in `Note [CPR for data structures can destroy sharing]`. Nofib results: ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- ben-raytrace -3.1% -0.4% binary-trees +0.8% -2.9% digits-of-e2 +5.8% +1.2% event +0.8% -2.1% fannkuch-redux +0.0% -1.4% fish 0.0% -1.5% gamteb -1.4% -0.3% mkhprog +1.4% +0.8% multiplier +0.0% -1.9% pic -0.6% -0.1% reptile -20.9% -17.8% wave4main +4.8% +0.4% x2n1 -100.0% -7.6% -------------------------------------------------------------------------------- Min -95.0% -17.8% Max +5.8% +1.2% Geometric Mean -2.9% -0.4% ``` The huge wins in x2n1 (loopy list) and reptile (see #19970) are due to refraining from unboxing (:). Other benchmarks like digits-of-e2 or wave4main regress because of that. Ultimately there are no great improvements due to Nested CPR alone, but at least it's a win. Binary sizes decrease by 0.6%. There are a significant number of metric decreases. The most notable ones (>1%): ``` ManyAlternatives(normal) ghc/alloc 771656002.7 762187472.0 -1.2% ManyConstructors(normal) ghc/alloc 4191073418.7 4114369216.0 -1.8% MultiLayerModules(normal) ghc/alloc 3095678333.3 3128720704.0 +1.1% PmSeriesG(normal) ghc/alloc 50096429.3 51495664.0 +2.8% PmSeriesS(normal) ghc/alloc 63512989.3 64681600.0 +1.8% PmSeriesV(normal) ghc/alloc 62575424.0 63767208.0 +1.9% T10547(normal) ghc/alloc 29347469.3 29944240.0 +2.0% T11303b(normal) ghc/alloc 46018752.0 47367576.0 +2.9% T12150(optasm) ghc/alloc 81660890.7 82547696.0 +1.1% T12234(optasm) ghc/alloc 59451253.3 60357952.0 +1.5% T12545(normal) ghc/alloc 1705216250.7 1751278952.0 +2.7% T12707(normal) ghc/alloc 981000472.0 968489800.0 -1.3% GOOD T13056(optasm) ghc/alloc 389322664.0 372495160.0 -4.3% GOOD T13253(normal) ghc/alloc 337174229.3 341954576.0 +1.4% T13701(normal) ghc/alloc 2381455173.3 2439790328.0 +2.4% BAD T14052(ghci) ghc/alloc 2162530642.7 2139108784.0 -1.1% T14683(normal) ghc/alloc 3049744728.0 2977535064.0 -2.4% GOOD T14697(normal) ghc/alloc 362980213.3 369304512.0 +1.7% T15164(normal) ghc/alloc 1323102752.0 1307480600.0 -1.2% T15304(normal) ghc/alloc 1304607429.3 1291024568.0 -1.0% T16190(normal) ghc/alloc 281450410.7 284878048.0 +1.2% T16577(normal) ghc/alloc 7984960789.3 7811668768.0 -2.2% GOOD T17516(normal) ghc/alloc 1171051192.0 1153649664.0 -1.5% T17836(normal) ghc/alloc 1115569746.7 1098197592.0 -1.6% T17836b(normal) ghc/alloc 54322597.3 55518216.0 +2.2% T17977(normal) ghc/alloc 47071754.7 48403408.0 +2.8% T17977b(normal) ghc/alloc 42579133.3 43977392.0 +3.3% T18923(normal) ghc/alloc 71764237.3 72566240.0 +1.1% T1969(normal) ghc/alloc 784821002.7 773971776.0 -1.4% GOOD T3294(normal) ghc/alloc 1634913973.3 1614323584.0 -1.3% GOOD T4801(normal) ghc/alloc 295619648.0 292776440.0 -1.0% T5321FD(normal) ghc/alloc 278827858.7 276067280.0 -1.0% T5631(normal) ghc/alloc 586618202.7 577579960.0 -1.5% T5642(normal) ghc/alloc 494923048.0 487927208.0 -1.4% T5837(normal) ghc/alloc 37758061.3 39261608.0 +4.0% T9020(optasm) ghc/alloc 257362077.3 254672416.0 -1.0% T9198(normal) ghc/alloc 49313365.3 50603936.0 +2.6% BAD T9233(normal) ghc/alloc 704944258.7 685692712.0 -2.7% GOOD T9630(normal) ghc/alloc 1476621560.0 1455192784.0 -1.5% T9675(optasm) ghc/alloc 443183173.3 433859696.0 -2.1% GOOD T9872a(normal) ghc/alloc 1720926653.3 1693190072.0 -1.6% GOOD T9872b(normal) ghc/alloc 2185618061.3 2162277568.0 -1.1% GOOD T9872c(normal) ghc/alloc 1765842405.3 1733618088.0 -1.8% GOOD TcPlugin_RewritePerf(normal) ghc/alloc 2388882730.7 2365504696.0 -1.0% WWRec(normal) ghc/alloc 607073186.7 597512216.0 -1.6% T9203(normal) run/alloc 107284064.0 102881832.0 -4.1% haddock.Cabal(normal) run/alloc 24025329589.3 23768382560.0 -1.1% haddock.base(normal) run/alloc 25660521653.3 25370321824.0 -1.1% haddock.compiler(normal) run/alloc 74064171706.7 73358712280.0 -1.0% ``` The biggest exception to the rule is T13701 which seems to fluctuate as usual (not unlike T12545). T14697 has a similar quality, being a generated multi-module test. T5837 is small enough that it similarly doesn't measure anything significant besides module loading overhead. T13253 simply does one additional round of Simplification due to Nested CPR. There are also some apparent regressions in T9198, T12234 and PmSeriesG that we (@mpickering and I) were simply unable to reproduce locally. @mpickering tried to run the CI script in a local Docker container and actually found that T9198 and PmSeriesG *improved*. In MRs that were rebased on top this one, like !4229, I did not experience such increases. Let's not get hung up on these regression tests, they were meant to test for asymptotic regressions. The build-cabal test improves by 1.2% in -O0. Metric Increase: T10421 T12234 T12545 T13035 T13056 T13701 T14697 T18923 T5837 T9198 Metric Decrease: ManyConstructors T12545 T12707 T13056 T14683 T16577 T18223 T1969 T3294 T9203 T9233 T9675 T9872a T9872b T9872c T9961 TcPlugin_RewritePerf - - - - - 205f0f92 by Andrea Condoluci at 2021-09-30T00:57:09-04:00 Trees That Grow refactor for HsTick and HsBinTick Move HsTick and HsBinTick to XExpr, the extension tree of HsExpr. Part of #16830 . - - - - - e0923b98 by Ben Gamari at 2021-09-30T00:57:44-04:00 ghc-boot: Eliminate unnecessary use of getEnvironment Previously we were using `System.Environment.getEnvironment`, which decodes all environment variables into Haskell `String`s, where a simple environment lookup would do. This made the compiler's allocations unnecessarily dependent on the environment. Fixes #20431. - - - - - 941d3792 by Sylvain Henry at 2021-09-30T19:41:09-04:00 Rules for sized conversion primops (#19769) Metric Decrease: T12545 - - - - - adc41a77 by Matthew Pickering at 2021-09-30T19:41:44-04:00 driver: Fix -E -XCPP, copy output from CPP ouput rather than .hs output Fixes #20416 I thought about adding a test for this case but I struggled to think of something robust. Grepping -v3 will include different paths on different systems and the structure of the result file depends on which preprocessor you are using. - - - - - 94f3ce7e by Matthew Pickering at 2021-09-30T19:42:19-04:00 Recompilation: Handle -plugin-package correctly If a plugins was specified using the -plugin-package-(id) flag then the module it applied to was always recompiled. The recompilation checker was previously using `findImportedModule`, which looked for packages in the HPT and then in the package database but only for modules specified using `-package`. The correct lookup function for plugins is `findPluginModule`, therefore we check normal imports with `findImportedModule` and plugins with `findPluginModule`. Fixes #20417 - - - - - ef92a009 by Andreas Klebinger at 2021-09-30T19:42:54-04:00 NCG: Linear-reg-alloc: A few small implemenation tweaks. Removed an intermediate list via a fold. realRegsAlias: Manually inlined the list functions to get better code. Linear.hs added a bang somewhere. - - - - - 9606774d by Aaron Allen at 2021-10-01T09:04:10-04:00 Convert Diagnostics GHC.Tc.Gen.* (Part 3) Converts all diagnostics in the `GHC.Tc.Gen.Expr` module. (#20116) - - - - - 9600a5fb by Matthew Pickering at 2021-10-01T09:04:46-04:00 code gen: Improve efficiency of findPrefRealReg Old strategy: For each variable linearly scan through all the blocks and check to see if the variable is any of the block register mappings. This is very slow when you have a lot of blocks. New strategy: Maintain a map from virtual registers to the first real register the virtual register was assigned to. Consult this map in findPrefRealReg. The map is updated when the register mapping is updated and is hidden behind the BlockAssigment abstraction. On the mmark package this reduces compilation time from about 44s to 32s. Ticket: #19471 - - - - - e3701815 by Matthew Pickering at 2021-10-01T09:05:20-04:00 ci: Unset CI_* variables before run_hadrian and test_make The goal here is to somewhat sanitize the environment so that performance tests don't fluctuate as much as they have been doing. In particular the length of the commit message was causing benchmarks to increase because gitlab stored the whole commit message twice in environment variables. Therefore when we used `getEnvironment` it would cause more allocation because more string would be created. See #20431 ------------------------- Metric Decrease: T10421 T13035 T18140 T18923 T9198 T12234 T12425 ------------------------- - - - - - e401274a by Ben Gamari at 2021-10-02T05:18:03-04:00 gitlab-ci: Bump docker images To install libncurses-dev on Debian targets. - - - - - 42f49c4e by Ben Gamari at 2021-10-02T05:18:03-04:00 Bump terminfo submodule to 0.4.1.5 Closes #20307. - - - - - cb862ecf by Andreas Schwab at 2021-10-02T05:18:40-04:00 CmmToLlvm: Sign/Zero extend parameters for foreign calls on RISC-V Like S390 and PPC64, RISC-V requires parameters for foreign calls to be extended to full words. - - - - - 0d455a18 by Richard Eisenberg at 2021-10-02T05:19:16-04:00 Use eqType, not tcEqType, in metavar kind check Close #20356. See addendum to Note [coreView vs tcView] in GHC.Core.Type for the details. Also killed old Note about metaTyVarUpdateOK, which has been gone for some time. test case: typecheck/should_fail/T20356 - - - - - 4264e74d by Ben Gamari at 2021-10-02T05:19:51-04:00 rts: Add missing write barriers in MVar wake-up paths Previously PerformPut failed to respect the non-moving collector's snapshot invariant, hiding references to an MVar and its new value by overwriting a stack frame without dirtying the stack. Fix this. PerformTake exhibited a similar bug, failing to dirty (and therefore mark) the blocked stack before mutating it. Closes #20399. - - - - - 040c347e by Ben Gamari at 2021-10-02T05:19:51-04:00 rts: Unify stack dirtiness check This fixes an inconsistency where one dirtiness check would not mask out the STACK_DIRTY flag, meaning it may also be affected by the STACK_SANE flag. - - - - - 4bdafb48 by Sylvain Henry at 2021-10-02T05:20:29-04:00 Add (++)/literal rule When we derive the Show instance of the big record in #16577, I get the following compilation times (with -O): Before: 0.91s After: 0.77s Metric Decrease: T19695 - - - - - 8b3d98ff by Sylvain Henry at 2021-10-02T05:21:07-04:00 Don't use FastString for UTF-8 encoding only - - - - - f4554f1d by Ben Gamari at 2021-10-03T14:23:36-04:00 ci: Use https:// transport and access token to push perf notes Previously we would push perf notes using a standard user and SSH key-based authentication. However, configuring SSH is unnecessarily fiddling. We now rather use HTTPS and a project access token. - - - - - 91cd1248 by Ben Gamari at 2021-10-03T14:23:45-04:00 ci/test-metrics: Clean up various bash quoting issues - - - - - ed0e29f1 by Ben Gamari at 2021-10-03T23:24:37-04:00 base: Update Unicode database to 14.0 Closes #20404. - - - - - e8693713 by Ben Gamari at 2021-10-03T23:25:11-04:00 configure: Fix redundant-argument warning from -no-pie check Modern clang versions are quite picky when it comes to reporting redundant arguments. In particular, they will warn when -no-pie is passed when no linking is necessary. Previously the configure script used a `$CC -Werror -no-pie -E` invocation to test whether `-no-pie` is necessary. Unfortunately, this meant that clang would throw a redundant argument warning, causing configure to conclude that `-no-pie` was not supported. We now rather use `$CC -Werror -no-pie`, ensuring that linking is necessary and avoiding this failure mode. Fixes #20463. - - - - - b3267fad by Sylvain Henry at 2021-10-04T08:28:23+00:00 Constant folding for negate (#20347) Only for small integral types for now. - - - - - 2308a130 by Vladislav Zavialov at 2021-10-04T18:44:07-04:00 Clean up HiePass constraints - - - - - 40c81dd2 by Matthew Pickering at 2021-10-04T23:45:11-04:00 ci: Run hadrian builds verbosely, but not tests This reduces the output from the testsuite to a more manageable level. Fixes #20432 - - - - - 347537a5 by Ben Gamari at 2021-10-04T23:45:46-04:00 compiler: Improve Haddocks of atomic MachOps - - - - - a0f44ceb by Ben Gamari at 2021-10-04T23:45:46-04:00 compiler: Fix racy ticker counter registration Previously registration of ticky entry counters was racy, performing a read-modify-write to add the new counter to the ticky_entry_ctrs list. This could result in the list becoming cyclic if multiple threads entered the same closure simultaneously. Fixes #20451. - - - - - a7629334 by Vladislav Zavialov at 2021-10-04T23:46:21-04:00 Bespoke TokenLocation data type The EpaAnnCO we were using contained an Anchor instead of EpaLocation, making it harder to work with. At the same time, using EpaLocation by itself isn't possible either, as we may have tokens without location information. Hence the new data type: data TokenLocation = NoTokenLoc | TokenLoc !EpaLocation - - - - - a14d0e63 by sheaf at 2021-10-04T23:46:58-04:00 Bump TcLevel of failing kind equality implication Not bumping the TcLevel meant that we could end up trying to add evidence terms for the implication constraint created to wrap failing kind equalities (to avoid their deferral). fixes #20043 - - - - - 48b0f17a by sheaf at 2021-10-04T23:47:35-04:00 Add a regression test for #17723 The underlying bug was fixed by b8d98827, see MR !2477 - - - - - 5601b9e2 by Matthías Páll Gissurarson at 2021-10-05T03:18:39-04:00 Speed up valid hole-fits by adding early abort and checks. By adding an early abort flag in `TcSEnv`, we can fail fast in the presence of insoluble constraints. This helps us avoid a lot of work in valid hole-fits, and we geta massive speed-up by avoiding a lot of useless work solving constraints that never come into play. Additionally, we add a simple check for degenerate hole types, such as when the type of the hole is an immutable type variable (as is the case when the hole is completely unconstrained). Then the only valid fits are the locals, so we can ignore the global candidates. This fixes #16875 - - - - - 298df16d by Krzysztof Gogolewski at 2021-10-05T03:19:14-04:00 Reject type family equation with wrong name (#20260) We should reject "type family Foo where Bar = ()". This check was done in kcTyFamInstEqn but not in tcTyFamInstEqn. I factored out arity checking, which was duplicated. - - - - - 643b6f01 by Sebastian Graf at 2021-10-05T14:32:51-04:00 WorkWrap: Nuke CPR signatures of join points (#18824) In #18824 we saw that the Simplifier didn't nuke a CPR signature of a join point when it pushed a continuation into it when it better should have. But join points are local, mostly non-exported bindings. We don't use their CPR signature anyway and would discard it at the end of the Core pipeline. Their main purpose is to propagate CPR info during CPR analysis and by the time worker/wrapper runs the signature will have served its purpose. So we zap it! Fixes #18824. - - - - - b4c0cc36 by Sebastian Graf at 2021-10-05T14:32:51-04:00 Simplifier: Get rid of demand zapping based on Note [Arity decrease] The examples in the Note were inaccurate (`$s$dm` has arity 1 and that seems OK) and the code didn't actually nuke the demand *signature* anyway. Specialise has to nuke it, but it starts from a clean IdInfo anyway (in `newSpecIdM`). So I just deleted the code. Fixes #20450. - - - - - cd1b016f by Sebastian Graf at 2021-10-05T14:32:51-04:00 CprAnal: Activate Sum CPR for local bindings We've had Sum CPR (#5075) for top-level bindings for a couple of years now. That begs the question why we didn't also activate it for local bindings, and the reasons for that are described in `Note [CPR for sum types]`. Only that it didn't make sense! The Note said that Sum CPR would destroy let-no-escapes, but that should be a non-issue since we have syntactic join points in Core now and we don't WW for them (`Note [Don't w/w join points for CPR]`). So I simply activated CPR for all bindings of sum type, thus fixing #5075 and \#16570. NoFib approves: ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- comp_lab_zift -0.0% +0.7% fluid +1.7% +0.7% reptile +0.1% +0.1% -------------------------------------------------------------------------------- Min -0.0% -0.2% Max +1.7% +0.7% Geometric Mean +0.0% +0.0% ``` There were quite a few metric decreases on the order of 1-4%, but T6048 seems to regress significantly, by 26.1%. WW'ing for a `Just` constructor and the nested data type meant additional Simplifier iterations and a 30% increase in term sizes as well as a 200-300% in type sizes due to unboxed 9-tuples. There's not much we can do about it, I'm afraid: We're just doing much more work there. Metric Decrease: T12425 T18698a T18698b T20049 T9020 WWRec Metric Increase: T6048 - - - - - 000f2a30 by Viktor Dukhovni at 2021-10-05T14:33:29-04:00 Address some Foldable documentation nits - Add link to laws from the class head - Simplify wording of left/right associativity intro paragraph - Avoid needless mention of "endomorphisms" - - - - - 7059a729 by Viktor Dukhovni at 2021-10-05T14:33:29-04:00 Add laws link and tweak Traversable class text - - - - - 43358ab9 by Viktor Dukhovni at 2021-10-05T14:33:29-04:00 Note linear `elem` cost This is a writeup of the state of play for better than linear `elem` via a helper type class. - - - - - 56899c8d by Viktor Dukhovni at 2021-10-05T14:33:29-04:00 Note elem ticket 20421 - - - - - fb6b772f by Viktor Dukhovni at 2021-10-05T14:33:29-04:00 Minor wording tweaks/fixes - - - - - f49c7012 by Viktor Dukhovni at 2021-10-05T14:33:29-04:00 Adopt David Feuer's explantion of foldl' via foldr - - - - - 5282eaa1 by Viktor Dukhovni at 2021-10-05T14:33:29-04:00 Explain Endo, Dual, ... in laws - - - - - f52df067 by Alfredo Di Napoli at 2021-10-05T14:34:04-04:00 Make GHC.Utils.Error.Validity type polymorphic This commit makes the `Validity` type polymorphic: ``` data Validity' a = IsValid -- ^ Everything is fine | NotValid a -- ^ A problem, and some indication of why -- | Monomorphic version of @Validity'@ specialised for 'SDoc's. type Validity = Validity' SDoc ``` The type has been (provisionally) renamed to Validity' to not break existing code, as the monomorphic `Validity` type is quite pervasive in a lot of signatures in GHC. Why having a polymorphic Validity? Because it carries the evidence of "what went wrong", but the old type carried an `SDoc`, which clashed with the new GHC diagnostic infrastructure (#18516). Having it polymorphic it means we can carry an arbitrary, richer diagnostic type, and this is very important for things like the `checkOriginativeSideConditions` function, which needs to report the actual diagnostic error back to `GHC.Tc.Deriv`. It also generalises Validity-related functions to be polymorphic in @a at . - - - - - ac275f42 by Alfredo Di Napoli at 2021-10-05T14:34:04-04:00 Eradicate TcRnUnknownMessage from GHC.Tc.Deriv This (big) commit finishes porting the GHC.Tc.Deriv module to support the new diagnostic infrastructure (#18516) by getting rid of the legacy calls to `TcRnUnknownMessage`. This work ended up being quite pervasive and touched not only the Tc.Deriv module but also the Tc.Deriv.Utils and Tc.Deriv.Generics module, which needed to be adapted to use the new infrastructure. This also required generalising `Validity`. More specifically, this is a breakdown of the work done: * Add and use the TcRnUselessTypeable data constructor * Add and use TcRnDerivingDefaults data constructor * Add and use the TcRnNonUnaryTypeclassConstraint data constructor * Add and use TcRnPartialTypeSignatures * Add T13324_compile2 test to test another part of the TcRnPartialTypeSignatures diagnostic * Add and use TcRnCannotDeriveInstance data constructor, which introduces a new data constructor to TcRnMessage called TcRnCannotDeriveInstance, which is further sub-divided to carry a `DeriveInstanceErrReason` which explains the reason why we couldn't derive a typeclass instance. * Add DerivErrSafeHaskellGenericInst data constructor to DeriveInstanceErrReason * Add DerivErrDerivingViaWrongKind and DerivErrNoEtaReduce * Introduce the SuggestExtensionInOrderTo Hint, which adds (and use) a new constructor to the hint type `LanguageExtensionHint` called `SuggestExtensionInOrderTo`, which can be used to give a bit more "firm" recommendations when it's obvious what the required extension is, like in the case for the `DerivingStrategies`, which automatically follows from having enabled both `DeriveAnyClass` and `GeneralizedNewtypeDeriving`. * Wildcard-free pattern matching in mk_eqn_stock, which removes `_` in favour of pattern matching explicitly on `CanDeriveAnyClass` and `NonDerivableClass`, because that determine whether or not we can suggest to the user `DeriveAnyClass` or not. - - - - - 52400ebb by Simon Peyton Jones at 2021-10-05T14:34:39-04:00 Ensure top-level binders in scope in SetLevels Ticket #20200 (the Agda failure) showed another case in which lookupIdSubst would fail to find a local Id in the InScopeSet. This time it was because SetLevels was given a program in which the top-level bindings were not in dependency order. The Simplifier (see Note [Glomming] in GHC.Core.Opt.Occuranal) and the specialiser (see Note [Top level scope] in GHC.Core.Opt.Specialise) may both produce top-level bindings where an early binding refers to a later one. One solution would be to run the occurrence analyser again to put them all in the right order. But a simpler one is to make SetLevels OK with this input by bringing all top-level binders into scope at the start. That's what this patch does. - - - - - 11240b74 by Sylvain Henry at 2021-10-05T14:35:17-04:00 Constant folding for (.&.) maxBound (#20448) - - - - - 29ee04f3 by Zubin Duggal at 2021-10-05T14:35:52-04:00 docs: Clarify documentation of `getFileSystemEncoding` (#20344) It may not always be a Unicode encoding - - - - - 435ff398 by Mann mit Hut at 2021-10-06T00:11:07-04:00 Corrected types of thread ids obtained from the RTS While the thread ids had been changed to 64 bit words in e57b7cc6d8b1222e0939d19c265b51d2c3c2b4c0 the return type of the foreign import function used to retrieve these ids - namely 'GHC.Conc.Sync.getThreadId' - was never updated accordingly. In order to fix that this function returns now a 'CUULong'. In addition to that the types used in the thread labeling subsystem were adjusted as well and several format strings were modified throughout the whole RTS to display thread ids in a consistent and correct way. Fixes #16761 - - - - - 89e98bdf by Alan Zimmerman at 2021-10-06T00:11:42-04:00 EPA: Remove duplicate AnnOpenP/AnnCloseP in DataDecl The parens EPAs were added in the tyvars where they belong, but also at the top level of the declaration. Closes #20452 - - - - - fc4c7ffb by Ryan Scott at 2021-10-06T00:12:17-04:00 Remove the Maybe in primRepName's type There's no need for this `Maybe`, as it will always be instantiated to `Just` in practice. Fixes #20482. - - - - - 4e91839a by sheaf at 2021-10-06T00:12:54-04:00 Add a regression test for #13233 This test fails on GHC 8.0.1, only when profiling is enabled, with the error: ghc: panic! (the 'impossible' happened) kindPrimRep.go a_12 This was fixed by commit b460d6c9. - - - - - 7fc986e1 by Sebastian Graf at 2021-10-06T00:13:29-04:00 CprAnal: Two regression tests For #16040 and #2387. - - - - - 9af29e7f by Matthew Pickering at 2021-10-06T10:57:24-04:00 Disable -dynamic-too if -dynamic is also passed Before if you passed both options then you would generate two identical hi/dyn_hi and o/dyn_o files, both in the dynamic way. It's better to warn this is happening rather than duplicating the work and causing potential confusion. -dynamic-too should only be used with -static. Fixes #20436 - - - - - a466b024 by sheaf at 2021-10-06T10:58:03-04:00 Improve overlap error for polykinded constraints There were two problems around `mkDictErr`: 1. An outdated call to `flattenTys` meant that we missed out on some instances. As we no longer flatten type-family applications, the logic is obsolete and can be removed. 2. We reported "out of scope" errors in a poly-kinded situation because `BoxedRep` and `Lifted` were considered out of scope. We fix this by using `pretendNameIsInScope`. fixes #20465 - - - - - b041fc6e by Ben Gamari at 2021-10-07T03:40:49-04:00 hadrian: Generate ghcii.sh in binary distributions Technically we should probably generate this in the in-place build tree as well, but I am not bothering to do so here as ghcii.sh will be removed in 9.4 when WinIO becomes the default anyways (see #12720). Fixes #19339. - - - - - 75a766a3 by Ben Gamari at 2021-10-07T03:40:49-04:00 hadrian: Fix incorrect ticket reference This was supposed to refer to #20253. - - - - - 62157287 by Teo Camarasu at 2021-10-07T03:41:27-04:00 fix non-moving gc heap space requirements estimate The space requirements of the non-moving gc are comparable to the compacting gc, not the copying gc. The copying gc requires a much larger overhead. Fixes #20475 - - - - - e82c8dd2 by Joachim Breitner at 2021-10-07T03:42:01-04:00 Fix rst syntax mistakes in release notes - - - - - 358f6222 by Benjamin Maurer at 2021-10-07T03:42:36-04:00 Removed left-over comment from `nonDetEltsUFM`-removal in `seqEltsUFM`. - - - - - 0cf23263 by Alan Zimmerman at 2021-10-07T03:43:11-04:00 EPA: Add comments to EpaDelta The EpaDelta variant of EpaLocation cannot be sorted by location. So we capture any comments that need to be printed between the prior output and this location, when creating an EpaDelta offset in ghc-exactprint. And make the EpaLocation fields strict. - - - - - e1d02fb0 by Sylvain Henry at 2021-10-07T20:20:01-04:00 Bignum: allow naturalEq#/Ne# to inline (#20361) We now perform constant folding on bigNatEq# instead. - - - - - 44886aab by Sylvain Henry at 2021-10-07T20:20:01-04:00 Bignum: allow inlining of naturalEq/Ne/Gt/Lt/Ge/Le/Compare (#20361) Perform constant folding on bigNatCompare instead. Some functions of the Enum class for Natural now need to be inlined explicitly to be specialized at call sites (because `x > lim` for Natural is inlined and the resulting function is a little too big to inline). If we don't do this, T17499 runtime allocations regresses by 16%. - - - - - 3a5a5c85 by Sylvain Henry at 2021-10-07T20:20:01-04:00 Bignum: allow naturalToWordClamp/Negate/Signum to inline (#20361) We don't need built-in rules now that bignum literals (e.g. 123 :: Natural) match with their constructors (e.g. NS 123##). - - - - - 714568bb by Sylvain Henry at 2021-10-07T20:20:01-04:00 Bignum: remove outdated comment - - - - - 4d44058d by Sylvain Henry at 2021-10-07T20:20:01-04:00 Bignum: transfer NOINLINE from Natural to BigNat - - - - - 01f5324f by Joachim Breitner at 2021-10-07T20:20:36-04:00 Recover test case for T11547 commit 98c7749 has reverted commit 59d7ee53, including the test that that file added. That test case is still valuable, so I am re-adding it. I add it with it’s current (broken) behavior so that whoever fixes it intentionally or accidentially will notice and then commit the actual desired behavior (which is kinda unspecified, see https://gitlab.haskell.org/ghc/ghc/-/issues/20455#note_382030) - - - - - 3d31f11e by Sylvain Henry at 2021-10-08T13:08:16-04:00 Don't link plugins' units with target code (#20218) Before this patch, plugin units were linked with the target code even when the unit was passed via `-plugin-package`. This is an issue to support plugins in cross-compilers (plugins are definitely not ABI compatible with target code). We now clearly separate unit dependencies for plugins and unit dependencies for target code and only link the latter ones. We've also added a test to ensure that plugin units passed via `-package` are linked with target code so that `thNameToGhcName` can still be used in plugins that need it (see T20218b). - - - - - 75aea732 by Joachim Breitner at 2021-10-08T13:08:51-04:00 New test case: Variant of T14052 with data type definitions previous attempts at fixing #11547 and #20455 were reverted because they showed some quadratic behaviour, and the test case T15052 was added to catch that. I believe that similar quadratic behavor can be triggered with current master, by using type definitions rather than value definitions, so this adds a test case similar to T14052. I have hopes that my attempts at fixing #11547 will lead to code that avoid the quadratic increase here. Or not, we will see. In any case, having this in `master` and included in future comparisons will be useful. - - - - - 374a718e by Teo Camarasu at 2021-10-08T18:09:56-04:00 Fix nonmoving gen label in gc stats report The current code assumes the non-moving generation is always generation 1, but this isn't the case if the amount of generations is greater than 2 Fixes #20461 - - - - - a37275a3 by Matthew Pickering at 2021-10-08T18:10:31-04:00 ci: Remove BROKEN_TESTS for x86 darwin builds The tests Capi_Ctype_001 Capi_Ctype_002 T12010 pass regularly on CI so let's mark them unbroken and hopefully then we can fix #20013. - - - - - e6838872 by Matthew Pickering at 2021-10-08T18:10:31-04:00 ci: Expect x86-darwin to pass Closes #20013 - - - - - 1f160cd9 by Matthew Pickering at 2021-10-08T18:10:31-04:00 Normalise output of T20199 test - - - - - 816d2561 by CarrieMY at 2021-10-08T18:11:08-04:00 Fix -E -fno-code undesirable interactions #20439 - - - - - 55a6377a by Matthew Pickering at 2021-10-08T18:11:43-04:00 code gen: Disable dead code elimination when -finfo-table-map is enabled It's important that when -finfo-table-map is enabled that we generate IPE entries just for those info tables which are actually used. To this end, the info tables which are used are collected just before code generation starts and entries only created for those tables. Not accounted for in this scheme was the dead code elimination in the native code generator. When compiling GHC this optimisation removed an info table which had an IPE entry which resulting in the following kind of linker error: ``` /home/matt/ghc-with-debug/_build/stage1/lib/../lib/x86_64-linux-ghc-9.3.20210928/libHSCabal-3.5.0.0-ghc9.3.20210928.so: error: undefined reference to '.Lc5sS_info' /home/matt/ghc-with-debug/_build/stage1/lib/../lib/x86_64-linux-ghc-9.3.20210928/libHSCabal-3.5.0.0-ghc9.3.20210928.so: error: undefined reference to '.Lc5sH_info' /home/matt/ghc-with-debug/_build/stage1/lib/../lib/x86_64-linux-ghc-9.3.20210928/libHSCabal-3.5.0.0-ghc9.3.20210928.so: error: undefined reference to '.Lc5sm_info' collect2: error: ld returned 1 exit status `cc' failed in phase `Linker'. (Exit code: 1) Development.Shake.cmd, system command failed ``` Unfortunately, by the time this optimisation happens the structure of the CmmInfoTable has been lost, we only have the generated code for the info table to play with so we can no longer just collect all the used info tables and generate the IPE map. This leaves us with two options: 1. Return a list of the names of the discarded info tables and then remove them from the map. This is awkward because we need to do code generation for the map as well. 2. Just disable this small code size optimisation when -finfo-table-map is enabled. The option produces very big object files anyway. Option 2 is much easier to implement and means we don't have to thread information around awkwardly. It's at the cost of slightly larger object files (as dead code is not eliminated). Disabling this optimisation allows an IPE build of GHC to complete successfully. Fixes #20428 - - - - - a76409c7 by Andrei Barbu at 2021-10-08T19:45:29-04:00 Add defaulting plugins. Like the built-in type defaulting rules these plugins can propose candidates to resolve ambiguous type variables. Machine learning and other large APIs like those for game engines introduce new numeric types and other complex typed APIs. The built-in defaulting mechanism isn't powerful enough to resolve ambiguous types in these cases forcing users to specify minutia that they might not even know how to do. There is an example defaulting plugin linked in the documentation. Applications include defaulting the device a computation executes on, if a gradient should be computed for a tensor, or the size of a tensor. See https://github.com/ghc-proposals/ghc-proposals/pull/396 for details. - - - - - 31983ab4 by sheaf at 2021-10-09T04:46:05-04:00 Reject GADT pattern matches in arrow notation Tickets #20469 and #20470 showed that the current implementation of arrows is not at all up to the task of supporting GADTs: GHC produces ill-scoped Core programs because it doesn't propagate the evidence introduced by a GADT pattern match. For the time being, we reject GADT pattern matches in arrow notation. Hopefully we are able to add proper support for GADTs in arrows in the future. - - - - - a356bd56 by Matthew Pickering at 2021-10-10T15:07:52+02:00 driver: Fix assertion failure on self-import Fixes #20459 - - - - - 245ab166 by Ben Gamari at 2021-10-10T17:55:10-04:00 hadrian: Include Cabal flags in verbose configure output - - - - - 9f9d6280 by Zejun Wu at 2021-10-12T01:39:53-04:00 Derive Eq instance for the HieTypeFix type We have `instance Eq a => Eq (HieType a)` already. This instance can be handy when we want to impement a function to find all `fromIntegral :: a -> a` using `case ty of { Roll (HFunTy _ a b) -> a == b; _ -> False }`. - - - - - 8d6de541 by Ben Gamari at 2021-10-12T01:40:29-04:00 nonmoving: Fix and factor out mark_trec_chunk We need to ensure that the TRecChunk itself is marked, in addition to the TRecs it contains. - - - - - aa520ba1 by Ben Gamari at 2021-10-12T01:40:29-04:00 rts/nonmoving: Rename mark_* to trace_* These functions really do no marking; they merely trace pointers. - - - - - 2c02ea8d by Ben Gamari at 2021-10-12T01:40:29-04:00 rts/primops: Fix write barrier in stg_atomicModifyMutVarzuzh Previously the call to dirty_MUT_VAR in stg_atomicModifyMutVarzuzh was missing its final argument. Fixes #20414. - - - - - 2e0c13ab by Ben Gamari at 2021-10-12T01:40:29-04:00 rts/nonmoving: Enable selector optimisation by default - - - - - 2c06720e by GHC GitLab CI at 2021-10-12T01:41:04-04:00 rts/Linker: Fix __dso_handle handling Previously the linker's handling of __dso_handle was quite wrong. Not only did we claim that __dso_handle could be NULL when statically linking (which it can not), we didn't even implement this mislead theory faithfully and instead resolved the symbol to a random pointer. This lead to the failing relocations on AArch64 noted in #20493. Here we try to implement __dso_handle as a dynamic linker would do, choosing an address within the loaded object (specifically its start address) to serve as the object's handle. - - - - - 58223dfa by Carrie Xu at 2021-10-12T01:41:41-04:00 Add Hint to "Empty 'do' block" Error Message#20147 - - - - - 8e88ef36 by Carrie Xu at 2021-10-12T01:41:41-04:00 Change affected tests stderr - - - - - 44384696 by Zubin Duggal at 2021-10-12T01:42:15-04:00 driver: Share the graph of dependencies We want to share the graph instead of recomputing it for each key. - - - - - e40feab0 by Matthew Pickering at 2021-10-12T01:42:50-04:00 Make ms_ghc_prim_import field strict If you don't promptly force this field then it ends up retaining a lot of data structures related to parsing. For example, the following retaining chain can be observed when using GHCi. ``` PState 0x4289365ca0 0x4289385d68 0x4289385db0 0x7f81b37a7838 0x7f81b3832fd8 0x4289365cc8 0x4289365cd8 0x4289365cf0 0x4289365cd8 0x4289365d08 0x4289385e48 0x7f81b4e4c290 0x7f818f63f440 0x7f818f63f440 0x7f81925ccd18 0x7f81b4e41230 0x7f818f63f440 0x7f81925ccd18 0x7f818f63f4a8 0x7f81b3832fd8 0x7f81b3832fd8 0x4289365d20 0x7f81b38233b8 0 19 <PState:GHC.Parser.Lexer:_build-ipe/stage1/compiler/build/GHC/Parser/Lexer.hs:3779:46> _thunk( ) 0x4289384230 0x4289384160 <([LEpaComment], [LEpaComment]):GHC.Parser.Lexer:> _thunk( ) 0x4289383250 <EpAnnComments:GHC.Parser.Lexer:compiler/GHC/Parser/Lexer.x:2306:19-40> _thunk( ) 0x4289399850 0x7f818f63f440 0x4289399868 <SrcSpanAnnA:GHC.Parser:_build-ipe/stage1/compiler/build/GHC/Parser.hs:12527:13-30> L 0x4289397600 0x42893975a8 <GenLocated:GHC.Parser:_build-ipe/stage1/compiler/build/GHC/Parser.hs:12527:32> 0x4289c4e8c8 : 0x4289c4e8b0 <[]:GHC.Parser.Header:compiler/GHC/Parser/Header.hs:104:36-54> (0x4289c4da70,0x7f818f63f440) <(,):GHC.Parser.Header:compiler/GHC/Parser/Header.hs:104:36-54> _thunk( ) 0x4289c4d030 <Bool:GHC.Parser.Header:compiler/GHC/Parser/Header.hs:(112,22)-(115,27)> ExtendedModSummary 0x422e9c8998 0x7f81b617be78 0x422e9c89b0 0x4289c4c0c0 0x7f81925ccd18 0x7f81925ccd18 0x7f81925ccd18 0x7f81925ccd18 0x7f818f63f440 0x4289c4c0d8 0x4289c4c0f0 0x7f81925ccd18 0x422e9c8a20 0x4289c4c108 0x4289c4c730 0x7f818f63f440 <ExtendedModSummary:GHC.Driver.Make:compiler/GHC/Driver/Make.hs:2041:30-38> ModuleNode 0x4289c4b850 <ModuleGraphNode:GHC.Unit.Module.Graph:compiler/GHC/Unit/Module/Graph.hs:139:14-36> 0x4289c4b590 : 0x4289c4b578 <[]:GHC.Unit.Module.Graph:compiler/GHC/Unit/Module/Graph.hs:139:31-36> ModuleGraph 0x4289c4b2f8 0x4289c4b310 0x4289c4b340 0x7f818f63f4a0 <ModuleGraph:GHC.Driver.Make:compiler/GHC/Driver/Make.hs:(242,19)-(244,40)> HscEnv 0x4289d9a4a8 0x4289d9aad0 0x4289d9aae8 0x4217062a88 0x4217060b38 0x4217060b58 0x4217060b68 0x7f81b38a7ce0 0x4217060b78 0x7f818f63f440 0x7f818f63f440 0x4217062af8 0x4289d9ab10 0x7f81b3907b60 0x4217060c00 114 <HscEnv:GHC.Runtime.Eval:compiler/GHC/Runtime/Eval.hs:790:31-44> ``` - - - - - 5c266b59 by Ben Gamari at 2021-10-12T19:16:40-04:00 hadrian: Introduce `static` flavour - - - - - 683011c7 by Ben Gamari at 2021-10-12T19:16:40-04:00 gitlab-ci: Introduce static Alpine job - - - - - 9257abeb by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Drop :set from ghci scripts The ghci scripts for T9293 and ghci057 used `:set` to print the currently-set options. However, in neither case was this necessary to the correctness of the test and moreover it would introduce spurious platform-dependence (e.g. since `-fexternal-dynamic-refs` is set by default only on platforms that support dynamic linking). - - - - - 82a89df7 by Ben Gamari at 2021-10-12T19:16:40-04:00 rts/linker: Define _DYNAMIC when necessary Usually the dynamic linker would define _DYNAMIC. However, when dynamic linking is not supported (e.g. on musl) it is safe to define it to be NULL. - - - - - fcd970b5 by GHC GitLab CI at 2021-10-12T19:16:40-04:00 rts/linker: Resolve __fini_array_* symbols to NULL If the __fini_array_{start,end} symbols are not defined (e.g. as is often the case when linking against musl) then resolve them to NULL. - - - - - 852ec4f5 by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Mark T13702 as requiring share libraries It fails on statically-built Alpine with ``` T13702.hs:1:1: error: Could not find module ‘Prelude’ Perhaps you haven't installed the "dyn" libraries for package ‘base-4.15.0.0’? Use -v (or `:set -v` in ghci) to see a list of the files searched for. | 1 | {-# LANGUAGE ForeignFunctionInterface #-} | ^ ``` - - - - - b604bfd9 by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Mark ghcilink00[25] as requiring dynamic linking - - - - - d709a133 by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Mark all ghci/linking/dyn tests as requiring dynamic linking - - - - - 99b8177a by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Mark T14931 as requiring dynamic linking - - - - - 2687f65e by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Compile safeInfered tests with -v0 This eliminates some spurious platform-dependence due to static linking (namely in UnsafeInfered02 due to dynamic-too). - - - - - 587d7e66 by Brian Jaress at 2021-10-12T19:16:40-04:00 documentation: flavours.md static details - - - - - 91cfe121 by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Make recomp021 less environment-sensitive Suppress output from diff to eliminate unnecessary environmental-dependence. - - - - - dc094597 by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Make T12600 more robust Previously we would depend upon `grep ... | head -n1`. In principle this should work, but on Alpine Linux `grep` complains when its stdout stream has been closed. - - - - - cdd45a61 by Ben Gamari at 2021-10-12T19:16:40-04:00 gitlab-ci: Mark more broken tests on Alpine - - - - - 9ebda74e by Ben Gamari at 2021-10-12T19:16:40-04:00 rts/RtsSymbols: Add environ - - - - - 08aa7a1d by Ben Gamari at 2021-10-12T19:16:40-04:00 rts/linker: Introduce a notion of strong symbols - - - - - 005b1848 by Ben Gamari at 2021-10-12T19:16:40-04:00 rts/RtsSymbols: Declare atexit as a strong symbol - - - - - 5987357b by Ben Gamari at 2021-10-12T19:16:40-04:00 rts/RtsSymbols: fini array - - - - - 9074b748 by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Move big-obj test from ghci/linking/dyn to ghci/linking There was nothing dynamic about this test. - - - - - 3b1c12d3 by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Fix overzealous command-line mangling Previously this attempt at suppressing make's -s flag would mangle otherwise valid arguments. - - - - - 05303f68 by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Clean up dynlib support predicates Previously it was unclear whether req_shared_libs should require: * that the platform supports dynamic library loading, * that GHC supports dynamic linking of Haskell code, or * that the dyn way libraries were built Clarify by splitting the predicate into two: * `req_dynamic_lib_support` demands that the platform support dynamic linking * `req_dynamic_hs` demands that the GHC support dynamic linking of Haskell code on the target platform Naturally `req_dynamic_hs` cannot be true unless `req_dynamic_lib_support` is also true. - - - - - 9859eede by Ben Gamari at 2021-10-12T19:16:40-04:00 gitlab-ci: Bump docker images Bumps bootstrap compiler to GHC 9.0.1. - - - - - af5ed156 by Matthew Pickering at 2021-10-12T19:17:15-04:00 Make the OccName field of NotOrphan strict In GHCi, by default the ModIface is not written to disk, this can leave a thunk which retains a TyCon which ends up retaining a great deal more on the heap. For example, here is the retainer trace from ghc-debug. ``` ... many other closures ... <TyCon:GHC.Core.TyCon:compiler/GHC/Core/TyCon.hs:1755:34-97> Just 0x423162aaa8 <Maybe:GHC.Core.TyCon:compiler/GHC/Core/TyCon.hs:(1936,11)-(1949,13)> FamilyTyCon 0x4231628318 0x4210e06260 0x4231628328 0x4231628340 0x421730a398 0x4231628358 0x4231628380 0x4231628390 0x7f0f5a171d18 0x7f0f7b1d7850 0x42316283a8 0x7f0f7b1d7830 <TyCon:GHC.Core.TyCon:compiler/GHC/Cor e/TyCon.hs:1948:30-32> _thunk( ) 0x4231624000 <OccName:GHC.Iface.Make:compiler/GHC/Iface/Make.hs:724:22-43> NotOrphan 0x42357d8ed8 <IsOrphan:GHC.Iface.Make:compiler/GHC/Iface/Make.hs:724:12-43> IfaceFamInst 0x4210e06260 0x42359aed10 0x4210e0c6b8 0x42359aed28 <IfaceFamInst:GHC.Iface.Make:> ``` Making the field strict squashes this retainer leak when using GHCi. - - - - - 0c5d9ca8 by Matthew Pickering at 2021-10-12T19:17:15-04:00 Be more careful about retaining KnotVars It is quite easy to end up accidently retaining a KnotVars, which contains pointers to a stale TypeEnv because they are placed in the HscEnv. One place in particular we have to be careful is when loading a module into the EPS in `--make` mode, we have to remove the reference to KnotVars as otherwise the interface loading thunks will forever retain reference to the KnotVars which are live at the time the interface was loaded. These changes do not go as far as to enforce the invariant described in Note [KnotVar invariants] * At the end of upsweep, there should be no live KnotVars but at least improve the situation. This is left for future work (#20491) - - - - - 105e2711 by Matthew Pickering at 2021-10-12T19:17:15-04:00 driver: Pass hsc_env with empty HPT into upsweep Otherwise you end up retaining the whole old HPT when reloading in GHCi. - - - - - 7215f6de by Matthew Pickering at 2021-10-12T19:17:15-04:00 Make fields of Linkable strict The Module field can end up retaining part of a large structure and is always calculated by projection. - - - - - 053d9deb by Matthew Pickering at 2021-10-12T19:17:15-04:00 Make the fields of MakeEnv strict There's no reason for them to be lazy, and in particular we would like to make sure the old_hpt field is evaluated. - - - - - 0d711791 by Matthew Pickering at 2021-10-12T19:17:15-04:00 More strictness around HomePackageTable This patch makes some operations to do with HomePackageTable stricter * Adding a new entry into the HPT would not allow the old HomeModInfo to be collected because the function used by insertWith wouldn't be forced. * We're careful to force the new MVar value before it's inserted into the global MVar as otherwise we retain references to old entries. - - - - - ff0409d0 by Matthew Pickering at 2021-10-12T19:17:15-04:00 driver: Filter out HPT modules **before** typecheck loop It's better to remove the modules first before performing the typecheckLoop as otherwise you can end up with thunks which reference stale HomeModInfo which are difficult to force due to the knot-tie. - - - - - c2ce1b17 by Matthew Pickering at 2021-10-12T19:17:15-04:00 Add GHCi recompilation performance test - - - - - 82938981 by Matthew Pickering at 2021-10-12T19:17:15-04:00 Force name_exe field to avoid retaining entire UnitEnv (including whole HPT) Not forcing this one place will result in GHCi using 2x memory on a reload. - - - - - 90f06a0e by Haochen Tong at 2021-10-12T19:17:53-04:00 Check for libatomic dependency for atomic operations Some platforms (e.g. RISC-V) require linking against libatomic for some (e.g. sub-word-sized) atomic operations. Fixes #19119. - - - - - 234bf368 by Haochen Tong at 2021-10-12T19:17:53-04:00 Move libatomic check into m4/fp_gcc_supports_atomics.m4 - - - - - 4cf43b2a by Haochen Tong at 2021-10-12T19:17:53-04:00 Rename fp_gcc_supports__atomics to fp_cc_supports__atomics - - - - - 0aae1b4e by Joachim Breitner at 2021-10-13T01:07:45+00:00 shadowNames: Accept an OccName, not a GreName previously, the `shadowNames` function would take `[GreName]`. This has confused me for two reasons: * Why `GreName` and not `Name`? Does the difference between a normal name and a field name matter? The code of `shadowNames` shows that it does not, but really its better if the type signatures says so. * Why `Name` and not `OccName`? The point of `shadowNames` is to shadow _unqualified names_, at least in the two use cases I am aware of (names defined on the GHCI prompt or in TH splices). The code of `shadowNames` used to have cases that peek at the module of the given name and do something if that module appears in the `GlobalRdrElt`, but I think these cases are dead code, I don’t see how they could occur in the above use cases. Also, I replaced them with `errors` and GHC would still validate. Hence removing this code (yay!) This change also allows `shadowNames` to accept an `OccSet` instead, which allows for a faster implemenation; I’ll try that separately. This in stead might help with !6703. - - - - - 19cd403b by Norman Ramsey at 2021-10-13T03:32:21-04:00 Define and export Outputable instance for StgOp - - - - - 58bd0cc1 by Zubin Duggal at 2021-10-13T13:50:10+05:30 ci: build validate-x86_64-linux-deb9-debug with hyperlinked source (#20067) - - - - - 4536e8ca by Zubin Duggal at 2021-10-13T13:51:00+05:30 hadrian, testsuite: Teach Hadrian to query the testsuite driver for dependencies Issues #19072, #17728, #20176 - - - - - 60d3e33d by Zubin Duggal at 2021-10-13T13:51:03+05:30 hadrian: Fix location for haddocks in installed pkgconfs - - - - - 337a31db by Zubin Duggal at 2021-10-13T13:51:03+05:30 testsuite: Run haddock tests on out of tree compiler - - - - - 8c224b6d by Zubin Duggal at 2021-10-13T13:51:03+05:30 ci: test in-tree compiler in hadrian - - - - - 8d5a5ecf by Zubin Duggal at 2021-10-13T13:51:03+05:30 hadrian: avoid building check-{exact,ppr} and count-deps when the tests don't need them hadrian: build optional dependencies with test compiler - - - - - d0e87d0c by Zubin Duggal at 2021-10-13T13:51:03+05:30 testsuite: remove 'req_smp' from testwsdeque - - - - - 3c0e60b8 by Zubin Duggal at 2021-10-13T13:51:03+05:30 testsuite: strip windows line endings for haddock haddock: deterministic SCC Updates haddock submodule Metric Increase: haddock.Cabal haddock.base haddock.compiler - - - - - 64460b20 by Ben Gamari at 2021-10-13T18:44:12-04:00 distrib/configure: Add AC_CONFIG_MACRO_DIRS Sadly, autoconf cannot warn when it encounters an undefined macro and therefore this bug went unnoticed for altogether far too long. - - - - - e46edfcf by sheaf at 2021-10-13T18:44:49-04:00 Set logger flags in --backpack mode Backpack used to initialise the logger before obtaining the DynFlags. This meant that logging options (such as dump flags) were not set. Initialising the logger after the session flags have been set fixes the issue. fixes #20396 - - - - - df016e4e by Matthew Pickering at 2021-10-14T08:41:17-04:00 Make sure paths are quoted in install Makefile Previously it would fail with this error: ``` if [ -L wrappers/ghc ]; then echo "ghc is a symlink"; fi ghc is a symlink cp: target 'dir/bin/ghc' is not a directory make: *** [Makefile:197: install_wrappers] Error 1 ``` which is because the install path contains a space. Fixes #20506 - - - - - 7f2ce0d6 by Joachim Breitner at 2021-10-14T08:41:52-04:00 Move BreakInfo into own module while working on GHCi stuff, e.g. `GHC.Runtime.Eval.Types`, I observed a fair amount of modules being recompiled that I didn’t expect to depend on this, from byte code interpreters to linkers. Turns out that the rather simple `BreakInfo` type is all these modules need from the `GHC.Runtime.Eval.*` hierarchy, so by moving that into its own file we make the dependency tree wider and shallower, which is probably worth it. - - - - - 557d26fa by Ziyang Liu at 2021-10-14T14:32:57-04:00 Suggest -dynamic-too in failNonStd when applicable I encountered an error that says ``` Cannot load -dynamic objects when GHC is built the normal way To fix this, either: (1) Use -fexternal-interpreter, or (2) Build the program twice: once the normal way, and then with -dynamic using -osuf to set a different object file suffix. ``` Or it could say ``` (2) Use -dynamic-too ``` - - - - - f450e948 by Joachim Breitner at 2021-10-14T14:33:32-04:00 fuzzyLookup: More deterministic order else the output may depend on the input order, which seems it may depend on the concrete Uniques, which is causing headaches when including test cases about that. - - - - - 8b7f5424 by Alan Zimmerman at 2021-10-14T14:34:07-04:00 EPA: Preserve semicolon order in annotations Ensure the AddSemiAnn items appear in increasing order, so that if they are converted to delta format they are still in the correct order. Prior to this the exact printer sorted by Span, which is meaningless for EpaDelta locations. - - - - - 481e6b54 by Matthew Pickering at 2021-10-14T14:34:42-04:00 Some extra strictness in annotation fields Locations can be quite long-lived so it's important that things which live in locations, such as annotations are forced promptly. Otherwise they end up retaining the entire PState, as evidenced by this retainer trace: ``` PState 0x4277ce6cd8 0x4277ce6d00 0x7f61f12d37d8 0x7f61f12d37d8 0x7f61f135ef78 0x4277ce6d48 0x4277ce6d58 0x4277ce6d70 0x4277ce6d58 0x4277ce6d88 0x4277ce6da0 0x7f61f29782f0 0x7f61cd16b440 0x7f61cd16b440 0x7f61d00f8d18 0x7f61f296d290 0x7f61cd16b440 0x7f61d00f8d18 0x7f61cd16b4a8 0x7f61f135ef78 0x4277ce6db8 0x4277ce6dd0 0x7f61f134f358 0 3 <PState:GHC.Parser.Lexer:_build-ipe/stage1/compiler/build/GHC/Parser/Lexer.hs:3779:46> _thunk( ) 0x4277ce6280 0x4277ce68a0 <([LEpaComment], [LEpaComment]):GHC.Parser.Lexer:> _thunk( ) 0x4277ce6568 <EpAnnComments:GHC.Parser.Lexer:compiler/GHC/Parser/Lexer.x:2306:19-40> _thunk( ) 0x4277ce62b0 0x4277ce62c0 0x4277ce6280 0x7f61f287fc58 <EpAnn AnnList:GHC.Parser:_build-ipe/stage1/compiler/build/GHC/Parser.hs:12664:13-32> SrcSpanAnn 0x4277ce6060 0x4277ce6048 <SrcSpanAnn':GHC.Parser:_build-ipe/stage1/compiler/build/GHC/Parser.hs:12664:3-35> L 0x4277ce4e70 0x428f8c9158 <GenLocated:GHC.Data.BooleanFormula:compiler/GHC/Data/BooleanFormula.hs:40:23-29> 0x428f8c8318 : 0x428f8c8300 <[]:GHC.Base:libraries/base/GHC/Base.hs:1316:16-29> Or 0x428f8c7890 <BooleanFormula:GHC.Data.BooleanFormula:compiler/GHC/Data/BooleanFormula.hs:40:23-29> IfConcreteClass 0x7f61cd16b440 0x7f61cd16b440 0x428f8c7018 0x428f8c7030 <IfaceClassBody:GHC.Iface.Make:compiler/GHC/Iface/Make.hs:(640,12)-(645,13)> ``` Making these few places strict is sufficient for now but there are perhaps more places which will need strictifying in future. ------------------------- Metric Increase: parsing001 ------------------------- - - - - - 7a8171bc by Tom Sydney Kerckhove at 2021-10-15T06:51:18+00:00 Insert warnings in the documentation of dangerous functions - - - - - 1cda768c by Joachim Breitner at 2021-10-15T18:15:36-04:00 GHC.Builtin.Uniques: Remove unused code a number of functions exported by this module are (no longer) used, so let’s remove them. In particular, it no longer seems to be the case that type variables have tag `'t'`, so removed the special handling when showing them. * the use of `initTyVarUnique` was removed in 7babb1 (with the notable commit message of "Before merging to HEAD we need to tidy up and write a proper commit message.") * `mkPseudoUniqueD`and `mkPseudoUniqueH` were added in 423d477, but never ever used? * `mkCoVarUnique` was added in 674654, but never ever used? - - - - - 88e913d4 by Oleg Grenrus at 2021-10-15T18:16:14-04:00 Null eventlog writer - - - - - bbb1f6da by Sylvain Henry at 2021-10-15T18:16:51-04:00 Hadrian: display command line above errors (#20490) - - - - - b6954f0c by Joachim Breitner at 2021-10-15T18:17:26-04:00 shadowNames: Use OccEnv a, not [OccName] this allows us to use a smarter implementation based on `Data.IntSet.differenceWith`, which should do less work. Also, it will unblock improvements to !6703. The `OccEnv a` really denotes a set of `OccName`s. We are not using `OccSet`, though, because that is an `OccEnv OccName`, and we in !6703 we want to use this with differently-valued `OccEnv`s. But `OccSet`s are readily and safely coerced into `OccEnv`s. There is no other use of `delLocalRdrEnvList` remaining, so removing that. - - - - - c9922a8e by Matthew Pickering at 2021-10-15T18:18:00-04:00 hadrian: Document lint targets Fixes #20508 - - - - - 65bf3992 by Matthew Pickering at 2021-10-17T14:06:08-04:00 ghci: Explicitly store and restore interface file cache In the old days the old HPT was used as an interface file cache when using ghci. The HPT is a `ModuleEnv HomeModInfo` and so if you were using hs-boot files then the interface file from compiling the .hs file would be present in the cache but not the hi-boot file. This used to be ok, because the .hi file used to just be a better version of the .hi-boot file, with more information so it was fine to reuse it. Now the source hash of a module is kept track of in the interface file and the source hash for the .hs and .hs-boot file are correspondingly different so it's no longer safe to reuse an interface file. I took the decision to move the cache management of interface files to GHCi itself, and provide an API where `load` can be provided with a list of interface files which can be used as a cache. An alternative would be to manage this cache somewhere in the HscEnv but it seemed that an API user should be responsible for populating and suppling the cache rather than having it managed implicitly. Fixes #20217 - - - - - 81740ce8 by sheaf at 2021-10-17T14:06:46-04:00 Introduce Concrete# for representation polymorphism checks PHASE 1: we never rewrite Concrete# evidence. This patch migrates all the representation polymorphism checks to the typechecker, using a new constraint form Concrete# :: forall k. k -> TupleRep '[] Whenever a type `ty` must be representation-polymorphic (e.g. it is the type of an argument to a function), we emit a new `Concrete# ty` Wanted constraint. If this constraint goes unsolved, we report a representation-polymorphism error to the user. The 'FRROrigin' datatype keeps track of the context of the representation-polymorphism check, for more informative error messages. This paves the way for further improvements, such as allowing type families in RuntimeReps and improving the soundness of typed Template Haskell. This is left as future work (PHASE 2). fixes #17907 #20277 #20330 #20423 #20426 updates haddock submodule ------------------------- Metric Decrease: T5642 ------------------------- - - - - - 19d1237e by Koz Ross at 2021-10-19T03:29:40-04:00 Fix infelicities in docs for lines, unlines, words, unwords - - - - - 3035d1a2 by Matthew Pickering at 2021-10-19T03:30:16-04:00 tests: Remove $(CABAL_MINIMAL_CONFIGURATION) from T16219 There is a latent issue in T16219 where -dynamic-too is enabled when compiling a signature file which causes us to enter the DT_Failed state because library-a-impl doesn't generate dyn_o files. Somehow this used to work in 8.10 (that also entered the DT_Failed state) We don't need dynamic object files when compiling a signature file but the code loads interfaces, and if dynamic-too is enabled then it will also try to load the dyn_hi file and check the two are consistent. There is another hack to do with this in `GHC.Iface.Recomp`. The fix for this test is to remove CABAL_MINIMAL_CONFIGURATION, which stops cabal building shared libraries by default. I'm of the opinion that the DT_Failed state indicates an error somewhere so we should hard fail rather than this confusing (broken) rerun logic. Whether this captures the original intent of #16219 is debateable, but it's not clear how it was supposed to work in the first place if the libraries didn't build dynamic object files. Module C imports module A, which is from a library where shared objects are not built so the test would never have worked anyway (if anything from A was used in a TH splice). - - - - - d25868b6 by Matthew Pickering at 2021-10-19T03:30:16-04:00 dynamic-too: Expand GHC.Iface.Recomp comment about the backpack hack - - - - - 837ce6cf by Matthew Pickering at 2021-10-19T03:30:16-04:00 driver: Check the correct flag to see if dynamic-too is enabled. We just need to check the flag here rather than read the variable which indicates whether dynamic-too compilation has failed. - - - - - 981f2c74 by Matthew Pickering at 2021-10-19T03:30:16-04:00 driver: Update cached DynFlags in ModSummary if we are enabling -dynamic-too - - - - - 1bc77a85 by Matthew Pickering at 2021-10-19T03:30:16-04:00 dynamic-too: Check the dynamic-too status in hscPipeline This "fixes" DT_Failed in --make mode, but only "fixes" because I still believe DT_Failed is pretty broken. - - - - - 51281e81 by Matthew Pickering at 2021-10-19T03:30:16-04:00 Add test for implicit dynamic too This test checks that we check for missing dynamic objects if dynamic-too is enabled implicitly by the driver. - - - - - 8144a92f by Matthew Pickering at 2021-10-19T03:30:16-04:00 WW: Use module name rather than filename for absent error messages WwOpts in WorkWrap.Utils initialised the wo_output_file field with the result of outputFile dflags. This is misguided because outputFile is only set when -o is specified, which is barely ever (and never in --make mode). It seems this is just used to add more context to an error message, a more appropriate thing to use I think would be a module name. Fixes #20438 - - - - - df419c1a by Matthew Pickering at 2021-10-19T03:30:16-04:00 driver: Cleanups related to ModLocation ModLocation is the data type which tells you the locations of all the build products which can affect recompilation. It is now computed in one place and not modified through the pipeline. Important locations will now just consult ModLocation rather than construct the dynamic object path incorrectly. * Add paths for dynamic object and dynamic interface files to ModLocation. * Always use the paths from mod location when looking for where to find any interface or object file. * Always use the paths in a ModLocation when deciding where to write an interface and object file. * Remove `dynamicOutputFile` and `dynamicOutputHi` functions which *calculated* (incorrectly) the location of `dyn_o` and `dyn_hi` files. * Don't set `outputFile_` and so-on in `enableCodeGenWhen`, `-o` and hence `outputFile_` should not affect the location of object files in `--make` mode. It is now sufficient to just update the ModLocation with the temporary paths. * In `hscGenBackendPipeline` don't recompute the `ModLocation` to account for `-dynamic-too`, the paths are now accurate from the start of the run. * Rename `getLocation` to `mkOneShotModLocation`, as that's the only place it's used. Increase the locality of the definition by moving it close to the use-site. * Load the dynamic interface from ml_dyn_hi_file rather than attempting to reconstruct it in load_dynamic_too. * Add a variety of tests to check how -o -dyno etc interact with each other. Some other clean-ups * DeIOify mkHomeModLocation and friends, they are all pure functions. * Move FinderOpts into GHC.Driver.Config.Finder, next to initFinderOpts. * Be more precise about whether we mean outputFile or outputFile_: there were many places where outputFile was used but the result shouldn't have been affected by `-dyno` (for example the filename of the resulting executable). In these places dynamicNow would never be set but it's still more precise to not allow for this possibility. * Typo fixes suffices -> suffixes in the appropiate places. - - - - - 3d6eb85e by Matthew Pickering at 2021-10-19T03:30:16-04:00 driver: Correct output of -fno-code and -dynamic-too Before we would print [1 of 3] Compiling T[boot] ( T.hs-boot, nothing, T.dyn_o ) Which was clearly wrong for two reasons. 1. No dynamic object file was produced for T[boot] 2. The file would be called T.dyn_o-boot if it was produced. Fixes #20300 - - - - - 753b921d by Matthew Pickering at 2021-10-19T03:30:16-04:00 Remove DT_Failed state At the moment if `-dynamic-too` fails then we rerun the whole pipeline as if we were just in `-dynamic` mode. I argue this is a misfeature and we should remove the so-called `DT_Failed` mode. In what situations do we fall back to `DT_Failed`? 1. If the `dyn_hi` file corresponding to a `hi` file is missing completely. 2. If the interface hash of `dyn_hi` doesn't match the interface hash of `hi`. What happens in `DT_Failed` mode? * The whole compiler pipeline is rerun as if the user had just passed `-dynamic`. * Therefore `dyn_hi/dyn_o` files are used which don't agree with the `hi/o` files. (As evidenced by `dynamicToo001` test). * This is very confusing as now a single compiler invocation has produced further `hi`/`dyn_hi` files which are different to each other. Why should we remove it? * In `--make` mode, which is predominately used `DT_Failed` does not work (#19782), there can't be users relying on this functionality. * In `-c` mode, the recovery doesn't fix the root issue, which is the `dyn_hi` and `hi` files are mismatched. We should instead produce an error and pass responsibility to the build system using `-c` to ensure that the prerequisites for `-dynamic-too` (dyn_hi/hi) files are there before we start compiling. * It is a misfeature to support use cases like `dynamicToo001` which allow you to mix different versions of dynamic/non-dynamic interface files. It's more likely to lead to subtle bugs in your resulting programs where out-dated build products are used rather than a deliberate choice. * In practice, people are usually compiling with `-dynamic-too` rather than separately with `-dynamic` and `-static`, so the build products always match and `DT_Failed` is only entered due to compiler bugs (see !6583) What should we do instead? * In `--make` mode, for home packages check during recompilation checking that `dyn_hi` and `hi` are both present and agree, recompile the modules if they do not. * For package modules, when loading the interface check that `dyn_hi` and `hi` are there and that they agree but fail with an error message if they are not. * In `--oneshot` mode, fail with an error message if the right files aren't already there. Closes #19782 #20446 #9176 #13616 - - - - - 7271bf78 by Joachim Breitner at 2021-10-19T03:30:52-04:00 InteractiveContext: Smarter caching when rebuilding the ic_rn_gbl_env The GlobalRdrEnv of a GHCI session changes in odd ways: New bindings are not just added "to the end", but also "in the middle", namely when changing the set of imports: These are treated as if they happened before all bindings from the prompt, even those that happened earlier. Previously, this meant that the `ic_rn_gbl_env` is recalculated from the `ic_tythings`. But this wasteful if `ic_tythings` has many entries that define the same unqualified name. By separately keeping track of a `GlobalRdrEnv` of all the locally defined things we can speed this operation up significantly. This change improves `T14052Type` by 60% (It used to be 70%, but it looks that !6723 already reaped some of the rewards). But more importantly, it hopefully unblocks #20455, becaues with this smarter caching, the change needed to fix that issue will no longer make `T14052` explode. I hope. It does regress `T14052` by 30%; caching isn’t free. Oh well. Metric Decrease: T14052Type Metric Increase: T14052 - - - - - 53c0e771 by Matthew Pickering at 2021-10-19T03:31:27-04:00 Add test for T20509 This test checks to see whether a signature can depend on another home module. Whether it should or not is up for debate, see #20509 for more details. - - - - - fdfb3b03 by Matthew Pickering at 2021-10-19T03:31:27-04:00 Make the fields of Target and TargetId strict Targets are long-lived through GHC sessions so we don't want to end up retaining In particular in 'guessTarget', the call to `unitIdOrHomeUnit` was retaining reference to an entire stale HscEnv, which in turn retained reference to a stale HomePackageTable. Making the fields strict forces that place promptly and helps ensure that mistakes like this don't happen again. - - - - - 877e6685 by Matthew Pickering at 2021-10-19T03:31:27-04:00 Temporary fix for leak with -fno-code (#20509) This hack inserted for backpack caused a very bad leak when using -fno-code where EPS entries would end up retaining stale HomePackageTables. For any interactive user, such as HLS, this is really bad as once the entry makes it's way into the EPS then it's there for the rest of the session. This is a temporary fix which "solves" the issue by filtering the HPT to only the part which is needed for the hack to work, but in future we want to separate out hole modules from the HPT entirely to avoid needing to do this kind of special casing. ------------------------- Metric Decrease: MultiLayerModulesDefsGhci ------------------------- - - - - - cfacac68 by Matthew Pickering at 2021-10-19T03:31:27-04:00 Add performance test for ghci, -fno-code and reloading (#20509) This test triggers the bad code path identified by #20509 where an entry into the EPS caused by importing Control.Applicative will retain a stale HomePackageTable. - - - - - 12d74ef7 by Richard Eisenberg at 2021-10-19T13:36:36-04:00 Care about specificity in pattern type args Close #20443. - - - - - 79c9c816 by Zubin Duggal at 2021-10-19T13:37:12-04:00 Don't print Shake Diagnostic messages (#20484) - - - - - f8ce38e6 by Emily Martins at 2021-10-19T22:21:26-04:00 Fix #19884: add warning to tags command, drop T10989 - - - - - d73131b9 by Ben Gamari at 2021-10-19T22:22:02-04:00 hadrian: Fix quoting in binary distribution installation Makefile Previously we failed to quote various paths in Hadrian's installation Makefile, resulting in #20506. - - - - - 949d7398 by Matthew Pickering at 2021-10-20T14:05:23-04:00 Add note about heap invariants [skip ci] At the moment the note just covers three important invariants but now there is a place to add more to if we think of them. - - - - - 2f75ffac by Ben Gamari at 2021-10-20T14:06:00-04:00 hadrian/doc: Add margin to staged-compilation figure - - - - - 5f274fbf by Ben Gamari at 2021-10-20T14:06:00-04:00 hadrian: Fix binary-dist support for cross-compilers Previously the logic which called ghc-pkg failed to account for the fact that the executable name may be prefixed with a triple. Moreover, the call must occur before we delete the settings file as ghc-pkg needs the latter. Fixes #20267. - - - - - 3e4b51ff by Matthew Pickering at 2021-10-20T14:06:36-04:00 Fix perf-nofib CI job The main change is to install the necessary build dependencies into an environment file using `caball install --lib`. Also updates the nofib submodule with a few fixes needed for the job to work. - - - - - ef92d889 by Matthew Pickering at 2021-10-20T14:07:12-04:00 Distribute HomeModInfo cache before starting upsweep This change means the HomeModInfo cache isn't retained until the end of upsweep and each cached interface can be collected immediately after its module is compiled. The result is lower peak memory usage when using GHCi. For Agda it reduced peak memory usage from about 1600M to 1200M. - - - - - 05b8a218 by Matthew Pickering at 2021-10-20T14:07:49-04:00 Make fields of GlobalRdrElt strict In order to do this I thought it was prudent to change the list type to a bag type to avoid doing a lot of premature work in plusGRE because of ++. Fixes #19201 - - - - - 0b575899 by Sylvain Henry at 2021-10-20T17:49:07-04:00 Bignum: constant folding for bigNatCompareWord# (#20361) - - - - - 758e0d7b by Sylvain Henry at 2021-10-20T17:49:07-04:00 Bignum: allow Integer predicates to inline (#20361) T17516 allocations increase by 48% because Integer's predicates are inlined in some Ord instance methods. These methods become too big to be inlined while they probably should: this is tracked in #20516. Metric Increase: T17516 - - - - - a901a1ae by Sylvain Henry at 2021-10-20T17:49:07-04:00 Bignum: allow Integer's signum to inline (#20361) Allow T12545 to increase because it only happens on CI with dwarf enabled and probably not related to this patch. Metric Increase: T12545 - - - - - 9ded1b17 by Matthew Pickering at 2021-10-20T17:49:42-04:00 Make sure ModIface values are still forced even if not written When we are not writing a ModIface to disk then the result can retain a lot of stuff. For example, in the case I was debugging the DocDeclsMap field was holding onto the entire HomePackageTable due to a single unforced thunk. Therefore, now if we're not going to write the interface then we still force deeply it in order to remove these thunks. The fields in the data structure are not made strict because when we read the field from the interface we don't want to load it immediately as there are parts of an interface which are unused a lot of the time. Also added a note to explain why not all the fields in a ModIface field are strict. The result of this is being able to load Agda in ghci and not leaking information across subsequent reloads. - - - - - 268857af by Matthew Pickering at 2021-10-20T17:50:19-04:00 ci: Move hlint jobs from quick-built into full-build This somewhat fixes the annoyance of not getting any "useful" feedback from a CI pipeline if you have a hlint failure. Now the hlint job runs in parallel with the other CI jobs so the feedback is recieved at the same time as other testsuite results. Fixes #20507 - - - - - f6f24515 by Joachim Breitner at 2021-10-20T17:50:54-04:00 instance Ord Name: Do not repeat default methods it is confusing to see what looks like it could be clever code, only to see that it does precisely the same thing as the default methods. Cleaning this up, to spare future readers the confusion. - - - - - 56b2b04f by Ziyang Liu at 2021-10-22T10:57:28-04:00 Document that `InScopeSet` is a superset of currently in-scope variables - - - - - 7f4e0e91 by Moritz Angermann at 2021-10-22T10:58:04-04:00 Do not sign extend CmmInt's unless negative. Might fix #20526. - - - - - 77c6f3e6 by sheaf at 2021-10-22T10:58:44-04:00 Use tcEqType in GHC.Core.Unify.uVar Because uVar used eqType instead of tcEqType, it was possible to accumulate a substitution that unified Type and Constraint. For example, a call to `tc_unify_tys` with arguments tys1 = [ k, k ] tys2 = [ Type, Constraint ] would first add `k = Type` to the substitution. That's fine, but then the second call to `uVar` would claim that the substitution also unifies `k` with `Constraint`. This could then be used to cause trouble, as per #20521. Fixes #20521 - - - - - fa5870d3 by Sylvain Henry at 2021-10-22T19:20:05-04:00 Add test for #19641 Now that Bignum predicates are inlined (!6696), we only need to add a test. Fix #19641 - - - - - 6fd7da74 by Sylvain Henry at 2021-10-22T19:20:44-04:00 Remove Indefinite We no longer need it after previous IndefUnitId refactoring. - - - - - 806e49ae by Sylvain Henry at 2021-10-22T19:20:44-04:00 Refactor package imports Use an (Raw)PkgQual datatype instead of `Maybe FastString` to represent package imports. Factorize the code that renames RawPkgQual into PkgQual in function `rnPkgQual`. Renaming consists in checking if the FastString is the magic "this" keyword, the home-unit unit-id or something else. Bump haddock submodule - - - - - 47ba842b by Haochen Tong at 2021-10-22T19:21:21-04:00 Fix compilerConfig stages Fix the call to compilerConfig because it accepts 1-indexed stage numbers. Also fixes `make stage=3`. - - - - - 621608c9 by Matthew Pickering at 2021-10-22T19:21:56-04:00 driver: Don't use the log queue abstraction when j = 1 This simplifies the code path for -j1 by not using the log queue queue abstraction. The result is that trace output isn't interleaved with other dump output like it can be with -j<N>. - - - - - dd2dba80 by Sebastian Graf at 2021-10-22T19:22:31-04:00 WorkWrap: `isRecDataCon` should not eta-reduce NewTyCon field tys (#20539) In #20539 we had a type ```hs newtype Measured a = Measured { unmeasure :: () -> a } ``` and `isRecDataCon Measured` recursed into `go_arg_ty` for `(->) ()`, because `unwrapNewTyConEtad_maybe` eta-reduced it. That triggered an assertion error a bit later. Eta reducing the field type is completely wrong to do here! Just call `unwrapNewTyCon_maybe` instead. Fixes #20539 and adds a regression test T20539. - - - - - 8300ca2e by Ben Gamari at 2021-10-24T01:26:11-04:00 driver: Export wWarningFlagMap A new feature requires Ghcide to be able to convert warnings to CLI flags (WarningFlag -> String). This is most easily implemented in terms of the internal function flagSpecOf, which uses an inefficient implementation based on linear search through a linked list. This PR derives Ord for WarningFlag, and replaces that list with a Map. Closes #19087. - - - - - 3bab222c by Sebastian Graf at 2021-10-24T01:26:46-04:00 DmdAnal: Implement Boxity Analysis (#19871) This patch fixes some abundant reboxing of `DynFlags` in `GHC.HsToCore.Match.Literal.warnAboutOverflowedLit` (which was the topic of #19407) by introducing a Boxity analysis to GHC, done as part of demand analysis. This allows to accurately capture ad-hoc unboxing decisions previously made in worker/wrapper in demand analysis now, where the boxity info can propagate through demand signatures. See the new `Note [Boxity analysis]`. The actual fix for #19407 is described in `Note [No lazy, Unboxed demand in demand signature]`, but `Note [Finalising boxity for demand signature]` is probably a better entry-point. To support the fix for #19407, I had to change (what was) `Note [Add demands for strict constructors]` a bit (now `Note [Unboxing evaluated arguments]`). In particular, we now take care of it in `finaliseBoxity` (which is only called from demand analaysis) instead of `wantToUnboxArg`. I also had to resurrect `Note [Product demands for function body]` and rename it to `Note [Unboxed demand on function bodies returning small products]` to avoid huge regressions in `join004` and `join007`, thereby fixing #4267 again. See the updated Note for details. A nice side-effect is that the worker/wrapper transformation no longer needs to look at strictness info and other bits such as `InsideInlineableFun` flags (needed for `Note [Do not unbox class dictionaries]`) at all. It simply collects boxity info from argument demands and interprets them with a severely simplified `wantToUnboxArg`. All the smartness is in `finaliseBoxity`, which could be moved to DmdAnal completely, if it wasn't for the call to `dubiousDataConInstArgTys` which would be awkward to export. I spent some time figuring out the reason for why `T16197` failed prior to my amendments to `Note [Unboxing evaluated arguments]`. After having it figured out, I minimised it a bit and added `T16197b`, which simply compares computed strictness signatures and thus should be far simpler to eyeball. The 12% ghc/alloc regression in T11545 is because of the additional `Boxity` field in `Poly` and `Prod` that results in more allocation during `lubSubDmd` and `plusSubDmd`. I made sure in the ticky profiles that the number of calls to those functions stayed the same. We can bear such an increase here, as we recently improved it by -68% (in b760c1f). T18698* regress slightly because there is more unboxing of dictionaries happening and that causes Lint (mostly) to allocate more. Fixes #19871, #19407, #4267, #16859, #18907 and #13331. Metric Increase: T11545 T18698a T18698b Metric Decrease: T12425 T16577 T18223 T18282 T4267 T9961 - - - - - 691c450f by Alan Zimmerman at 2021-10-24T01:27:21-04:00 EPA: Use LocatedA for ModuleName This allows us to use an Anchor with a DeltaPos in it when exact printing. - - - - - 3417a81a by Joachim Breitner at 2021-10-24T01:27:57-04:00 undefined: Neater CallStack in error message Users of `undefined` don’t want to see ``` files.hs: Prelude.undefined: CallStack (from HasCallStack): error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err undefined, called at file.hs:151:19 in main:Main ``` but want to see ``` files.hs: Prelude.undefined: CallStack (from HasCallStack): undefined, called at file.hs:151:19 in main:Main ``` so let’s make that so. The function for that is `withFrozenCallStack`, but that is not usable here (module dependencies, and also not representation-polymorphic). And even if it were, it could confuse GHC’s strictness analyzer, leading to big regressions in some perf tests (T10421 in particular). So after shuffling modules and definitions around, I eventually noticed that the easiest way is to just not call `error` here. Fixes #19886 - - - - - 98aa29d3 by John Ericson at 2021-10-24T01:28:33-04:00 Fix dangling reference to RtsConfig.h It hasn't existed since a2a67cd520b9841114d69a87a423dabcb3b4368e -- in 2009! - - - - - 9cde38a0 by John Ericson at 2021-10-25T17:45:15-04:00 Remove stray reference to `dist-ghcconstants` I think this hasn't been a thing since 86054b4ab5125a8b71887b06786d0a428539fb9c, almost 10 years ago! - - - - - 0f7541dc by Viktor Dukhovni at 2021-10-25T17:45:51-04:00 Tweak descriptions of lines and unlines It seems more clear to think of lines as LF-terminated rather than LF-separated. - - - - - 0255ef38 by Zubin Duggal at 2021-10-26T12:36:24-04:00 Warn if unicode bidirectional formatting characters are found in the source (#20263) - - - - - 9cc6c193 by sheaf at 2021-10-26T12:37:02-04:00 Don't default type variables in type families This patch removes the following defaulting of type variables in type and data families: - type variables of kind RuntimeRep defaulting to LiftedRep - type variables of kind Levity defaulting to Lifted - type variables of kind Multiplicity defaulting to Many It does this by passing "defaulting options" to the `defaultTyVars` function; when calling from `tcTyFamInstEqnGuts` or `tcDataFamInstHeader` we pass options that avoid defaulting. This avoids wildcards being defaulted, which caused type families to unexpectedly fail to reduce. Note that kind defaulting, applicable only with -XNoPolyKinds, is not changed by this patch. Fixes #17536 ------------------------- Metric Increase: T12227 ------------------------- - - - - - cc113616 by Artyom Kuznetsov at 2021-10-26T20:27:33+00:00 Change CaseAlt and LambdaExpr to FunRhs in deriving Foldable and Traversable (#20496) - - - - - 9bd6daa4 by John Ericson at 2021-10-27T13:29:39-04:00 Make build system: Generalize and/or document distdirs `manual-package-config` should not hard-code the distdir, and no longer does Elsewhere, we must continue to hard-code due to inconsitent distdir names across stages, so we document this referring to the existing note "inconsistent distdirs". - - - - - 9d577ea1 by John Ericson at 2021-10-27T13:30:15-04:00 Compiler dosen't need to know about certain settings from file - RTS and libdw - SMP - RTS ways I am leaving them in the settings file because `--info` currently prints all the fields in there, but in the future I do believe we should separate the info GHC actually needs from "extra metadata". The latter could go in `+RTS --info` and/or a separate file that ships with the RTS for compile-time inspection instead. - - - - - ed9ec655 by Ben Gamari at 2021-10-27T13:30:55-04:00 base: Note export of Data.Tuple.Solo in changelog - - - - - 638f6548 by Ben Gamari at 2021-10-27T13:30:55-04:00 hadrian: Turn the `static` flavour into a transformer This turns the `static` flavour into the `+fully_static` flavour transformer. - - - - - 522eab3f by Ziyang Liu at 2021-10-29T05:01:50-04:00 Show family TyCons in mk_dict_error in the case of a single match - - - - - 71700526 by Sebastian Graf at 2021-10-29T05:02:25-04:00 Add more INLINABLE and INLINE pragmas to `Enum Int*` instances Otherwise the instances aren't good list producers. See Note [Stable Unfolding for list producers]. - - - - - 925c47b4 by Sebastian Graf at 2021-10-29T05:02:25-04:00 WorkWrap: Update Unfolding with WW'd body prior to `tryWW` (#20510) We have a function in #20510 that is small enough to get a stable unfolding in WW: ```hs small :: Int -> Int small x = go 0 x where go z 0 = z * x go z y = go (z+y) (y-1) ``` But it appears we failed to use the WW'd RHS as the stable unfolding. As a result, inlining `small` would expose the non-WW'd version of `go`. That appears to regress badly in #19727 which is a bit too large to extract a reproducer from that is guaranteed to reproduce across GHC versions. The solution is to simply update the unfolding in `certainlyWillInline` with the WW'd RHS. Fixes #20510. - - - - - 7b67724b by John Ericson at 2021-10-29T16:57:48-04:00 make build system: RTS should use dist-install not dist This is the following find and replace: - `rts/dist` -> `rts/dist-install` # for paths - `rts_dist` -> `rts_dist-install` # for make rules and vars - `,dist` -> `,dist-install` # for make, just in rts/ghc.mk` Why do this? Does it matter when the RTS is just built once? The answer is, yes, I think it does, because I want the distdir--stage correspondence to be consistent. In particular, for #17191 and continuing from d5de970dafd5876ef30601697576167f56b9c132 I am going to make the headers (`rts/includes`) increasingly the responsibility of the RTS (hence their new location). However, those headers are current made for multiple stages. This will probably become unnecessary as work on #17191 progresses and the compiler proper becomes more of a freestanding cabal package (e.g. a library that can be downloaded from Hackage and built without any autoconf). However, until that is finished, we have will transitional period where the RTS and headers need to agree on dirs for multiple stages. I know the make build system is going away, but it's not going yet, so I need to change it to unblock things :). - - - - - b0a1ed55 by Sylvain Henry at 2021-10-29T16:58:35-04:00 Add test for T15547 (#15547) Fix #15547 - - - - - c8d89f62 by Sylvain Henry at 2021-10-29T16:58:35-04:00 Bignum: add missing rule Add missing "Natural -> Integer -> Word#" rule. - - - - - 2a4581ff by sheaf at 2021-10-29T16:59:13-04:00 User's guide: data family kind-inference changes Explain that the kind of a data family instance must now be fully determined by the header of the instance, and how one might migrate code to account for this change. Fixes #20527 - - - - - ea862ef5 by Ben Gamari at 2021-10-30T15:43:28-04:00 ghci: Make getModBreaks robust against DotO Unlinked Previously getModBreaks assumed that an interpreted linkable will have only a single `BCOs` `Unlinked` entry. However, in general an object may also contain `DotO`s; ignore these. Fixes #20570. - - - - - e4095c0c by John Ericson at 2021-10-31T09:04:41-04:00 Make build system: Put make generated include's in RTS distdirs These are best thought of as being part of the RTS. - After !6791, `ghcautoconf.h` won't be used by the compiler inappropriately. - `ghcversion.h` is only used once outside the RTS, which is `compiler/cbits/genSym.c`. Except we *do* mean the RTS GHC is built against there, so it's better if we always get get the installed version. - `ghcplatform.h` alone is used extensively outside the RTS, but since we no longer have a target platform it is perfectly safe/correct to get the info from the previous RTS. All 3 are exported from the RTS currently and in the bootstrap window. This commit just swaps directories around, such that the new headers may continue to be used in stage 0 despite the reasoning above, but the idea is that we can subsequently make more interesting changes doubling down on the reasoning above. In particular, in !6803 we'll start "morally" moving `ghcautonconf.h` over, introducing an RTS configure script and temporary header of its `AC_DEFINE`s until the top-level configure script doesn't define any more. Progress towards #17191 - - - - - f5471c0b by John Ericson at 2021-10-31T09:05:16-04:00 Modularize autoconf platform detection This will allow better reuse of it, such as in the upcoming RTS configure script. Progress towards #17191 - - - - - 6b38c8a6 by Ben Gamari at 2021-10-31T09:05:52-04:00 ghc: Bump Cabal-Version to 1.22 This is necessary to use reexported-modules - - - - - 6544446d by Ben Gamari at 2021-10-31T09:05:52-04:00 configure: Hide error output from --target check - - - - - 7445bd71 by Andreas Klebinger at 2021-11-01T12:13:45+00:00 Update comment in Lint.hs mkWwArgs has been renamed to mkWorkerArgs. - - - - - f1a782dd by Vladislav Zavialov at 2021-11-02T01:36:32-04:00 HsToken for let/in (#19623) One more step towards the new design of EPA. - - - - - 37a37139 by John Ericson at 2021-11-02T01:37:08-04:00 Separate some AC_SUBST / AC_DEFINE Eventually, the RTS configure alone will need the vast majority of AC_DEFINE, and the top-level configure will need the most AC_SUBST. By removing the "side effects" of the macros like this we make them more reusable so they can be shared between the two configures without doing too much. - - - - - 2f69d102 by John Ericson at 2021-11-02T01:37:43-04:00 Remove `includes_GHCCONSTANTS` from make build system It is dead code. - - - - - da1a8e29 by John Ericson at 2021-11-02T01:37:43-04:00 Treat generated RTS headers in a more consistent manner We can depend on all of them at once the same way. - - - - - a7e1be3d by Ryan Scott at 2021-11-02T01:38:53-04:00 Fix #20590 with another application of mkHsContextMaybe We were always converting empty GADT contexts to `Just []` in `GHC.ThToHs`, which caused the pretty-printer to always print them as `() => ...`. This is easily fixed by using the `mkHsContextMaybe` function when converting GADT contexts so that empty contexts are turned to `Nothing`. This is in the same tradition established in commit 4c87a3d1d14f9e28c8aa0f6062e9c4201f469ad7. In the process of fixing this, I discovered that the `Cxt` argument to `mkHsContextMaybe` is completely unnecessary, as we can just as well check if the `LHsContext GhcPs` argument is empty. Fixes #20590. - - - - - 39eed84c by Alan Zimmerman at 2021-11-02T21:39:32+00:00 EPA: Get rid of bare SrcSpan's in the ParsedSource The ghc-exactPrint library has had to re-introduce the relatavise phase. This is needed if you change the length of an identifier and want the layout to be preserved afterwards. It is not possible to relatavise a bare SrcSpan, so introduce `SrcAnn NoEpAnns` for them instead. Updates haddock submodule. - - - - - 9f42a6dc by ARATA Mizuki at 2021-11-03T09:19:17-04:00 hadrian: Use $bindir instead of `dirname $0` in ghci wrapper `dirname $0` doesn't work when the wrapper is called via a symbolic link. Fix #20589 - - - - - bf6f96a6 by Vladislav Zavialov at 2021-11-03T16:35:50+03:00 Generalize the type of wrapLocSndMA - - - - - 1419fb16 by Matthew Pickering at 2021-11-04T00:36:09-04:00 ci: Don't run alpine job in fast-ci - - - - - 6020905a by Takenobu Tani at 2021-11-04T09:40:42+00:00 Correct load_load_barrier for risc-v This patch corrects the instruction for load_load_barrier(). Current load_load_barrier() incorrectly uses `fence w,r`. It means a store-load barrier. See also linux-kernel's smp_rmb() implementation: https://github.com/torvalds/linux/blob/v5.14/arch/riscv/include/asm/barrier.h#L27 - - - - - 086e288c by Richard Eisenberg at 2021-11-04T13:04:44-04:00 Tiny renamings and doc updates Close #20433 - - - - - f0b920d1 by CarrieMY at 2021-11-05T05:30:13-04:00 Fix deferOutOfScopeVariables for qualified #20472 - - - - - 59dfb005 by Simon Peyton Jones at 2021-11-05T05:30:48-04:00 Remove record field from Solo Ticket #20562 revealed that Solo, which is a wired-in TyCon, had a record field that wasn't being added to the type env. Why not? Because wired-in TyCons don't have record fields. It's not hard to change that, but it's tiresome for this one use-case, and it seems easier simply to make `getSolo` into a standalone function. On the way I refactored the handling of Solo slightly, to put it into wiredInTyCons (where it belongs) rather than only in knownKeyNames - - - - - be3750a5 by Matthew Pickering at 2021-11-05T10:12:16-04:00 Allow CApi FFI calls in GHCi At some point in the past this started working. I noticed this when working on multiple home units and couldn't load GHC's dependencies into the interpreter. Fixes #7388 - - - - - d96ce59d by John Ericson at 2021-11-05T10:12:52-04:00 make: Futher systematize handling of generated headers This will make it easier to add and remove generated headers, as we will do when we add a configure script for the RTS. - - - - - 3645abac by John Ericson at 2021-11-05T20:25:32-04:00 Avoid GHC_STAGE and other include bits We should strive to make our includes in terms of the RTS as much as possible. One place there that is not possible, the llvm version, we make a new tiny header Stage numbers are somewhat arbitrary, if we simple need a newer RTS, we should say so. - - - - - 4896a6a6 by Matthew Pickering at 2021-11-05T20:26:07-04:00 Fix boolean confusion with Opt_NoLlvmMangler flag I accidently got the two branches of the if expression the wrong way around when refactoring. Fixes #20567 - - - - - d74cc01e by Ziyang Liu at 2021-11-06T07:53:06-04:00 Export `withTcPlugins` and `withHoleFitPlugins` - - - - - ecd6d142 by Sylvain Henry at 2021-11-06T07:53:42-04:00 i386: fix codegen of 64-bit comparisons - - - - - e279ea64 by Sylvain Henry at 2021-11-06T07:53:42-04:00 Add missing Int64/Word64 constant-folding rules - - - - - 4c86df25 by Sylvain Henry at 2021-11-06T07:53:42-04:00 Fix Int64ToInt/Word64ToWord rules on 32-bit architectures When the input literal was larger than 32-bit it would crash in a compiler with assertion enabled because it was creating an out-of-bound word-sized literal (32-bit). - - - - - 646c3e21 by Sylvain Henry at 2021-11-06T07:53:42-04:00 CI: allow perf-nofib to fail - - - - - 20956e57 by Sylvain Henry at 2021-11-06T07:53:42-04:00 Remove target dependent CPP for Word64/Int64 (#11470) Primops types were dependent on the target word-size at *compiler* compilation time. It's an issue for multi-target as GHC may not have the correct primops types for the target. This patch fixes some primops types: if they take or return fixed 64-bit values they now always use `Int64#/Word64#`, even on 64-bit architectures (where they used `Int#/Word#` before). Users of these primops may now need to convert from Int64#/Word64# to Int#/Word# (a no-op at runtime). This is a stripped down version of !3658 which goes the all way of changing the underlying primitive types of Word64/Int64. This is left for future work. T12545 allocations increase ~4% on some CI platforms and decrease ~3% on AArch64. Metric Increase: T12545 Metric Decrease: T12545 - - - - - 2800eee2 by Sylvain Henry at 2021-11-06T07:53:42-04:00 Make Word64 use Word64# on every architecture - - - - - be9d7862 by Sylvain Henry at 2021-11-06T07:53:42-04:00 Fix Int64/Word64's Enum instance fusion Performance improvement: T15185(normal) run/alloc 51112.0 41032.0 -19.7% GOOD Metric Decrease: T15185 - - - - - 6f2d6a5d by Nikolay Yakimov at 2021-11-06T11:24:50-04:00 Add regression test for #20568 GHC produced broken executables with rebindable if and -fhpc if `ifThenElse` expected non-Bool condition until GHC 9.0. This adds a simple regression test. - - - - - 7045b783 by Vladislav Zavialov at 2021-11-06T11:25:25-04:00 Refactor HdkM using deriving via * No more need for InlineHdkM, mkHdkM * unHdkM is now just a record selector * Update comments - - - - - 0d8a883e by Andreas Klebinger at 2021-11-07T12:54:30-05:00 Don't undersaturate join points through eta-reduction. In #20599 I ran into an issue where the unfolding for a join point was eta-reduced removing the required lambdas. This patch adds guards that should prevent this from happening going forward. - - - - - 3d7e3d91 by Vladislav Zavialov at 2021-11-07T12:55:05-05:00 Print the Type kind qualified when ambiguous (#20627) The Type kind is printed unqualified: ghci> :set -XNoStarIsType ghci> :k (->) (->) :: Type -> Type -> Type This is the desired behavior unless the user has defined their own Type: ghci> data Type Then we want to resolve the ambiguity by qualification: ghci> :k (->) (->) :: GHC.Types.Type -> GHC.Types.Type -> GHC.Types.Type - - - - - 184f6bc6 by John Ericson at 2021-11-07T16:26:10-05:00 Factor out unregisterised and tables next to code m4 macros These will be useful for upcoming RTS configure script. - - - - - 56705da8 by Sebastian Graf at 2021-11-07T16:26:46-05:00 Pmc: Do inhabitation test for unlifted vars (#20631) Although I thought we were already set to handle unlifted datatypes correctly, it appears we weren't. #20631 showed that it's wrong to assume `vi_bot=IsNotBot` for `VarInfo`s of unlifted types from their inception if we don't follow up with an inhabitation test to see if there are any habitable constructors left. We can't trigger the test from `emptyVarInfo`, so now we instead fail early in `addBotCt` for variables of unlifted types. Fixed #20631. - - - - - 28334b47 by sheaf at 2021-11-08T13:40:05+01:00 Default kind vars in tyfams with -XNoPolyKinds We should still default kind variables in type families in the presence of -XNoPolyKinds, to avoid suggesting enabling -XPolyKinds just because the function arrow introduced kind variables, e.g. type family F (t :: Type) :: Type where F (a -> b) = b With -XNoPolyKinds, we should still default `r :: RuntimeRep` in `a :: TYPE r`. Fixes #20584 - - - - - 3f103b1a by John Ericson at 2021-11-08T19:35:12-05:00 Factor out GHC_ADJUSTORS_METHOD m4 macro - - - - - ba9fdc51 by John Ericson at 2021-11-08T19:35:12-05:00 Factor out FP_FIND_LIBFFI and use in RTS configure too - - - - - 2929850f by Sylvain Henry at 2021-11-09T10:02:06-05:00 RTS: open timerfd synchronously (#20618) - - - - - bc498fdf by Sylvain Henry at 2021-11-09T10:02:46-05:00 Bignum: expose backendName (#20495) - - - - - 79a26df1 by Sylvain Henry at 2021-11-09T10:02:46-05:00 Don't expose bignum backend in ghc --info (#20495) GHC is bignum backend agnostic and shouldn't report this information as in the future ghc-bignum will be reinstallable potentially with a different backend that GHC is unaware of. Moreover as #20495 shows the returned information may be wrong currently. - - - - - e485f4f2 by Andreas Klebinger at 2021-11-09T19:54:31-05:00 SpecConstr - Attach evaldUnfolding to known evaluated arguments. - - - - - 983a99f0 by Ryan Scott at 2021-11-09T19:55:07-05:00 deriving: infer DatatypeContexts from data constructors, not type constructor Previously, derived instances that use `deriving` clauses would infer `DatatypeContexts` by using `tyConStupidTheta`. But this sometimes causes redundant constraints to be included in the derived instance contexts, as the constraints that appear in the `tyConStupidTheta` may not actually appear in the types of the data constructors (i.e., the `dataConStupidTheta`s). For instance, in `data Show a => T a = MkT deriving Eq`, the type of `MkT` does not require `Show`, so the derived `Eq` instance should not require `Show` either. This patch makes it so with some small tweaks to `inferConstraintsStock`. Fixes #20501. - - - - - bdd7b2be by Ryan Scott at 2021-11-09T19:55:07-05:00 Flesh out Note [The stupid context] and reference it `Note [The stupid context]` in `GHC.Core.DataCon` talks about stupid contexts from `DatatypeContexts`, but prior to this commit, it was rather outdated. This commit spruces it up and references it from places where it is relevant. - - - - - 95563259 by Li-yao Xia at 2021-11-10T09:16:21-05:00 Fix rendering of Applicative law - - - - - 0f852244 by Viktor Dukhovni at 2021-11-10T09:16:58-05:00 Improve ZipList section of Traversable overview - Fix cut/paste error by adding missing `c` pattern in `Vec3` traversable instance. - Add a bit of contextual prose above the Vec2/Vec3 instance sample code. - - - - - c4cd13b8 by Richard Eisenberg at 2021-11-10T18:18:19-05:00 Fix Note [Function types] Close #19938. - - - - - dfb9913c by sheaf at 2021-11-10T18:18:59-05:00 Improvements to rank_polymorphism.rst - rename the function f4 to h1 for consistency with the naming convention - be more explicit about the difference between `Int -> (forall a. a -> a)` and `forall a. Int -> (a -> a)` - reorder the section to make it flow better Fixes #20585 - - - - - 1540f556 by sheaf at 2021-11-10T18:19:37-05:00 Clarify hs-boot file default method restrictions The user guide wrongly stated that default methods should not be included in hs-boot files. In fact, if the class is not left abstract (no methods, no superclass constraints, ...) then the defaults must be provided and match with those given in the .hs file. We add some tests for this, as there were no tests in the testsuite that gave rise to the "missing default methods" error. Fixes #20588 - - - - - 8c0aec38 by Sylvain Henry at 2021-11-10T18:20:17-05:00 Hadrian: fix building/registering of .dll libraries - - - - - 11c9a469 by Matthew Pickering at 2021-11-11T07:21:28-05:00 testsuite: Convert hole fit performance tests into proper perf tests Fixes #20621 - - - - - c2ed85cb by Matthew Pickering at 2021-11-11T07:22:03-05:00 driver: Cache the transitive dependency calculation in ModuleGraph Two reasons for this change: 1. Avoid computing the transitive dependencies when compiling each module, this can save a lot of repeated work. 2. More robust to forthcoming changes to support multiple home units. - - - - - 4230e4fb by Matthew Pickering at 2021-11-11T07:22:03-05:00 driver: Use shared transitive dependency calculation in hptModulesBelow This saves a lot of repeated work on big dependency graphs. ------------------------- Metric Decrease: MultiLayerModules T13719 ------------------------- - - - - - af653b5f by Matthew Bauer at 2021-11-11T07:22:39-05:00 Only pass -pie, -no-pie when linking Previously, these flags were passed when both compiling and linking code. However, `-pie` and `-no-pie` are link-time-only options. Usually, this does not cause issues, but when using Clang with `-Werror` set results in errors: clang: error: argument unused during compilation: '-nopie' [-Werror,-Wunused-command-line-argument] This is unused by Clang because this flag has no effect at compile time (it’s called `-nopie` internally by Clang but called `-no-pie` in GHC for compatibility with GCC). Just passing these flags at linking time resolves this. Additionally, update #15319 hack to look for `-pgml` instead. Because of the main change, the value of `-pgmc` does not matter when checking for the workaround of #15319. However, `-pgml` *does* still matter as not all `-pgml` values support `-no-pie`. To cover all potential values, we assume that no custom `-pgml` values support `-no-pie`. This means that we run the risk of not using `-no-pie` when it is otherwise necessary for in auto-hardened toolchains! This could be a problem at some point, but this workaround was already introduced in 8d008b71 and we might as well continue supporting it. Likewise, mark `-pgmc-supports-no-pie` as deprecated and create a new `-pgml-supports-no-pie`. - - - - - 7cc6ebdf by Sebastian Graf at 2021-11-11T07:23:14-05:00 Add regression test for #20598 Fixes #20598, which is mostly a duplicate of #18824 but for GHC 9.2. - - - - - 7b44c816 by Simon Jakobi at 2021-11-12T21:20:17-05:00 Turn GHC.Data.Graph.Base.Graph into a newtype - - - - - a57cc754 by John Ericson at 2021-11-12T21:20:52-05:00 Make: Do not generate ghc.* headers in stage0 GHC should get everything it needs from the RTS, which for stage0 is the "old" RTS that comes from the bootstrap compiler. - - - - - 265ead8a by Richard Eisenberg at 2021-11-12T21:21:27-05:00 Improve redundant-constraints warning Previously, we reported things wrong with f :: (Eq a, Ord a) => a -> Bool f x = x == x saying that Eq a was redundant. This is fixed now, along with some simplification in Note [Replacement vs keeping]. There's a tiny bit of extra complexity in setImplicationStatus, but it's explained in Note [Tracking redundant constraints]. Close #20602 - - - - - ca90ffa3 by Richard Eisenberg at 2021-11-12T21:21:27-05:00 Use local instances with least superclass depth See new Note [Use only the best local instance] in GHC.Tc.Solver.Interact. This commit also refactors the InstSC/OtherSC mechanism slightly. Close #20582. - - - - - dfc4093c by Vladislav Zavialov at 2021-11-12T21:22:03-05:00 Implement -Wforall-identifier (#20609) In accordance with GHC Proposal #281 "Visible forall in types of terms": For three releases before this change takes place, include a new warning -Wforall-identifier in -Wdefault. This warning will be triggered at definition sites (but not use sites) of forall as an identifier. Updates the haddock submodule. - - - - - 4143bd21 by Cheng Shao at 2021-11-12T21:22:39-05:00 hadrian: use /bin/sh in timeout wrapper /usr/bin/env doesn't work within a nix build. - - - - - 43cab5f7 by Simon Peyton Jones at 2021-11-12T21:23:15-05:00 Get the in-scope set right in simplArg This was a simple (but long standing) error in simplArg, revealed by #20639 - - - - - 578b8b48 by Ben Gamari at 2021-11-12T21:23:51-05:00 gitlab-ci: Allow draft MRs to fail linting jobs Addresses #20623 by allowing draft MRs to fail linting jobs. - - - - - 908e49fa by Ben Gamari at 2021-11-12T21:23:51-05:00 Fix it - - - - - 05166660 by Ben Gamari at 2021-11-12T21:23:51-05:00 Fix it - - - - - e41cffb0 by Ben Gamari at 2021-11-12T21:23:51-05:00 Fix it - - - - - cce3a025 by Ben Gamari at 2021-11-12T21:23:51-05:00 Fix it - - - - - 4499db7d by Ben Gamari at 2021-11-12T21:23:51-05:00 Fix it - - - - - dd1be88b by Travis Whitaker at 2021-11-12T21:24:29-05:00 mmapForLinkerMarkExecutable: do nothing when len = 0 - - - - - 4c6ace75 by John Ericson at 2021-11-12T21:25:04-05:00 Delete compiler/MachDeps.h This was accidentally added back in 28334b475a109bdeb8d53d58c48adb1690e2c9b4 after it is was no longer needed by the compiler proper in 20956e5784fe43781d156dd7ab02f0bff4ab41fb. - - - - - 490e8c75 by John Ericson at 2021-11-12T21:25:40-05:00 Generate ghcversion.h with the top-level configure This is, rather unintuitively, part of the goal of making the packages that make of the GHC distribution more freestanding. `ghcversion.h` is very simple, so we easily can move it out of the main build systems (make and Hadrian). By doing so, the RTS becomes less of a special case to those build systems as the header, already existing in the source tree, appears like any other. We could do this with the upcomming RTS configure, but it hardly matters because there is nothing platform-specific here, it is just versioning information like the other files the top-level configure can be responsible for. - - - - - bba156f3 by John Ericson at 2021-11-12T21:26:15-05:00 Remove bit about size_t in ghc-llvm-version.h This shouldn't be here. It wasn't causing a problem because this header was only used from Haskell, but still. - - - - - 0b1da2f1 by John Ericson at 2021-11-12T21:26:50-05:00 Make: Install RTS headers in `$libdir/rts/include` not `$libdir/include` Before we were violating the convention of every other package. This fixes that. It matches the changes made in d5de970dafd5876ef30601697576167f56b9c132 to the location of the files in the repo. - - - - - b040d0d4 by Sebastian Graf at 2021-11-12T21:27:26-05:00 Add regression test for #20663 - - - - - c6065292 by John Ericson at 2021-11-12T21:28:02-05:00 Make: Move remaining built RTS headers to ...build/include This allows us to clean up the rts include dirs in the package conf. - - - - - aa372972 by Ryan Scott at 2021-11-15T10:17:57-05:00 Refactoring: Consolidate some arguments with DerivInstTys Various functions in GHC.Tc.Deriv.* were passing around `TyCon`s and `[Type]`s that ultimately come from the same `DerivInstTys`. This patch moves the definition of `DerivInstTys` to `GHC.Tc.Deriv.Generate` so that all of these `TyCon` and `[Type]` arguments can be consolidated into a single `DerivInstTys`. Not only does this make the code easier to read (in my opinion), this will also be important in a subsequent commit where we need to add another field to `DerivInstTys` that will also be used from `GHC.Tc.Deriv.Generate` and friends. - - - - - 564a19af by Ryan Scott at 2021-11-15T10:17:57-05:00 Refactoring: Move DataConEnv to GHC.Core.DataCon `DataConEnv` will prove to be useful in another place besides `GHC.Core.Opt.SpecConstr` in a follow-up commit. - - - - - 3e5f0595 by Ryan Scott at 2021-11-15T10:17:57-05:00 Instantiate field types properly in stock-derived instances Previously, the `deriving` machinery was very loosey-goosey about how it used the types of data constructor fields when generating code. It would usually just consult `dataConOrigArgTys`, which returns the _uninstantiated_ field types of each data constructor. Usually, you can get away with this, but issues #20375 and #20387 revealed circumstances where this approach fails. Instead, when generated code for a stock-derived instance `C (T arg_1 ... arg_n)`, one must take care to instantiate the field types of each data constructor with `arg_1 ... arg_n`. The particulars of how this is accomplished is described in the new `Note [Instantiating field types in stock deriving]` in `GHC.Tc.Deriv.Generate`. Some highlights: * `DerivInstTys` now has a new `dit_dc_inst_arg_env :: DataConEnv [Type]` field that caches the instantiated field types of each data constructor. Whenever we need to consult the field types somewhere in `GHC.Tc.Deriv.*` we avoid using `dataConOrigArgTys` and instead look it up in `dit_dc_inst_arg_env`. * Because `DerivInstTys` now stores the instantiated field types of each constructor, some of the details of the `GHC.Tc.Deriv.Generics.mkBindsRep` function were able to be simplified. In particular, we no longer need to apply a substitution to instantiate the field types in a `Rep(1)` instance, as that is already done for us by `DerivInstTys`. We still need a substitution to implement the "wrinkle" section of `Note [Generating a correctly typed Rep instance]`, but the code is nevertheless much simpler than before. * The `tyConInstArgTys` function has been removed in favor of the new `GHC.Core.DataCon.dataConInstUnivs` function, which is really the proper tool for the job. `dataConInstUnivs` is much like `tyConInstArgTys` except that it takes a data constructor, not a type constructor, as an argument, and it adds extra universal type variables from that data constructor at the end of the returned list if need be. `dataConInstUnivs` takes care to instantiate the kinds of the universal type variables at the end, thereby avoiding a bug in `tyConInstArgTys` discovered in https://gitlab.haskell.org/ghc/ghc/-/issues/20387#note_377037. Fixes #20375. Fixes #20387. - - - - - 25d36c31 by John Ericson at 2021-11-15T10:18:32-05:00 Make: Get rid of GHC_INCLUDE_DIRS These dirs should not be included in all stages. Instead make the per-stage `BUILD_*_INCLUDE_DIR` "plural" to insert `rts/include` in the right place. - - - - - b679721a by John Ericson at 2021-11-15T10:18:32-05:00 Delete dead code knobs for building GHC itself As GHC has become target agnostic, we've left behind some now-useless logic in both build systems. - - - - - 3302f42a by Sylvain Henry at 2021-11-15T13:19:42-05:00 Fix windres invocation I've already fixed this 7 months ago in the comments of #16780 but it never got merged. Now we need this for #20657 too. - - - - - d9f54905 by Sylvain Henry at 2021-11-15T13:19:42-05:00 Hadrian: fix windows cross-build (#20657) Many small things to fix: * Hadrian: platform triple is "x86_64-w64-mingw32" and this wasn't recognized by Hadrian (note "w64" instead of "unknown") * Hadrian was using the build platform ("isWindowsHost") to detect the use of the Windows toolchain, which was wrong. We now use the "targetOs" setting. * Hadrian was doing the same thing for Darwin so we fixed both at once, even if cross-compilation to Darwin is unlikely to happen afaik (cf "osxHost" vs "osxTarget" changes) * Hadrian: libffi name was computed in two different places and one of them wasn't taking the different naming on Windows into account. * Hadrian was passing "-Irts/include" when building the stage1 compiler leading to the same error as in #18143 (which is using make). stage1's RTS is stage0's one so mustn't do this. * Hadrian: Windows linker doesn't seem to support "-zorigin" so we don't pass it (similarly to Darwin) * Hadrian: hsc2hs in cross-compilation mode uses a trick (taken from autoconf): it defines "static int test_array[SOME_EXPR]" where SOME_EXPR is a constant expression. However GCC reports an error because SOME_EXPR is supposedly not constant. This is fixed by using another method enabled with the `--via-asm` flag of hsc2hs. It has been fixed in `make` build system (5f6fcf7808b16d066ad0fb2068225b3f2e8363f7) but not in Hadrian. * Hadrian: some packages are specifically built only on Windows but they shouldn't be when building a cross-compiler (`touchy` and `ghci-wrapper`). We now correctly detect this case and disable these packages. * Base: we use `iNVALID_HANDLE_VALUE` in a few places. It fixed some hsc2hs issues before we switched to `--via-asm` (see above). I've kept these changes are they make the code nicer. * Base: `base`'s configure tries to detect if it is building for Windows but for some reason the `$host_alias` value is `x86_64-windows` in my case and it wasn't properly detected. * Base: libraries/base/include/winio_structs.h imported "Windows.h" with a leading uppercase. It doesn't work on case-sensitive systems when cross-compiling so we have to use "windows.h". * RTS: rts/win32/ThrIOManager.c was importin "rts\OSThreads.h" but this path isn't valid when cross-compiling. We replaced "\" with "/". * DeriveConstants: this tool derives the constants from the target RTS header files. However these header files define `StgAsyncIOResult` only when `mingw32_HOST_OS` is set hence it seems we have to set it explicitly. Note that deriveConstants is called more than once (why? there is only one target for now so it shouldn't) and in the second case this value is correctly defined (probably coming indirectly from the import of "rts/PosixSource.h"). A better fix would probably be to disable the unneeded first run of deriveconstants. - - - - - cc635da1 by Richard Eisenberg at 2021-11-15T13:20:18-05:00 Link to ghc-proposals repo from README A potential contributor said that they weren't aware of ghc-proposals. This might increase visibility. - - - - - a8e1a756 by Ben Gamari at 2021-11-16T03:12:34-05:00 gitlab-ci: Refactor toolchain provision This makes it easier to invoke ci.sh on Darwin by teaching it to manage the nix business. - - - - - 1f0014a8 by Ben Gamari at 2021-11-16T03:12:34-05:00 gitlab-ci: Fail if dynamic references are found in a static bindist Previously we called error, which just prints an error, rather than fail, which actually fails. - - - - - 85f2c0ba by Ben Gamari at 2021-11-16T03:12:34-05:00 gitlab-ci/darwin: Move SDK path discovery into toolchain.nix Reduce a bit of duplication and a manual step when running builds manually. - - - - - 3e94b5a7 by John Ericson at 2021-11-16T03:13:10-05:00 Make: Get rid of `BUILD_.*_INCLUDE_DIRS` First, we improve some of the rules around -I include dirs, and CPP opts. Then, we just specify the RTS's include dirs normally (locally per the package and in the package conf), and then everything should work normally. The primops.txt.pp rule needs no extra include dirs at all, as it no longer bakes in a target platfom. Reverts some of the extra stage arguments I added in 05419e55cab272ed39790695f448b311f22669f7, as they are no longer needed. - - - - - 083a7583 by Ben Gamari at 2021-11-17T05:10:27-05:00 Increase type sharing Fixes #20541 by making mkTyConApp do more sharing of types. In particular, replace * BoxedRep Lifted ==> LiftedRep * BoxedRep Unlifted ==> UnliftedRep * TupleRep '[] ==> ZeroBitRep * TYPE ZeroBitRep ==> ZeroBitType In each case, the thing on the right is a type synonym for the thing on the left, declared in ghc-prim:GHC.Types. See Note [Using synonyms to compress types] in GHC.Core.Type. The synonyms for ZeroBitRep and ZeroBitType are new, but absolutely in the same spirit as the other ones. (These synonyms are mainly for internal use, though the programmer can use them too.) I also renamed GHC.Core.Ty.Rep.isVoidTy to isZeroBitTy, to be compatible with the "zero-bit" nomenclature above. See discussion on !6806. There is a tricky wrinkle: see GHC.Core.Types Note [Care using synonyms to compress types] Compiler allocation decreases by up to 0.8%. - - - - - 20a4f251 by Ben Gamari at 2021-11-17T05:11:03-05:00 hadrian: Factor out --extra-*-dirs=... pattern We repeated this idiom quite a few times. Give it a name. - - - - - 4cec6cf2 by Ben Gamari at 2021-11-17T05:11:03-05:00 hadrian: Ensure that term.h is in include search path terminfo now requires term.h but previously neither build system offered any way to add the containing directory to the include search path. Fix this in Hadrian. Also adds libnuma includes to global include search path as it was inexplicably missing earlier. - - - - - 29086749 by Sebastian Graf at 2021-11-17T05:11:38-05:00 Pmc: Don't case split on wildcard matches (#20642) Since 8.10, when formatting a pattern match warning, we'd case split on a wildcard match such as ```hs foo :: [a] -> [a] foo [] = [] foo xs = ys where (_, ys@(_:_)) = splitAt 0 xs -- Pattern match(es) are non-exhaustive -- In a pattern binding: -- Patterns not matched: -- ([], []) -- ((_:_), []) ``` But that's quite verbose and distracts from which part of the pattern was actually the inexhaustive one. We'd prefer a wildcard for the first pair component here, like it used to be in GHC 8.8. On the other hand, case splitting is pretty handy for `-XEmptyCase` to know the different constructors we could've matched on: ```hs f :: Bool -> () f x = case x of {} -- Pattern match(es) are non-exhaustive -- In a pattern binding: -- Patterns not matched: -- False -- True ``` The solution is to communicate that we want a top-level case split to `generateInhabitingPatterns` for `-XEmptyCase`, which is exactly what this patch arranges. Details in `Note [Case split inhabiting patterns]`. Fixes #20642. - - - - - c591ab1f by Sebastian Graf at 2021-11-17T05:11:38-05:00 testsuite: Refactor pmcheck all.T - - - - - 33c0c83d by Andrew Pritchard at 2021-11-17T05:12:17-05:00 Fix Haddock markup on Data.Type.Ord.OrdCond. - - - - - 7bcd91f4 by Andrew Pritchard at 2021-11-17T05:12:17-05:00 Provide in-line kind signatures for Data.Type.Ord.Compare. Haddock doesn't know how to render SAKS, so the only current way to make the documentation show the kind is to write what it should say into the type family declaration. - - - - - 16d86b97 by ARATA Mizuki at 2021-11-17T05:12:56-05:00 bitReverse functions in GHC.Word are since base-4.14.0.0, not 4.12.0.0 They were added in 33173a51c77d9960d5009576ad9b67b646dfda3c, which constitutes GHC 8.10.1 / base-4.14.0.0 - - - - - 7850142c by Morrow at 2021-11-17T11:14:37+00:00 Improve handling of import statements in GHCi (#20473) Currently in GHCi, when given a line of user input we: 1. Attempt to parse and handle it as a statement 2. Otherwise, attempt to parse and handle a single import 3. Otherwise, check if there are imports present (and if so display an error message) 4. Otherwise, attempt to parse a module and only handle the declarations This patch simplifies the process to: Attempt to parse and handle it as a statement Otherwise, attempt to parse a module and handle the imports and declarations This means that multiple imports in a multiline are now accepted, and a multiline containing both imports and declarations is now accepted (as well as when separated by semicolons). - - - - - 09d44b4c by Zubin Duggal at 2021-11-18T01:37:36-05:00 hadrian: add threadedDebug RTS way to devel compilers - - - - - 5fa45db7 by Zubin Duggal at 2021-11-18T01:37:36-05:00 testsuite: disable some tests when we don't have dynamic libraries - - - - - f8c1c549 by Matthew Pickering at 2021-11-18T01:38:11-05:00 Revert "base: Use one-shot kqueue on macOS" This reverts commit 41117d71bb58e001f6a2b6a11c9314d5b70b9182 - - - - - f55ae180 by Simon Peyton Jones at 2021-11-18T14:44:45-05:00 Add one line of comments (c.f. !5706) Ticket #19815 suggested changing coToMCo to use isReflexiveCo rather than isReflCo. But perf results weren't encouraging. This patch just adds a comment to point to the data, such as it is. - - - - - 12d023d1 by Vladislav Zavialov at 2021-11-18T14:45:20-05:00 testsuite: check for FlexibleContexts in T17563 The purpose of testsuite/tests/typecheck/should_fail/T17563.hs is to make sure we do validity checking on quantified constraints. In particular, see the following functions in GHC.Tc.Validity: * check_quant_pred * check_pred_help * check_class_pred The original bug report used a~b constraints as an example of a constraint that requires validity checking. But with GHC Proposal #371, equality constraints no longer require GADTs or TypeFamilies; instead, they require TypeOperators, which are checked earlier in the pipeline, in the renamer. Rather than simply remove this test, we change the example to use another extension: FlexibleContexts. Since we decide whether a constraint requires this extension in check_class_pred, the regression test continues to exercise the relevant code path. - - - - - 78d4bca0 by Ben Gamari at 2021-11-18T22:27:20-05:00 ghc-cabal, make: Add support for building C++ object code Co-Authored By: Matthew Pickering <matthew at well-typed.com> - - - - - a8b4961b by Ben Gamari at 2021-11-18T22:27:20-05:00 Bump Cabal submodule - - - - - 59e8a900 by Ben Gamari at 2021-11-18T22:27:20-05:00 Bump text and parsec submodules Accommodates text-2.0. Metric Decrease: T15578 - - - - - 7f7d7888 by Ben Gamari at 2021-11-18T22:27:20-05:00 ghc-cabal: Use bootstrap compiler's text package This avoids the need to build `text` without Cabal, in turn avoiding the need to reproduce the workaround for #20010 contained therein. - - - - - 048f8d96 by Ben Gamari at 2021-11-18T22:27:20-05:00 gitlab-ci: Bump MACOSX_DEPLOYMENT_TARGET It appears that Darwin's toolchain includes system headers in the dependency makefiles it generates with `-M` with older `MACOSX_DEPLOYMENT_TARGETS`. To avoid this we have bumped the deployment target for x86-64/Darwin to 10.10. - - - - - 0acbbd20 by Ben Gamari at 2021-11-18T22:27:20-05:00 testsuite: Use libc++ rather than libstdc++ in objcpp-hi It appears that libstdc++ is no longer available in recent XCode distributions. Closes #16083. - - - - - aed98dda by John Ericson at 2021-11-18T22:27:55-05:00 Hadrian: bring up to date with latest make improvements Headers should be associated with the RTS, and subject to less hacks. The most subtle issue was that the package-grained dependencies on generated files were being `need`ed before calculating Haskell deps, but not before calculating C/C++ deps. - - - - - aabff109 by Ben Gamari at 2021-11-20T05:34:27-05:00 Bump deepseq submodule to 1.4.7.0-pre Addresses #20653. - - - - - 3d6b78db by Matthew Pickering at 2021-11-20T05:35:02-05:00 Remove unused module import syntax from .bkp mode .bkp mode had this unused feature where you could write module A and it would go looking for A.hs on the file system and use that rather than provide the definition inline. This isn't use anywhere in the testsuite and the code to find the module A looks dubious. Therefore to reduce .bkp complexity I propose to remove it. Fixes #20701 - - - - - bdeea37e by Sylvain Henry at 2021-11-20T05:35:42-05:00 More support for optional home-unit This is a preliminary refactoring for #14335 (supporting plugins in cross-compilers). In many places the home-unit must be optional because there won't be one available in the plugin environment (we won't be compiling anything in this environment). Hence we replace "HomeUnit" with "Maybe HomeUnit" in a few places and we avoid the use of "hsc_home_unit" (which is partial) in some few others. - - - - - 29e03071 by Ben Gamari at 2021-11-20T05:36:18-05:00 rts: Ensure that markCAFs marks object code Previously `markCAFs` would only evacuate CAFs' indirectees. This would allow reachable object code to be unloaded by the linker as `evacuate` may never be called on the CAF itself, despite it being reachable via the `{dyn,revertible}_caf_list`s. To fix this we teach `markCAFs` to explicit call `markObjectCode`, ensuring that the linker is aware of objects reachable via the CAF lists. Fixes #20649. - - - - - b2933ea9 by Ben Gamari at 2021-11-20T05:36:54-05:00 gitlab-ci: Set HOME to plausible but still non-existent location We have been seeing numerous CI failures on aarch64/Darwin of the form: CI_COMMIT_BRANCH: CI_PROJECT_PATH: ghc/ghc error: creating directory '/nonexistent': Read-only file system Clearly *something* is attempting to create `$HOME`. A bit of sleuthing by @int-e found that the culprit is likely `nix`, although it's not clear why. For now we avoid the issue by setting `HOME` to a fresh directory in the working tree. - - - - - bc7e9f03 by Zubin Duggal at 2021-11-20T17:39:25+00:00 Use 'NonEmpty' for the fields in an 'HsProjection' (#20389) T12545 is very inconsistently affected by this change for some reason. There is a decrease in allocations on most configurations, but an increase on validate-x86_64-linux-deb9-unreg-hadrian. Accepting it as it seems unrelated to this patch. Metric Decrease: T12545 Metric Increase: T12545 - - - - - 742d8b60 by sheaf at 2021-11-20T18:13:23-05:00 Include "not more specific" info in overlap msg When instances overlap, we now include additional information about why we weren't able to select an instance: perhaps one instance overlapped another but was not strictly more specific, so we aren't able to directly choose it. Fixes #20542 - - - - - f748988b by Simon Peyton Jones at 2021-11-22T11:53:02-05:00 Better wrapper activation calculation As #20709 showed, GHC could prioritise a wrapper over a SPEC rule, which is potentially very bad. This patch fixes that problem. The fix is is described in Note [Wrapper activation], especially item 4, 4a, and Conclusion. For now, it has a temporary hack (replicating what was there before to make sure that wrappers inline no earlier than phase 2. But it should be temporary; see #19001. - - - - - f0bac29b by Simon Peyton Jones at 2021-11-22T11:53:02-05:00 Make INLINE/NOINLINE pragmas a bgi less constraining We can inline a bit earlier than the previous pragmas said. I think they dated from an era in which the InitialPhase did no inlining. I don't think this patch will have much effect, but it's a bit cleaner. - - - - - 68a3665a by Sylvain Henry at 2021-11-22T11:53:47-05:00 Hadrian: bump stackage LTS to 18.18 (GHC 8.10.7) - - - - - 680ef2c8 by Andreas Klebinger at 2021-11-23T01:07:29-05:00 CmmSink: Be more aggressive in removing no-op assignments. No-op assignments like R1 = R1 are not only wasteful. They can also inhibit other optimizations like inlining assignments that read from R1. We now check for assignments being a no-op before and after we simplify the RHS in Cmm sink which should eliminate most of these no-ops. - - - - - 1ed2aa90 by Andreas Klebinger at 2021-11-23T01:07:29-05:00 Don't include types in test output - - - - - 3ab3631f by Krzysztof Gogolewski at 2021-11-23T01:08:05-05:00 Add a warning for GADT match + NoMonoLocalBinds (#20485) Previously, it was an error to pattern match on a GADT without GADTs or TypeFamilies. This is now allowed. Instead, we check the flag MonoLocalBinds; if it is not enabled, we issue a warning, controlled by -Wgadt-mono-local-binds. Also fixes #20485: pattern synonyms are now checked too. - - - - - 9dcb2ad1 by Ben Gamari at 2021-11-23T16:09:39+00:00 gitlab-ci: Bump DOCKER_REV - - - - - 16690374 by nineonine at 2021-11-23T22:32:51-08:00 Combine STG free variable traversals (#17978) Previously we would traverse the STG AST twice looking for free variables. * Once in `annTopBindingsDeps` which considers top level and imported ids free. Its output is used to put bindings in dependency order. The pass happens in STG pipeline. * Once in `annTopBindingsFreeVars` which only considers non-top level ids free. Its output is used by the code generator to compute offsets into closures. This happens in Cmm (CodeGen) pipeline. Now these two traversal operations are merged into one - `FVs.depSortWithAnnotStgPgm`. The pass happens right at the end of STG pipeline. Some type signatures had to be updated due to slight shifts of StgPass boundaries (for example, top-level CodeGen handler now directly works with CodeGen flavoured Stg AST instead of Vanilla). Due to changed order of bindings, a few debugger type reconstruction bugs have resurfaced again (see tests break018, break021) - work item #18004 tracks this investigation. authors: simonpj, nineonine - - - - - 91c0a657 by Matthew Pickering at 2021-11-25T01:03:17-05:00 Correct retypechecking in --make mode Note [Hydrating Modules] ~~~~~~~~~~~~~~~~~~~~~~~~ What is hydrating a module? * There are two versions of a module, the ModIface is the on-disk version and the ModDetails is a fleshed-out in-memory version. * We can **hydrate** a ModIface in order to obtain a ModDetails. Hydration happens in three different places * When an interface file is initially loaded from disk, it has to be hydrated. * When a module is finished compiling, we hydrate the ModIface in order to generate the version of ModDetails which exists in memory (see Note) * When dealing with boot files and module loops (see Note [Rehydrating Modules]) Note [Rehydrating Modules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ If a module has a boot file then it is critical to rehydrate the modules on the path between the two. Suppose we have ("R" for "recursive"): ``` R.hs-boot: module R where data T g :: T -> T A.hs: module A( f, T, g ) where import {-# SOURCE #-} R data S = MkS T f :: T -> S = ...g... R.hs: module R where data T = T1 | T2 S g = ...f... ``` After compiling A.hs we'll have a TypeEnv in which the Id for `f` has a type type uses the AbstractTyCon T; and a TyCon for `S` that also mentions that same AbstractTyCon. (Abstract because it came from R.hs-boot; we know nothing about it.) When compiling R.hs, we build a TyCon for `T`. But that TyCon mentions `S`, and it currently has an AbstractTyCon for `T` inside it. But we want to build a fully cyclic structure, in which `S` refers to `T` and `T` refers to `S`. Solution: **rehydration**. *Before compiling `R.hs`*, rehydrate all the ModIfaces below it that depend on R.hs-boot. To rehydrate a ModIface, call `typecheckIface` to convert it to a ModDetails. It's just a de-serialisation step, no type inference, just lookups. Now `S` will be bound to a thunk that, when forced, will "see" the final binding for `T`; see [Tying the knot](https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/tying-the-knot). But note that this must be done *before* compiling R.hs. When compiling R.hs, the knot-tying stuff above will ensure that `f`'s unfolding mentions the `LocalId` for `g`. But when we finish R, we carefully ensure that all those `LocalIds` are turned into completed `GlobalIds`, replete with unfoldings etc. Alas, that will not apply to the occurrences of `g` in `f`'s unfolding. And if we leave matters like that, they will stay that way, and *all* subsequent modules that import A will see a crippled unfolding for `f`. Solution: rehydrate both R and A's ModIface together, right after completing R.hs. We only need rehydrate modules that are * Below R.hs * Above R.hs-boot There might be many unrelated modules (in the home package) that don't need to be rehydrated. This dark corner is the subject of #14092. Suppose we add to our example ``` X.hs module X where import A data XT = MkX T fx = ...g... ``` If in `--make` we compile R.hs-boot, then A.hs, then X.hs, we'll get a `ModDetails` for `X` that has an AbstractTyCon for `T` in the the argument type of `MkX`. So: * Either we should delay compiling X until after R has beeen compiled. * Or we should rehydrate X after compiling R -- because it transitively depends on R.hs-boot. Ticket #20200 has exposed some issues to do with the knot-tying logic in GHC.Make, in `--make` mode. this particular issue starts [here](https://gitlab.haskell.org/ghc/ghc/-/issues/20200#note_385758). The wiki page [Tying the knot](https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/tying-the-knot) is helpful. Also closely related are * #14092 * #14103 Fixes tickets #20200 #20561 - - - - - f0c5d8d3 by Matthew Pickering at 2021-11-25T01:03:17-05:00 Make T14075 more robust - - - - - 6907e9fa by Matthew Pickering at 2021-11-25T01:03:17-05:00 Revert "Convert lookupIdSubst panic back to a warning (#20200)" This reverts commit df1d808f26544cbb77d85773d672137c65fd3cc7. - - - - - baa8ffee by Greg Steuck at 2021-11-25T01:03:54-05:00 Use getExecutablePath in getBaseDir on OpenBSD While OpenBSD doesn't have a general mechanism for determining the path of the executing program image, it is reasonable to rely on argv[0] which happens as a fallback in getExecutablePath. With this change on top of T18173 we can get a bit close to fixing #18173. - - - - - e3c59191 by Christiaan Baaij at 2021-11-25T01:04:32-05:00 Ensure new Ct/evidence invariant The `ctev_pred` field of a `CtEvidence` is a just a cache for the type of the evidence. More precisely: * For Givens, `ctev_pred` = `varType ctev_evar` * For Wanteds, `ctev_pred` = `evDestType ctev_dest` This new invariant is needed because evidence can become part of a type, via `Castty ty kco`. - - - - - 3639ad8f by Christiaan Baaij at 2021-11-25T01:04:32-05:00 Compare types of recursive let-bindings in alpha-equivalence This commit fixes #20641 by checking the types of recursive let-bindings when performing alpha-equality. The `Eq (DeBruijn CoreExpr)` instance now also compares `BreakPoint`s similarly to `GHC.Core.Utils.eqTickish`, taking bound variables into account. In addition, the `Eq (DeBruijn Type)` instance now correctly compares the kinds of the types when one of them contains a Cast: the instance is modeled after `nonDetCmpTypeX`. - - - - - 7c65687e by CarrieMY at 2021-11-25T01:05:11-05:00 Enable UnboxedTuples in `genInst`, Fixes #20524 - - - - - e33412d0 by Krzysztof Gogolewski at 2021-11-25T01:05:46-05:00 Misc cleanup * Remove `getTag_RDR` (unused), `tidyKind` and `tidyOpenKind` (already available as `tidyType` and `tidyOpenType`) * Remove Note [Explicit Case Statement for Specificity]. Since 0a709dd9876e40 we require GHC 8.10 for bootstrapping. * Change the warning to `cmpAltCon` to a panic. This shouldn't happen. If it ever does, the code was wrong anyway: it shouldn't always return `LT`, but rather `LT` in one case and `GT` in the other case. * Rename `verifyLinearConstructors` to `verifyLinearFields` * Fix `Note [Local record selectors]` which was not referenced * Remove vestiges of `type +v` * Minor fixes to StaticPointers documentation, part of #15603 - - - - - bb71f7f1 by Greg Steuck at 2021-11-25T01:06:25-05:00 Reorder `sed` arguments to work with BSD sed The order was swapped in 490e8c750ea23ce8e2b7309e0d514b7d27f231bb causing the build on OpenBSD to fail with: `sed: 1: "mk/config.h": invalid command code m` - - - - - c18a51f0 by John Ericson at 2021-11-25T01:06:25-05:00 Apply 1 suggestion(s) to 1 file(s) - - - - - d530c46c by sheaf at 2021-11-25T01:07:04-05:00 Add Data.Bits changes to base 4.16 changelog Several additions since 4.15 had not been recorded in the changelog: - newtypes And, Ior, Xor and Iff, - oneBits - symbolic synonyms `.^.`, `.>>.`, `!>>.`, `.<<.` and `!<<.`. Fixes #20608. - - - - - 4d34bf15 by Matthew Pickering at 2021-11-25T01:07:40-05:00 Don't use implicit lifting when deriving Lift It isn't much more complicated to be more precise when deriving Lift so we now generate ``` data Foo = Foo Int Bool instance Lift Foo where lift (Foo a b) = [| Foo $(lift a) $(lift b) |] liftTyped (Foo a b) = [|| Foo $$(lift a) $$(lift b) |] ``` This fixes #20688 which complained about using implicit lifting in the derived code. - - - - - 8961d632 by Greg Steuck at 2021-11-25T01:08:18-05:00 Disable warnings for unused goto labels Clang on OpenBSD aborts compilation with this diagnostics: ``` % "inplace/bin/ghc-stage1" -optc-Wno-error=unused-label -optc-Wall -optc-Werror -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Wno-aggregate-return -optc-fno-strict-aliasing -optc-fno-common -optc-Irts/dist-install/build/./autogen -optc-Irts/include/../dist-install/build/include -optc-Irts/include/. -optc-Irts/. -optc-DCOMPILING_RTS -optc-DFS_NAMESPACE=rts -optc-Wno-unknown-pragmas -optc-O2 -optc-fomit-frame-pointer -optc-g -optc-DRtsWay=\"rts_v\" -static -O0 -H64m -Wall -fllvm-fill-undef-with-garbage -Werror -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist-install/build -Irts/dist-install/build -irts/dist-install/build/./autogen -Irts/dist-install/build/./autogen -Irts/include/../dist-install/build/include -Irts/include/. -Irts/. -optP-DCOMPILING_RTS -optP-DFS_NAMESPACE=rts -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/linker/Elf.c -o rts/dist-install/build/linker/Elf.o rts/linker/Elf.c:2169:1: error: error: unused label 'dl_iterate_phdr_fail' [-Werror,-Wunused-label] | 2169 | dl_iterate_phdr_fail: | ^ dl_iterate_phdr_fail: ^~~~~~~~~~~~~~~~~~~~~ rts/linker/Elf.c:2172:1: error: error: unused label 'dlinfo_fail' [-Werror,-Wunused-label] | 2172 | dlinfo_fail: | ^ dlinfo_fail: ^~~~~~~~~~~~ 2 errors generated. ``` - - - - - 5428b8c6 by Zubin Duggal at 2021-11-25T01:08:54-05:00 testsuite: debounce title updates - - - - - 96b3899e by Ben Gamari at 2021-11-25T01:09:29-05:00 gitlab-ci: Add release jobs for Darwin targets As noted in #20707, the validate jobs which we previously used lacked profiling support. Also clean up some variable definitions. Fixes #20707. - - - - - 52cdc2fe by Pepe Iborra at 2021-11-25T05:00:43-05:00 Monoid instance for InstalledModuleEnv - - - - - 47f36440 by Pepe Iborra at 2021-11-25T05:00:43-05:00 Drop instance Semigroup ModuleEnv There is more than one possible Semigroup and it is not needed since plusModuleEnv can be used directly - - - - - b742475a by Pepe Iborra at 2021-11-25T05:00:43-05:00 drop instance Semigroup InstalledModuleEnv Instead, introduce plusInstalledModuleEnv - - - - - b24e8d91 by Roland Senn at 2021-11-25T05:01:21-05:00 GHCi Debugger - Improve RTTI When processing the heap, use also `APClosures` to create additional type constraints. This adds more equations and therefore improves the unification process to infer the correct type of values at breakpoints. (Fix the `incr` part of #19559) - - - - - cf5279ed by Gergo ERDI at 2021-11-25T05:01:59-05:00 Use `simplify` in non-optimizing build pipeline (#20500) - - - - - c9cead1f by Gergo ERDI at 2021-11-25T05:01:59-05:00 Add specific optimization flag for fast PAP calls (#6084, #20500) - - - - - be0a9470 by Gergo ERDI at 2021-11-25T05:01:59-05:00 Add specific optimization flag for Cmm control flow analysis (#20500) - - - - - b52a9a3f by Gergo ERDI at 2021-11-25T05:01:59-05:00 Add `llvmOptLevel` to `DynFlags` (#20500) - - - - - f27a63fe by sheaf at 2021-11-25T05:02:39-05:00 Allow boring class declarations in hs-boot files There are two different ways of declaring a class in an hs-boot file: - a full declaration, where everything is written as it is in the .hs file, - an abstract declaration, where class methods and superclasses are left out. However, a declaration with no methods and a trivial superclass, such as: class () => C a was erroneously considered to be an abstract declaration, because the superclass is trivial. This is remedied by a one line fix in GHC.Tc.TyCl.tcClassDecl1. This patch also further clarifies the documentation around class declarations in hs-boot files. Fixes #20661, #20588. - - - - - cafb1f99 by Ben Gamari at 2021-11-25T05:03:15-05:00 compiler: Mark GHC.Prelude as Haddock no-home This significantly improves Haddock documentation generated by nix. - - - - - bd92c9b2 by Sebastian Graf at 2021-11-25T05:03:51-05:00 hadrian: Add `collect_stats` flavour transformer This is useful for later consumption with https://gitlab.haskell.org/bgamari/ghc-utils/-/blob/master/ghc_timings.py - - - - - 774fc4d6 by Ilias Tsitsimpis at 2021-11-25T08:34:54-05:00 Link against libatomic for 64-bit atomic operations Some platforms (e.g., armel) require linking against libatomic for 64-bit atomic operations. Fixes #20549 - - - - - 20101d9c by Greg Steuck at 2021-11-25T08:35:31-05:00 Permit multiple values in config_args for validate The whitespace expansion should be permitted to pass multiple arguments to configure. - - - - - e2c48b98 by Greg Steuck at 2021-11-25T08:36:09-05:00 Kill a use of %n format specifier This format has been used as a security exploit vector for decades now. Some operating systems (OpenBSD, Android, MSVC). It is targeted for removal in C2X standard: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2834.htm This requires extending the debug message function to return the number of bytes written (like printf(3)), to permit %n format specifier in one in one invocation of statsPrintf() in report_summary(). Implemented by Matthias Kilian (kili<AT>outback.escape.de) - - - - - ff0c45f3 by Bodigrim at 2021-11-26T16:01:09-05:00 Rename Data.ByteArray to Data.Array.ByteArray + add Trustworthy - - - - - 9907d540 by Bodigrim at 2021-11-26T16:01:09-05:00 Rename Data.Array.ByteArray -> Data.Array.Byte - - - - - 0c8e1b4d by Kai Prott at 2021-11-26T16:01:47-05:00 Improve error message for mis-typed plugins #20671 Previously, when a plugin could not be loaded because it was incorrectly typed, the error message only printed the expected but not the actual type. This commit augments the error message such that both types are printed and the corresponding module is printed as well. - - - - - 51bcb986 by Kai Prott at 2021-11-26T16:01:47-05:00 Remove duplicate import - - - - - 1830eea7 by Kai Prott at 2021-11-26T16:01:47-05:00 Simplify printQualification - - - - - 69e62032 by Kai Prott at 2021-11-26T16:01:47-05:00 Fix plugin type to GHC.Plugins.Plugin - - - - - 0a6776a3 by Kai Prott at 2021-11-26T16:01:47-05:00 Adapt plugin test case - - - - - 7e18b304 by Kai Prott at 2021-11-26T16:01:47-05:00 Reflect type change in the haddock comment - - - - - 02372be1 by Matthew Pickering at 2021-11-26T16:02:23-05:00 Allow keywords which can be used as variables to be used with OverloadedDotSyntax There are quite a few keywords which are allowed to be used as variables. Such as "as", "dependency" etc. These weren't accepted by OverloadedDotSyntax. The fix is pretty simple, use the varid production rather than raw VARID. Fixes #20723 - - - - - 13ef345c by John Ericson at 2021-11-27T19:41:11+00:00 Factor our `FP_CAPITALIZE_YES_NO` This deduplicates converting from yes/no to YES/NO in the configure scripts while also making it safer. - - - - - 88481c94 by John Ericson at 2021-11-27T19:46:16+00:00 Fix top-level configure script so --disable-foo works - - - - - f67060c6 by John Ericson at 2021-11-27T19:47:09+00:00 Make ambient MinGW support a proper settings Get rid of `USE_INPLACE_MINGW_TOOLCHAIN` and use a settings file entry instead. The CPP setting was originally introduced in f065b6b012. - - - - - 1dc0d7af by Ben Gamari at 2021-11-29T11:02:43-05:00 linker: Introduce linker_verbose debug output This splits the -Dl RTS debug output into two distinct flags: * `+RTS -Dl` shows errors and debug output which scales with at most O(# objects) * `+RTS -DL` shows debug output which scales with O(# symbols)t - - - - - 7ea665bf by Krzysztof Gogolewski at 2021-11-29T11:03:19-05:00 TTG: replace Void/NoExtCon with DataConCantHappen There were two ways to indicate that a TTG constructor is unused in a phase: `NoExtCon` and `Void`. This unifies the code, and uses the name 'DataConCantHappen', following the discussion at MR 7041. Updates haddock submodule - - - - - 14e9cab6 by Sylvain Henry at 2021-11-29T11:04:03-05:00 Use Monoid in hptSomeThingsBelowUs It seems to have a moderate but good impact on perf tests in CI. In particular: MultiLayerModules(normal) ghc/alloc 3125771138.7 3065532240.0 -1.9% So it's likely that huge projects will benefit from this. - - - - - 22bbf449 by Anton-Latukha at 2021-11-29T20:03:52+00:00 docs/users_guide/bugs.rst: Rewording It is either "slightly" || "significantly". If it is "bogus" - then no quotes around "optimization" & overall using word "bogus" or use quotes in that way in documentation is... Instead, something like "hack" or "heuristic" can be used there. - - - - - 9345bfed by Mitchell Rosen at 2021-11-30T01:32:22-05:00 Fix caluclation of nonmoving GC elapsed time Fixes #20751 - - - - - c7613493 by PHO at 2021-12-01T03:07:32-05:00 rts/ProfHeap.c: Use setlocale() on platforms where uselocale() is not available Not all platforms have per-thread locales. NetBSD doesn't have uselocale() in particular. Using setlocale() is of course not a safe thing to do, but it would be better than no GHC at all. - - - - - 4acfa0db by Ben Gamari at 2021-12-01T03:08:07-05:00 rts: Refactor SRT representation selection The goal here is to make the SRT selection logic a bit clearer and allow configurations which we currently don't support (e.g. using a full word in the info table even when TNTC is used). - - - - - 87bd9a67 by Ben Gamari at 2021-12-01T03:08:07-05:00 gitlab-ci: Introduce no_tntc job A manual job for testing the non-tables-next-to-code configuration. - - - - - 7acb945d by Carrie Xu at 2021-12-01T03:08:46-05:00 Dump non-module specific info to file #20316 - Change the dumpPrefix to FilePath, and default to non-module - Add dot to seperate dump-file-prefix and suffix - Modify user guide to introduce how dump files are named - This commit does not affect Ghci dump file naming. See also #17500 - - - - - 7bdca2ba by Ben Gamari at 2021-12-01T03:09:21-05:00 rts/RtsSymbols: Provide a proper prototype for environ Previously we relied on Sym_NeedsProto, but this gave the symbol a type which conflicts with the definition that may be provided by unistd.h. Fixes #20577. - - - - - 91d1a773 by Ben Gamari at 2021-12-01T03:09:21-05:00 hadrian: Don't pass empty paths via -I Previously we could in some cases add empty paths to `cc`'s include file search path. See #20578. - - - - - d8d57729 by Ben Gamari at 2021-12-01T03:09:21-05:00 ghc-cabal: Manually specify -XHaskell2010 Otherwise we end up with issues like #19631 when bootstrapping using GHC 9.2 and above. Fixes #19631. - - - - - 1c0c140a by Ben Gamari at 2021-12-01T03:09:21-05:00 ghc-compact: Update cabal file Improve documentation, bump bounds and cabal-version. - - - - - 322b6b45 by Ben Gamari at 2021-12-01T03:09:21-05:00 hadrian: Document fully_static flavour transformer - - - - - 4c434c9e by Ben Gamari at 2021-12-01T03:09:21-05:00 user-guide: Fix :since: of -XCApiFFI Closes #20504. - - - - - 0833ad55 by Matthew Pickering at 2021-12-01T03:09:58-05:00 Add failing test for #20674 - - - - - c2cb5e9a by Ben Gamari at 2021-12-01T03:10:34-05:00 testsuite: Print geometric mean of stat metrics As suggested in #20733. - - - - - 59b27945 by Ben Gamari at 2021-12-01T03:11:09-05:00 users-guide: Describe requirements of DWARF unwinding As requested in #20702 - - - - - c2f6cbef by Matthew Pickering at 2021-12-01T03:11:45-05:00 Fix several quoting issues in testsuite This fixes the ./validate script on my machine. I also took the step to add some linters which would catch problems like these in future. Fixes #20506 - - - - - bffd4074 by John Ericson at 2021-12-01T03:12:21-05:00 rts.cabal.in: Move `extra-source-files` so it is valid - - - - - 86c14db5 by John Ericson at 2021-12-01T03:12:21-05:00 Switch RTS cabal file / package conf to use Rts.h not Stg.h When we give cabal a configure script, it seems to begin checking whether or not Stg.h is valid, and then gets tripped up on all the register stuff which evidentally requires obscure command line flags to go. We can side-step this by making the test header Rts.h instead, which is more normal. I was a bit sketched out making this change, as I don't know why the Cabal library would suddenly beging checking the header. But I did confirm even without my RTS configure script the header doesn't compile stand-alone, and also the Stg.h is a probably-arbitrary choice since it dates all the way back to 2002 in 2cc5b907318f97e19b28b2ad8ed9ff8c1f401dcc. - - - - - defd8d54 by John Ericson at 2021-12-01T03:12:21-05:00 Avoid raw `echo` in `FPTOOLS_SET_PLATFORM_VARS` This ensures quiet configuring works. - - - - - b53f1227 by John Ericson at 2021-12-01T03:12:21-05:00 Factor our `$dir_$distdir_PKGDATA` make variable This makes a few things cleaner. - - - - - f124f2a0 by Ben Gamari at 2021-12-01T03:12:56-05:00 rts: Annotate benign race in pthread ticker's exit test Previously TSAN would report spurious data races due to the unsynchronized access of `exited`. I would have thought that using a relaxed load on `exited` would be enough to convince TSAN that the race was intentional, but apparently not. Closes #20690. - - - - - d3c7f9be by Viktor Dukhovni at 2021-12-01T03:13:34-05:00 Use POSIX shell syntax to redirect stdout/err FreeBSD (and likely NetBSD) /bin/sh does not support '>& word' to redirect stdout + stderr. (Also the preferred syntax in bash would be '&> word' to avoid surprises when `word` is "-" or a number). Resolves: #20760 - - - - - 1724ac37 by Ben Gamari at 2021-12-02T18:13:30-05:00 nativeGen/x86: Don't encode large shift offsets Handle the case of a shift larger than the width of the shifted value. This is necessary since x86 applies a mask of 0x1f to the shift amount, meaning that, e.g., `shr 47, $eax` will actually shift by 47 & 0x1f == 15. See #20626. (cherry picked from commit 31370f1afe1e2f071b3569fb5ed4a115096127ca) - - - - - 5b950a7f by Ben Gamari at 2021-12-02T18:13:30-05:00 cmm: narrow when folding signed quotients Previously the constant-folding behavior for MO_S_Quot and MO_S_Rem failed to narrow its arguments, meaning that a program like: %zx64(%quot(%lobits8(0x00e1::bits16), 3::bits8)) would be miscompiled. Specifically, this program should reduce as %lobits8(0x00e1::bits16) == -31 %quot(%lobits8(0x00e1::bits16), 3::bits8) == -10 %zx64(%quot(%lobits8(0x00e1::bits16), 3::bits8)) == 246 However, with this bug the `%lobits8(0x00e1::bits16)` would instead be treated as `+31`, resulting in the incorrect result of `75`. (cherry picked from commit 94e197e3dbb9a48991eb90a03b51ea13d39ba4cc) - - - - - 78b78ac4 by Ben Gamari at 2021-12-02T18:13:30-05:00 ncg/aarch64: Don't sign extend loads Previously we would emit the sign-extending LDS[HB] instructions for sub-word loads. However, this is wrong, as noted in #20638. - - - - - 35bbc251 by Ben Gamari at 2021-12-02T18:13:30-05:00 cmm: Disallow shifts larger than shiftee Previously primops.txt.pp stipulated that the word-size shift primops were only defined for shift offsets in [0, word_size). However, there was no further guidance for the definition of Cmm's sub-word size shift MachOps. Here we fix this by explicitly disallowing (checked in many cases by CmmLint) shift operations where the shift offset is larger than the shiftee. This is consistent with LLVM's shift operations, avoiding the miscompilation noted in #20637. - - - - - 2f6565cf by Ben Gamari at 2021-12-02T18:13:30-05:00 testsuite: Add testcases for various machop issues There were found by the test-primops testsuite. - - - - - 7094f4fa by Ben Gamari at 2021-12-02T18:13:30-05:00 nativeGen/aarch64: Don't rely on register width to determine amode We might be loading, e.g., a 16- or 8-bit value, in which case the register width is not reflective of the loaded element size. - - - - - 9c65197e by Ben Gamari at 2021-12-02T18:13:30-05:00 cmm/opt: Fold away shifts larger than shiftee width This is necessary for lint-correctness since we no longer allow such shifts in Cmm. - - - - - adc7f108 by Ben Gamari at 2021-12-02T18:13:30-05:00 nativeGen/aarch64: Fix handling of subword values Here we rework the handling of sub-word operations in the AArch64 backend, fixing a number of bugs and inconsistencies. In short, we now impose the invariant that all subword values are represented in registers in zero-extended form. Signed arithmetic operations are then responsible for sign-extending as necessary. Possible future work: * Use `CMP`s extended register form to avoid burning an instruction in sign-extending the second operand. * Track sign-extension state of registers to elide redundant sign extensions in blocks with frequent sub-word signed arithmetic. - - - - - e19e9e71 by Ben Gamari at 2021-12-02T18:13:31-05:00 CmmToC: Fix width of shift operations Under C's implicit widening rules, the result of an operation like (a >> b) where a::Word8 and b::Word will have type Word, yet we want Word. - - - - - ebaf7333 by Ben Gamari at 2021-12-02T18:13:31-05:00 CmmToC: Zero-extend sub-word size results As noted in Note [Zero-extending sub-word signed results] we must explicitly zero-extend the results of sub-word-sized signed operations. - - - - - 0aeaa8f3 by Ben Gamari at 2021-12-02T18:13:31-05:00 CmmToC: Always cast arguments as unsigned As noted in Note [When in doubt, cast arguments as unsigned], we must ensure that arguments have the correct signedness since some operations (e.g. `%`) have different semantics depending upon signedness. - - - - - e98dad1b by Ben Gamari at 2021-12-02T18:13:31-05:00 CmmToC: Cast possibly-signed results as unsigned C11 rule 6.3.1.1 dictates that all small integers used in expressions be implicitly converted to `signed int`. However, Cmm semantics require that the width of the operands be preserved with zero-extension semantics. For this reason we must recast sub-word arithmetic results as unsigned. - - - - - 44c08863 by Ben Gamari at 2021-12-02T18:13:31-05:00 testsuite: Specify expected word-size of machop tests These generally expect a particular word size. - - - - - fab2579e by Ben Gamari at 2021-12-02T18:14:06-05:00 hadrian: Don't rely on realpath in bindist Makefile As noted in #19963, `realpath` is not specified by POSIX and therefore cannot be assumed to be available. Here we provide a POSIX shell implementation of `realpath`, due to Julian Ospald and others. Closes #19963. - - - - - 99eb54bd by Kamil Dworakowski at 2021-12-02T21:45:10-05:00 Make openFile more tolerant of async excs (#18832) - - - - - 0e274c39 by nineonine at 2021-12-02T21:45:49-05:00 Require all dirty_MUT_VAR callers to do explicit stg_MUT_VAR_CLEAN_info comparison (#20088) - - - - - 81082cf4 by Matthew Pickering at 2021-12-03T10:12:04-05:00 Revert "Data.List specialization to []" This reverts commit bddecda1a4c96da21e3f5211743ce5e4c78793a2. This implements the first step in the plan formulated in #20025 to improve the communication and migration strategy for the proposed changes to Data.List. Requires changing the haddock submodule to update the test output. - - - - - a9e035a4 by sheaf at 2021-12-03T10:12:42-05:00 Test-suite: fix geometric mean of empty list The geometric mean computation panicked when it was given an empty list, which happens when there are no baselines. Instead, we should simply return 1. - - - - - d72720f9 by Matthew Pickering at 2021-12-06T16:27:35+00:00 Add section to the user guide about OS memory usage - - - - - 0fe45d43 by Viktor Dukhovni at 2021-12-07T06:27:12-05:00 List-monomorphic `foldr'` While a *strict* (i.e. constant space) right-fold on lists is not possible, the default `foldr'` is optimised for structures like `Seq`, that support efficient access to the right-most elements. The original default implementation seems to have a better constant factor for lists, so we add a monomorphic implementation in GHC.List. Should this be re-exported from `Data.List`? That would be a user-visible change if both `Data.Foldable` and `Data.List` are imported unqualified... - - - - - 7d2283b9 by Ben Gamari at 2021-12-07T06:27:47-05:00 compiler: Eliminate accidental loop in GHC.SysTools.BaseDir As noted in #20757, `GHC.SysTools.BaseDir.findToolDir` previously contained an loop, which would be triggered in the case that the search failed. Closes #20757. - - - - - 8044e232 by Viktor Dukhovni at 2021-12-07T06:28:23-05:00 More specific documentation of foldr' caveats - - - - - d932e2d6 by Viktor Dukhovni at 2021-12-07T06:28:23-05:00 Use italic big-O notation in Data.Foldable - - - - - 57c9c0a2 by Viktor Dukhovni at 2021-12-07T06:28:23-05:00 Fix user-guide typo - - - - - 324772bb by Ben Gamari at 2021-12-07T06:28:59-05:00 rts/Linker: Ensure that mmap_32bit_base is updated after mapping The amount of duplicated code in `mmapForLinker` hid the fact that some codepaths would fail to update `mmap_32bit_base` (specifically, on platforms like OpenBSD where `MAP_32BIT` is not supported). Refactor the function to make the implementation more obviously correct. Closes #20734. - - - - - 5dbdf878 by Ben Gamari at 2021-12-07T06:28:59-05:00 rts: +RTS -DL should imply +RTS -Dl Otherwise the user may be surprised by the missing context provided by the latter. - - - - - 7eb56064 by sheaf at 2021-12-07T06:29:38-05:00 More permissive parsing of higher-rank type IPs The parser now accepts implicit parameters with higher-rank types, such as `foo :: (?ip :: forall a. a -> a) => ...` Before this patch, we instead insisted on parentheses like so: `foo :: (?ip :: (forall a. a -> a)) => ...` The rest of the logic surrounding implicit parameters is unchanged; in particular, even with ImpredicativeTypes, this idiom is not likely to be very useful. Fixes #20654 - - - - - 427f9c12 by sheaf at 2021-12-07T13:32:55-05:00 Re-export GHC.Types from GHC.Exts Several times in the past, it has happened that things from GHC.Types were not re-exported from GHC.Exts, forcing users to import either GHC.Types or GHC.Prim, which are subject to internal change without notice. We now re-export GHC.Types from GHC.Exts, which should avoid this happening again in the future. In particular, we now re-export `Multiplicity` and `MultMul`, which we didn't before. Fixes #20695 - - - - - 483bd04d by Sebastian Graf at 2021-12-07T13:33:31-05:00 Explicit Data.List import list in check-ppr (#20789) `check-ppr` features an import of Data.List without an import list. After 81082cf4, this breaks the local validate flavour because of the compat warning and `-Werror`. So fix that. Fixes #20789. - - - - - cc2bf8e9 by Norman Ramsey at 2021-12-07T17:34:51-05:00 generalize GHC.Cmm.Dataflow to work over any node type See #20725. The commit includes source-code changes and a test case. - - - - - 4c6985cc by Sylvain Henry at 2021-12-07T17:35:30-05:00 Perf: remove an indirection when fetching the unique mask Slight decrease but still noticeable on CI: Baseline Test Metric value New value Change ----------------------------------------------------------------------------- ManyAlternatives(normal) ghc/alloc 747607676.0 747458936.0 -0.0% ManyConstructors(normal) ghc/alloc 4003722296.0 4003530032.0 -0.0% MultiLayerModules(normal) ghc/alloc 3064539560.0 3063984552.0 -0.0% MultiLayerModulesRecomp(normal) ghc/alloc 894700016.0 894700624.0 +0.0% PmSeriesG(normal) ghc/alloc 48410952.0 48262496.0 -0.3% PmSeriesS(normal) ghc/alloc 61561848.0 61415768.0 -0.2% PmSeriesT(normal) ghc/alloc 90975784.0 90829360.0 -0.2% PmSeriesV(normal) ghc/alloc 60405424.0 60259008.0 -0.2% T10421(normal) ghc/alloc 113275928.0 113137168.0 -0.1% T10421a(normal) ghc/alloc 79195676.0 79050112.0 -0.2% T10547(normal) ghc/alloc 28720176.0 28710008.0 -0.0% T10858(normal) ghc/alloc 180992412.0 180857400.0 -0.1% T11195(normal) ghc/alloc 283452220.0 283293832.0 -0.1% T11276(normal) ghc/alloc 137882128.0 137745840.0 -0.1% T11303b(normal) ghc/alloc 44453956.0 44309184.0 -0.3% T11374(normal) ghc/alloc 248118668.0 247979880.0 -0.1% T11545(normal) ghc/alloc 971994728.0 971852696.0 -0.0% T11822(normal) ghc/alloc 131544864.0 131399024.0 -0.1% T12150(optasm) ghc/alloc 79336468.0 79191888.0 -0.2% T12227(normal) ghc/alloc 495064180.0 494943040.0 -0.0% T12234(optasm) ghc/alloc 57198468.0 57053568.0 -0.3% T12425(optasm) ghc/alloc 90928696.0 90793440.0 -0.1% T12545(normal) ghc/alloc 1695417772.0 1695275744.0 -0.0% T12707(normal) ghc/alloc 956258984.0 956138864.0 -0.0% T13035(normal) ghc/alloc 102279484.0 102132616.0 -0.1% T13056(optasm) ghc/alloc 367196556.0 367066408.0 -0.0% T13253(normal) ghc/alloc 334365844.0 334255264.0 -0.0% T13253-spj(normal) ghc/alloc 125474884.0 125328672.0 -0.1% T13379(normal) ghc/alloc 359185604.0 359036960.0 -0.0% T13701(normal) ghc/alloc 2403026480.0 2402677464.0 -0.0% T13719(normal) ghc/alloc 4192234752.0 4192039448.0 -0.0% T14052(ghci) ghc/alloc 2745868552.0 2747706176.0 +0.1% T14052Type(ghci) ghc/alloc 7335937964.0 7336283280.0 +0.0% T14683(normal) ghc/alloc 2992557736.0 2992436872.0 -0.0% T14697(normal) ghc/alloc 363391248.0 363222920.0 -0.0% T15164(normal) ghc/alloc 1292578008.0 1292434240.0 -0.0% T15304(normal) ghc/alloc 1279603472.0 1279465944.0 -0.0% T15630(normal) ghc/alloc 161707776.0 161602632.0 -0.1% T16190(normal) ghc/alloc 276904644.0 276555264.0 -0.1% T16577(normal) ghc/alloc 7573033016.0 7572982752.0 -0.0% T16875(normal) ghc/alloc 34937980.0 34796592.0 -0.4% T17096(normal) ghc/alloc 287436348.0 287299368.0 -0.0% T17516(normal) ghc/alloc 1714727484.0 1714617664.0 -0.0% T17836(normal) ghc/alloc 1091095748.0 1090958168.0 -0.0% T17836b(normal) ghc/alloc 52467912.0 52321296.0 -0.3% T17977(normal) ghc/alloc 44971660.0 44826480.0 -0.3% T17977b(normal) ghc/alloc 40941128.0 40793160.0 -0.4% T18140(normal) ghc/alloc 82363124.0 82213056.0 -0.2% T18223(normal) ghc/alloc 1168448128.0 1168333624.0 -0.0% T18282(normal) ghc/alloc 131577844.0 131440400.0 -0.1% T18304(normal) ghc/alloc 86988664.0 86844432.0 -0.2% T18478(normal) ghc/alloc 742992400.0 742871136.0 -0.0% T18698a(normal) ghc/alloc 337654412.0 337526792.0 -0.0% T18698b(normal) ghc/alloc 398840772.0 398716472.0 -0.0% T18923(normal) ghc/alloc 68964992.0 68818768.0 -0.2% T1969(normal) ghc/alloc 764285884.0 764156168.0 -0.0% T19695(normal) ghc/alloc 1395577984.0 1395552552.0 -0.0% T20049(normal) ghc/alloc 89159032.0 89012952.0 -0.2% T3064(normal) ghc/alloc 191194856.0 191051816.0 -0.1% T3294(normal) ghc/alloc 1604762016.0 1604656488.0 -0.0% T4801(normal) ghc/alloc 296829368.0 296687824.0 -0.0% T5030(normal) ghc/alloc 364720540.0 364580152.0 -0.0% T5321FD(normal) ghc/alloc 271090004.0 270950824.0 -0.1% T5321Fun(normal) ghc/alloc 301244320.0 301102960.0 -0.0% T5631(normal) ghc/alloc 576154548.0 576022904.0 -0.0% T5642(normal) ghc/alloc 471105876.0 470967552.0 -0.0% T5837(normal) ghc/alloc 36328620.0 36186720.0 -0.4% T6048(optasm) ghc/alloc 103125988.0 102981024.0 -0.1% T783(normal) ghc/alloc 386945556.0 386795984.0 -0.0% T9020(optasm) ghc/alloc 247835012.0 247696704.0 -0.1% T9198(normal) ghc/alloc 47556208.0 47413784.0 -0.3% T9233(normal) ghc/alloc 682210596.0 682069960.0 -0.0% T9630(normal) ghc/alloc 1429689648.0 1429581168.0 -0.0% T9675(optasm) ghc/alloc 431092812.0 430943192.0 -0.0% T9872a(normal) ghc/alloc 1705052592.0 1705042064.0 -0.0% T9872b(normal) ghc/alloc 2180406760.0 2180395784.0 -0.0% T9872c(normal) ghc/alloc 1760508464.0 1760497936.0 -0.0% T9872d(normal) ghc/alloc 501517968.0 501309464.0 -0.0% T9961(normal) ghc/alloc 354037204.0 353891576.0 -0.0% TcPlugin_RewritePerf(normal) ghc/alloc 2381708520.0 2381550824.0 -0.0% WWRec(normal) ghc/alloc 589553520.0 589407216.0 -0.0% hard_hole_fits(normal) ghc/alloc 492122188.0 492470648.0 +0.1% hie002(normal) ghc/alloc 9336434800.0 9336443496.0 +0.0% parsing001(normal) ghc/alloc 537680944.0 537659824.0 -0.0% geo. mean -0.1% - - - - - aafa5079 by Bodigrim at 2021-12-09T04:26:35-05:00 Bump bytestring submodule to 0.11.2.0 Both tests import `Data.ByteString`, so the change in allocations is more or less expected. Metric Increase: T19695 T9630 - - - - - 803eefb1 by Matthew Pickering at 2021-12-09T04:27:11-05:00 package imports: Take into account package visibility when renaming In 806e49ae the package imports refactoring code was modified to rename package imports. There was a small oversight which meant the code didn't account for module visibility. This patch fixes that oversight. In general the "lookupPackageName" function is unsafe to use as it doesn't account for package visiblity/thinning/renaming etc, there is just one use in the compiler which would be good to audit. Fixes #20779 - - - - - 52bbea0f by Viktor Dukhovni at 2021-12-09T04:27:48-05:00 Fix typo and outdated link in Data.Foldable Amazing nobody had reported the "Foldabla" typo. :-( The Traversable docs got overhauled, leaving a stale link in Foldable to a section that got replaced. Gave the new section an anchor and updated the link. - - - - - a722859f by Viktor Dukhovni at 2021-12-09T04:27:48-05:00 A few more typos - - - - - d6177cb5 by Viktor Dukhovni at 2021-12-09T04:27:48-05:00 Drop O(n^2) warning on concat - - - - - 9f988525 by David Feuer at 2021-12-09T13:49:47+00:00 Improve mtimesDefault * Make 'mtimesDefault' use 'stimes' for the underlying monoid rather than the default 'stimes'. * Explain in the documentation why one might use `mtimesDefault`. - - - - - 2fca50d4 by Gergo ERDI at 2021-12-09T22:14:24-05:00 Use same optimization pipeline regardless of `optLevel` (#20500) - - - - - 6d031922 by Gergo ERDI at 2021-12-09T22:14:24-05:00 Add `Opt_CoreConstantFolding` to turn on constant folding (#20500) Previously, `-O1` and `-O2`, by way of their effect on the compilation pipeline, they implicitly turned on constant folding - - - - - b6f7d145 by Gergo ERDI at 2021-12-09T22:14:24-05:00 Remove `optLevel` from `DynFlags` (closes #20500) - - - - - 724df9c3 by Ryan Scott at 2021-12-09T22:15:00-05:00 Hadrian: Allow building with GHC 9.2 A separate issue is the fact that many of `hadrian`'s modules produce `-Wincomplete-uni-patterns` warnings under 9.2, but that is probably best left to a separate patch. - - - - - 80a25502 by Matthew Pickering at 2021-12-09T22:15:35-05:00 Use file hash cache when hashing object file dependencies This fixes the immediate problem that we hash the same file multiple different times which causes quite a noticeably performance regression. In the future we can probably do better than this by storing the implementation hash in the interface file rather than dependending on hashing the object file. Related to #20604 which notes some inefficiencies with the current recompilation logic. Closes #20790 ------------------------- Metric Decrease: T14052Type ------------------------- - - - - - f573cb16 by nineonine at 2021-12-10T06:16:41-05:00 rts: use allocation helpers from RtsUtils Just a tiny cleanup inspired by the following comment: https://gitlab.haskell.org/ghc/ghc/-/issues/19437#note_334271 I was just getting familiar with rts code base so I thought might as well do this. - - - - - 16eab39b by Matthew Pickering at 2021-12-10T06:17:16-05:00 Remove confusing haddock quotes in 'readInt' documentation As pointed out in #20776, placing quotes in this way linked to the 'Integral' type class which is nothing to do with 'readInt', the text should rather just be "integral", to suggest that the argument must be an integer. Closes #20776 - - - - - b4a55419 by Ben Gamari at 2021-12-10T06:17:52-05:00 docs: Drop old release notes Closes #20786 - - - - - 8d1f30e7 by Jakob Brünker at 2021-12-11T00:55:48-05:00 Add PromotedInfixT/PromotedUInfixT to TH Previously, it was not possible to refer to a data constructor using InfixT with a dynamically bound name (i.e. a name with NameFlavour `NameS` or `NameQ`) if a type constructor of the same name exists. This commit adds promoted counterparts to InfixT and UInfixT, analogously to how PromotedT is the promoted counterpart to ConT. Closes #20773 - - - - - 785859fa by Bodigrim at 2021-12-11T00:56:26-05:00 Bump text submodule to 2.0-rc2 - - - - - 352284de by Sylvain Henry at 2021-12-11T00:57:05-05:00 Perf: remove allocation in writeBlocks and fix comment (#14309) - - - - - 40a44f68 by Douglas Wilson at 2021-12-12T09:09:30-05:00 rts: correct stats when running with +RTS -qn1 Despite the documented care having been taken, several bugs are fixed here. When run with -qn1, when a SYNC_GC_PAR is requested we will have n_gc_threads == n_capabilities && n_gc_idle_threads == (n_gc_threads - 1) In this case we now: * Don't increment par_collections * Don't increment par_balanced_copied * Don't emit debug traces for idle threads * Take the fast path in scavenge_until_all_done, wakeup_gc_threads, and shutdown_gc_threads. Some ASSERTs have also been tightened. Fixes #19685 - - - - - 6b2947d2 by Matthew Pickering at 2021-12-12T09:10:06-05:00 iserv: Remove network dependent parts of libiserv As noted in #20794 the parts of libiserv and iserv-proxy depend on network, therefore are never built nor tested during CI. Due to this iserv-proxy had bitrotted due to the bound on bytestring being out of date. Given we don't test this code it seems undesirable to distribute it. Therefore, it's removed and an external maintainer can be responsible for testing it (via head.hackage if desired). Fixes #20794 - - - - - f04d1a49 by Ben Gamari at 2021-12-12T09:10:41-05:00 gitlab-ci: Bump fedora jobs to use Fedora 33 Annoyingly, this will require downstream changes in head.hackage, which depends upon the artifact produced by this job. Prompted by !6462. - - - - - 93783e6a by Andrey Mokhov at 2021-12-12T09:11:20-05:00 Drop --configure from Hadrian docs - - - - - 31bf380f by Oleg Grenrus at 2021-12-12T12:52:18-05:00 Use HasCallStack and error in GHC.List and .NonEmpty In addition to providing stack traces, the scary HasCallStack will hopefully make people think whether they want to use these functions, i.e. act as a documentation hint that something weird might happen. A single metric increased, which doesn't visibly use any method with `HasCallStack`. ------------------------- Metric Decrease: T9630 Metric Decrease: T19695 T9630 ------------------------- - - - - - 401ddd53 by Greg Steuck at 2021-12-12T12:52:56-05:00 Respect W^X in Linker.c:preloadObjectFile on OpenBSD This fixes -fexternal-interpreter for ghci. Fixes #20814. - - - - - c43ee6b8 by Andreas Klebinger at 2021-12-14T19:24:20+01:00 GHC.Utils.Misc.only: Add doc string. This function expects a singleton list as argument but only checks this in debug builds. I've added a docstring saying so. Fixes #20797 - - - - - 9ff54ea8 by Vaibhav Sagar at 2021-12-14T20:50:08-05:00 Data.Functor.Classes: fix Ord1 instance for Down - - - - - 8a2de3c2 by Tamar Christina at 2021-12-14T20:50:47-05:00 rts: update xxhash used by the linker's hashmap - - - - - 1c8d609a by alirezaghey at 2021-12-14T20:51:25-05:00 fix ambiguity in `const` documentation fixes #20412 - - - - - a5d8d47f by Joachim Breitner at 2021-12-14T20:52:00-05:00 Ghci environment: Do not remove shadowed ids Names defined earier but shadowed need to be kept around, e.g. for type signatures: ``` ghci> data T = T ghci> let t = T ghci> data T = T ghci> :t t t :: Ghci1.T ``` and indeed they can be used: ``` ghci> let t2 = Ghci1.T :: Ghci1.T ghci> :t t2 t2 :: Ghci1.T ``` However, previously this did not happen for ids (non-types), although they are still around under the qualified name internally: ``` ghci> let t = "other t" ghci> t' <interactive>:8:1: error: • Variable not in scope: t' • Perhaps you meant one of these: ‘Ghci2.t’ (imported from Ghci2), ‘t’ (line 7), ‘t2’ (line 5) ghci> Ghci2.t <interactive>:9:1: error: • GHC internal error: ‘Ghci2.t’ is not in scope during type checking, but it passed the renamer tcl_env of environment: [] • In the expression: Ghci2.t In an equation for ‘it’: it = Ghci2.t ``` This fixes the problem by simply removing the code that tries to remove shadowed ids from the environment. Now you can refer to shadowed ids using `Ghci2.t`, just like you can do for data and type constructors. This simplifies the code, makes terms and types more similar, and also fixes #20455. Now all names ever defined in GHCi are in `ic_tythings`, which is printed by `:show bindings`. But for that commands, it seems to be more ergonomic to only list those bindings that are not shadowed. Or, even if it is not more ergonomic, it’s the current behavour. So let's restore that by filtering in `icInScopeTTs`. Of course a single `TyThing` can be associated with many names. We keep it it in the bindings if _any_ of its names are still visible unqualifiedly. It's a judgement call. This commit also turns a rather old comment into a test files. The comment is is rather stale and things are better explained elsewhere. Fixes #925. Two test cases are regressing: T14052(ghci) ghc/alloc 2749444288.0 12192109912.0 +343.4% BAD T14052Type(ghci) ghc/alloc 7365784616.0 10767078344.0 +46.2% BAD This is not unexpected; the `ic_tythings list grows` a lot more if we don’t remove shadowed Ids. I tried to alleviate it a bit with earlier MRs, but couldn’t make up for it completely. Metric Increase: T14052 T14052Type - - - - - 7c2609d8 by Cheng Shao at 2021-12-14T20:52:37-05:00 base: fix clockid_t usage when it's a pointer type in C Closes #20607. - - - - - 55cb2aa7 by MichaWiedenmann1 at 2021-12-14T20:53:16-05:00 Fixes typo in documentation of the Semigroup instance of Equivalence - - - - - 82c39f4d by Ben Gamari at 2021-12-14T20:53:51-05:00 users-guide: Fix documentation for -shared flag This flag was previously called `--mk-dll`. It was renamed to `-shared` in b562cbe381d54e08dcafa11339e9a82e781ad557 but the documentation wasn't updated to match. - - - - - 4f654071 by Ben Gamari at 2021-12-14T20:53:51-05:00 compiler: Drop `Maybe ModLocation` from T_MergeForeign This field was entirely unused. - - - - - 71ecb55b by Ben Gamari at 2021-12-14T20:53:51-05:00 compiler: Use withFile instead of bracket A minor refactoring noticed by hlint. - - - - - 5686f47b by Ben Gamari at 2021-12-14T20:53:51-05:00 ghc-bin: Add --merge-objs mode This adds a new mode, `--merge-objs`, which can be used to produce merged GHCi library objects. As future work we will rip out the object-merging logic in Hadrian and Cabal and instead use this mode. Closes #20712. - - - - - 0198bb11 by Ben Gamari at 2021-12-14T20:54:27-05:00 libiserv: Rename Lib module to IServ As proposed in #20546. - - - - - ecaec722 by doyougnu at 2021-12-14T20:55:06-05:00 CmmToLlvm: Remove DynFlags, add LlvmCgConfig CodeOutput: LCGConfig, add handshake initLCGConfig Add two modules: GHC.CmmToLlvm.Config -- to hold the Llvm code gen config GHC.Driver.Config.CmmToLlvm -- for initialization, other utils CmmToLlvm: remove HasDynFlags, add LlvmConfig CmmToLlvm: add lcgContext to LCGConfig CmmToLlvm.Base: DynFlags --> LCGConfig Llvm: absorb LlvmOpts into LCGConfig CmmToLlvm.Ppr: swap DynFlags --> LCGConfig CmmToLlvm.CodeGen: swap DynFlags --> LCGConfig CmmToLlvm.CodeGen: swap DynFlags --> LCGConfig CmmToLlvm.Data: swap LlvmOpts --> LCGConfig CmmToLlvm: swap DynFlags --> LCGConfig CmmToLlvm: move LlvmVersion to CmmToLlvm.Config Additionally: - refactor Config and initConfig to hold LlvmVersion - push IO needed to get LlvmVersion to boundary between Cmm and LLvm code generation - remove redundant imports, this is much cleaner! CmmToLlvm.Config: store platformMisc_llvmTarget instead of all of platformMisc - - - - - 6b0fb9a0 by doyougnu at 2021-12-14T20:55:06-05:00 SysTools.Tasks Llvm.Types: remove redundant import Llvm.Types: remove redundant import SysTools.Tasks: remove redundant import - namely CmmToLlvm.Base - - - - - 80016022 by doyougnu at 2021-12-14T20:55:06-05:00 LLVM.CodeGen: use fast-string literals That is remove factorization of common strings and string building code for the LLVM code gen ops. Replace these with string literals to obey the FastString rewrite rule in GHC.Data.FastString and compute the string length at compile time - - - - - bc663f87 by doyougnu at 2021-12-14T20:55:06-05:00 CmmToLlvm.Config: strictify LlvmConfig field - - - - - 70f0aafe by doyougnu at 2021-12-14T20:55:06-05:00 CmmToLlvm: rename LCGConfig -> LlvmCgConfig CmmToLlvm: renamce lcgPlatform -> llvmCgPlatform CmmToLlvm: rename lcgContext -> llvmCgContext CmmToLlvm: rename lcgFillUndefWithGarbage CmmToLlvm: rename lcgSplitSections CmmToLlvm: lcgBmiVersion -> llvmCgBmiVersion CmmToLlvm: lcgLlvmVersion -> llvmCgLlvmVersion CmmToLlvm: lcgDoWarn -> llvmCgDoWarn CmmToLlvm: lcgLlvmConfig -> llvmCgLlvmConfig CmmToLlvm: llvmCgPlatformMisc --> llvmCgLlvmTarget - - - - - 34abbd81 by Greg Steuck at 2021-12-14T20:55:43-05:00 Add OpenBSD to llvm-targets This improves some tests that previously failed with: ghc: panic! (the 'impossible' happened) GHC version 9.3.20211211: Failed to lookup LLVM data layout Target: x86_64-unknown-openbsd Added the new generated lines to `llvm-targets` on an openbsd 7.0-current with clang 11.1.0. - - - - - 45bd6308 by Joachim Breitner at 2021-12-14T20:56:18-05:00 Test case from #19313 - - - - - f5a0b408 by Andrei Barbu at 2021-12-15T16:33:17-05:00 Plugin load order should follow the commandline order (fixes #17884) In the past the order was reversed because flags are consed onto a list. No particular behavior was documented. We now reverse the flags and document the behavior. - - - - - d13b9f20 by Cheng Shao at 2021-12-15T16:33:54-05:00 base: use `CUIntPtr` instead of `Ptr ()` as the autoconf detected Haskell type for C pointers When autoconf detects a C pointer type, we used to specify `Ptr ()` as the Haskell type. This doesn't work in some cases, e.g. in `wasi-libc`, `clockid_t` is a pointer type, but we expected `CClockId` to be an integral type, and `Ptr ()` lacks various integral type instances. - - - - - 89c1ffd6 by Cheng Shao at 2021-12-15T16:33:54-05:00 base: fix autoconf detection of C pointer types We used to attempt compiling `foo_t val; *val;` to determine if `foo_t` is a pointer type in C. This doesn't work if `foo_t` points to an incomplete type, and autoconf will detect `foo_t` as a floating point type in that case. Now we use `memset(val, 0, 0)` instead, and it works for incomplete types as well. - - - - - 6cea7311 by Cheng Shao at 2021-12-15T16:33:54-05:00 Add a note to base changelog - - - - - 3c3e5c03 by Ben Gamari at 2021-12-17T21:20:57-05:00 Regression test for renamer/typechecker performance (#20261) We use the parser generated by stack to ensure reproducibility - - - - - 5d5620bc by Krzysztof Gogolewski at 2021-12-17T21:21:32-05:00 Change isUnliftedTyCon to marshalablePrimTyCon (#20401) isUnliftedTyCon was used in three places: Ticky, Template Haskell and FFI checks. It was straightforward to remove it from Ticky and Template Haskell. It is now used in FFI only and renamed to marshalablePrimTyCon. Previously, it was fetching information from a field in PrimTyCon called is_unlifted. Instead, I've changed the code to compute liftedness based on the kind. isFFITy and legalFFITyCon are removed. They were only referred from an old comment that I removed. There were three functions to define a PrimTyCon, but the only difference was that they were setting is_unlifted to True or False. Everything is now done in mkPrimTyCon. I also added missing integer types in Ticky.hs, I think it was an oversight. Fixes #20401 - - - - - 9d77976d by Matthew Pickering at 2021-12-17T21:22:08-05:00 testsuite: Format metric results with comma separator As noted in #20763 the way the stats were printed was quite hard for a human to compare. Therefore we now insert the comma separator so that they are easier to compare at a glance. Before: ``` Baseline Test Metric value New value Change ----------------------------------------------------------------------------- Conversions(normal) run/alloc 107088.0 107088.0 +0.0% DeriveNull(normal) run/alloc 112050656.0 112050656.0 +0.0% InlineArrayAlloc(normal) run/alloc 1600040712.0 1600040712.0 +0.0% InlineByteArrayAlloc(normal) run/alloc 1440040712.0 1440040712.0 +0.0% InlineCloneArrayAlloc(normal) run/alloc 1600040872.0 1600040872.0 +0.0% MethSharing(normal) run/alloc 480097864.0 480097864.0 +0.0% T10359(normal) run/alloc 354344.0 354344.0 +0.0% ``` After ``` Baseline Test Metric value New value Change ---------------------------------------------------------------------------------- Conversions(normal) run/alloc 107,088 107,088 +0.0% DeriveNull(normal) run/alloc 112,050,656 112,050,656 +0.0% InlineArrayAlloc(normal) run/alloc 1,600,040,712 1,600,040,712 +0.0% InlineByteArrayAlloc(normal) run/alloc 1,440,040,712 1,440,040,712 +0.0% InlineCloneArrayAlloc(normal) run/alloc 1,600,040,872 1,600,040,872 +0.0% MethSharing(normal) run/alloc 480,097,864 480,097,864 +0.0% T10359(normal) run/alloc 354,344 354,344 +0.0% ``` Closes #20763 - - - - - 3f31bfe8 by Sylvain Henry at 2021-12-17T21:22:48-05:00 Perf: inline exprIsCheapX Allow specialization for the ok_app predicate. Perf improvements: Baseline Test Metric value New value Change ----------------------------------------------------------------------------- ManyAlternatives(normal) ghc/alloc 747317244.0 746444024.0 -0.1% ManyConstructors(normal) ghc/alloc 4005046448.0 4001548792.0 -0.1% MultiLayerModules(normal) ghc/alloc 3063361000.0 3063178472.0 -0.0% MultiLayerModulesRecomp(normal) ghc/alloc 894208428.0 894252496.0 +0.0% PmSeriesG(normal) ghc/alloc 48021692.0 47901592.0 -0.3% PmSeriesS(normal) ghc/alloc 61322504.0 61149008.0 -0.3% PmSeriesT(normal) ghc/alloc 90879364.0 90609048.0 -0.3% PmSeriesV(normal) ghc/alloc 60155376.0 59983632.0 -0.3% T10421(normal) ghc/alloc 112820720.0 112517208.0 -0.3% T10421a(normal) ghc/alloc 78783696.0 78557896.0 -0.3% T10547(normal) ghc/alloc 28331984.0 28354160.0 +0.1% T10858(normal) ghc/alloc 180715296.0 180226720.0 -0.3% T11195(normal) ghc/alloc 284139184.0 283981048.0 -0.1% T11276(normal) ghc/alloc 137830804.0 137688912.0 -0.1% T11303b(normal) ghc/alloc 44080856.0 43956152.0 -0.3% T11374(normal) ghc/alloc 249319644.0 249059288.0 -0.1% T11545(normal) ghc/alloc 971507488.0 971146136.0 -0.0% T11822(normal) ghc/alloc 131410208.0 131269664.0 -0.1% T12150(optasm) ghc/alloc 78866860.0 78762296.0 -0.1% T12227(normal) ghc/alloc 494467900.0 494138112.0 -0.1% T12234(optasm) ghc/alloc 56781044.0 56588256.0 -0.3% T12425(optasm) ghc/alloc 90462264.0 90240272.0 -0.2% T12545(normal) ghc/alloc 1694316588.0 1694128448.0 -0.0% T12707(normal) ghc/alloc 955665168.0 955005336.0 -0.1% T13035(normal) ghc/alloc 101875160.0 101713312.0 -0.2% T13056(optasm) ghc/alloc 366370168.0 365347632.0 -0.3% T13253(normal) ghc/alloc 333741472.0 332612920.0 -0.3% T13253-spj(normal) ghc/alloc 124947560.0 124427552.0 -0.4% T13379(normal) ghc/alloc 358997996.0 358879840.0 -0.0% T13701(normal) ghc/alloc 2400391456.0 2399956840.0 -0.0% T13719(normal) ghc/alloc 4193179228.0 4192476392.0 -0.0% T14052(ghci) ghc/alloc 2734741552.0 2735731808.0 +0.0% T14052Type(ghci) ghc/alloc 7323235724.0 7323042264.0 -0.0% T14683(normal) ghc/alloc 2990457260.0 2988899144.0 -0.1% T14697(normal) ghc/alloc 363606476.0 363452952.0 -0.0% T15164(normal) ghc/alloc 1291321780.0 1289491968.0 -0.1% T15304(normal) ghc/alloc 1277838020.0 1276208304.0 -0.1% T15630(normal) ghc/alloc 161074632.0 160388136.0 -0.4% T16190(normal) ghc/alloc 276567192.0 276235216.0 -0.1% T16577(normal) ghc/alloc 7564318656.0 7535598656.0 -0.4% T16875(normal) ghc/alloc 34867720.0 34752440.0 -0.3% T17096(normal) ghc/alloc 288477360.0 288156960.0 -0.1% T17516(normal) ghc/alloc 1712777224.0 1704655496.0 -0.5% T17836(normal) ghc/alloc 1092127336.0 1091709880.0 -0.0% T17836b(normal) ghc/alloc 52083516.0 51954056.0 -0.2% T17977(normal) ghc/alloc 44552228.0 44425448.0 -0.3% T17977b(normal) ghc/alloc 40540252.0 40416856.0 -0.3% T18140(normal) ghc/alloc 81908200.0 81678928.0 -0.3% T18223(normal) ghc/alloc 1166459176.0 1164418104.0 -0.2% T18282(normal) ghc/alloc 131123648.0 130740432.0 -0.3% T18304(normal) ghc/alloc 86486796.0 86223088.0 -0.3% T18478(normal) ghc/alloc 746029440.0 745619968.0 -0.1% T18698a(normal) ghc/alloc 337037580.0 336533824.0 -0.1% T18698b(normal) ghc/alloc 398324600.0 397696400.0 -0.2% T18923(normal) ghc/alloc 68496432.0 68286264.0 -0.3% T1969(normal) ghc/alloc 760424696.0 759641664.0 -0.1% T19695(normal) ghc/alloc 1421672472.0 1413682104.0 -0.6% T20049(normal) ghc/alloc 88601524.0 88336560.0 -0.3% T3064(normal) ghc/alloc 190808832.0 190659328.0 -0.1% T3294(normal) ghc/alloc 1604483120.0 1604339080.0 -0.0% T4801(normal) ghc/alloc 296501624.0 296388448.0 -0.0% T5030(normal) ghc/alloc 364336308.0 364206240.0 -0.0% T5321FD(normal) ghc/alloc 270688492.0 270386832.0 -0.1% T5321Fun(normal) ghc/alloc 300860396.0 300559200.0 -0.1% T5631(normal) ghc/alloc 575822760.0 575579160.0 -0.0% T5642(normal) ghc/alloc 470243356.0 468988784.0 -0.3% T5837(normal) ghc/alloc 35936468.0 35821360.0 -0.3% T6048(optasm) ghc/alloc 102587024.0 102222000.0 -0.4% T783(normal) ghc/alloc 386539204.0 386003344.0 -0.1% T9020(optasm) ghc/alloc 247435312.0 247324184.0 -0.0% T9198(normal) ghc/alloc 47170036.0 47054840.0 -0.2% T9233(normal) ghc/alloc 677186820.0 676550032.0 -0.1% T9630(normal) ghc/alloc 1456411516.0 1451045736.0 -0.4% T9675(optasm) ghc/alloc 427190224.0 426812568.0 -0.1% T9872a(normal) ghc/alloc 1704660040.0 1704681856.0 +0.0% T9872b(normal) ghc/alloc 2180109488.0 2180130856.0 +0.0% T9872c(normal) ghc/alloc 1760209640.0 1760231456.0 +0.0% T9872d(normal) ghc/alloc 501126052.0 500973488.0 -0.0% T9961(normal) ghc/alloc 353244688.0 353063104.0 -0.1% TcPlugin_RewritePerf(normal) ghc/alloc 2387276808.0 2387254168.0 -0.0% WWRec(normal) ghc/alloc 588651140.0 587684704.0 -0.2% hard_hole_fits(normal) ghc/alloc 492063812.0 491798360.0 -0.1% hie002(normal) ghc/alloc 9334355960.0 9334396872.0 +0.0% parsing001(normal) ghc/alloc 537410584.0 537421736.0 +0.0% geo. mean -0.2% - - - - - e04878b0 by Matthew Pickering at 2021-12-17T21:23:23-05:00 ci: Use correct metrics baseline It turns out there was already a function in the CI script to correctly set the baseline for performance tests but it was just never called. I now call it during the initialisation to set the correct baseline. I also made the make testsuite driver take into account the PERF_BASELINE_COMMIT environment variable Fixes #20811 - - - - - 1327c176 by Matthew Pickering at 2021-12-17T21:23:58-05:00 Add regression test for T20189 Closes #20189 - - - - - fc9b1755 by Matthew Pickering at 2021-12-17T21:24:33-05:00 Fix documentation formatting in Language.Haskell.TH.CodeDo Fixes #20543 - - - - - abef93f3 by Matthew Pickering at 2021-12-17T21:24:33-05:00 Expand documentation for MulArrowT constructor Fixes #20812 - - - - - 94c3ff66 by Cheng Shao at 2021-12-17T21:25:09-05:00 Binary: make withBinBuffer safe With this patch, withBinBuffer will construct a ByteString that properly captures the reference to the BinHandle internal MutableByteArray#, making it safe to convert a BinHandle to ByteString and use that ByteString outside the continuation. - - - - - a3552934 by Sebastian Graf at 2021-12-17T21:25:45-05:00 Demand: `Eq DmdType` modulo `defaultFvDmd` (#20827) Fixes #20827 by filtering out any default free variable demands (as per `defaultFvDmd`) prior to comparing the assocs of the `DmdEnv`. The details are in `Note [Demand type Equality]`. - - - - - 9529d859 by Sylvain Henry at 2021-12-17T21:26:24-05:00 Perf: avoid using (replicateM . length) when possible Extracted from !6622 - - - - - 887d8b4c by Matthew Pickering at 2021-12-17T21:26:59-05:00 testsuite: Ensure that -dcore-lint is not set for compiler performance tests This place ensures that the default -dcore-lint option is disabled by default when collect_compiler_stats is used but you can still pass -dcore-lint as an additional option (see T1969 which tests core lint performance). Fixes #20830 ------------------------- Metric Decrease: PmSeriesS PmSeriesT PmSeriesV T10858 T11195 T11276 T11374 T11822 T14052 T14052Type T17096 T17836 T17836b T18478 T18698a T18698b ------------------------- - - - - - 5ff47ff5 by Ben Gamari at 2021-12-21T01:46:00-05:00 codeGen: Introduce flag to bounds-check array accesses Here we introduce code generator support for instrument array primops with bounds checking, enabled with the `-fcheck-prim-bounds` flag. Introduced to debug #20769. - - - - - d47bb109 by Ben Gamari at 2021-12-21T01:46:00-05:00 rts: Add optional bounds checking in out-of-line primops - - - - - 8ea79a16 by Ben Gamari at 2021-12-21T01:46:00-05:00 Rename -fcatch-bottoms to -fcatch-nonexhaustive-cases As noted in #20601, the previous name was rather misleading. - - - - - 00b55bfc by Ben Gamari at 2021-12-21T01:46:00-05:00 Introduce -dlint flag As suggested in #20601, this is a short-hand for enabling the usual GHC-internal sanity checks one typically leans on when debugging runtime crashes. - - - - - 9728d6c2 by Sylvain Henry at 2021-12-21T01:46:39-05:00 Give plugins a better interface (#17957) Plugins were directly fetched from HscEnv (hsc_static_plugins and hsc_plugins). The tight coupling of plugins and of HscEnv is undesirable and it's better to store them in a new Plugins datatype and to use it in the plugins' API (e.g. withPlugins, mapPlugins...). In the process, the interactive context (used by GHCi) got proper support for different static plugins than those used for loaded modules. Bump haddock submodule - - - - - 9bc5ab64 by Greg Steuck at 2021-12-21T01:47:17-05:00 Use libc++ instead of libstdc++ on openbsd in addition to freebsd This is not entirely accurate because some openbsd architectures use gcc. Yet we don't have ghc ported to them and thus the approximation is good enough. Fixes ghcilink006 test - - - - - f92c9c0d by Greg Steuck at 2021-12-21T01:47:55-05:00 Only use -ldl conditionally to fix T3807 OpenBSD doesn't have this library and so the linker complains: ld.lld: error: unable to find library -ldl - - - - - ff657a81 by Greg Steuck at 2021-12-21T01:48:32-05:00 Mark `linkwhole` test as expected broken on OpenBSD per #20841 - - - - - 1a596d06 by doyougnu at 2021-12-22T00:12:27-05:00 Cmm: DynFlags to CmmConfig refactor add files GHC.Cmm.Config, GHC.Driver.Config.Cmm Cmm: DynFlag references --> CmmConfig Cmm.Pipeline: reorder imports, add handshake Cmm: DynFlag references --> CmmConfig Cmm.Pipeline: DynFlag references --> CmmConfig Cmm.LayoutStack: DynFlag references -> CmmConfig Cmm.Info.Build: DynFlag references -> CmmConfig Cmm.Config: use profile to retrieve platform Cmm.CLabel: unpack NCGConfig in labelDynamic Cmm.Config: reduce CmmConfig surface area Cmm.Config: add cmmDoCmmSwitchPlans field Cmm.Config: correct cmmDoCmmSwitchPlans flag The original implementation dispatches work in cmmImplementSwitchPlans in an `otherwise` branch, hence we must add a not to correctly dispatch Cmm.Config: add cmmSplitProcPoints simplify Config remove cmmBackend, and cmmPosInd Cmm.CmmToAsm: move ncgLabelDynamic to CmmToAsm Cmm.CLabel: remove cmmLabelDynamic function Cmm.Config: rename cmmOptDoLinting -> cmmDoLinting testsuite: update CountDepsAst CountDepsParser - - - - - d7cc8f19 by Matthew Pickering at 2021-12-22T00:13:02-05:00 ci: Fix master CI I made a mistake in the bash script so there were errors about "$CI_MERGE_REQUEST_DIFF_BASE_SHA" not existing. - - - - - 09b6cb45 by Alan Zimmerman at 2021-12-22T00:13:38-05:00 Fix panic trying to -ddump-parsed-ast for implicit fixity A declaration such as infixr ++++ is supplied with an implicit fixity of 9 in the parser, but uses an invalid SrcSpan to capture this. Use of this span triggers a panic. Fix the problem by not recording an exact print annotation for the non-existent fixity source. Closes #20846 - - - - - 3ed90911 by Matthew Pickering at 2021-12-22T14:47:40-05:00 testsuite: Remove reqlib modifier The reqlib modifer was supposed to indicate that a test needed a certain library in order to work. If the library happened to be installed then the test would run as normal. However, CI has never run these tests as the packages have not been installed and we don't want out tests to depend on things which might get externally broken by updating the compiler. The new strategy is to run these tests in head.hackage, where the tests have been cabalised as well as possible. Some tests couldn't be transferred into the normal style testsuite but it's better than never running any of the reqlib tests. https://gitlab.haskell.org/ghc/head.hackage/-/merge_requests/169 A few submodules also had reqlib tests and have been updated to remove it. Closes #16264 #20032 #17764 #16561 - - - - - ac3e8c52 by Matthew Pickering at 2021-12-22T14:48:16-05:00 perf ci: Start searching form the performance baseline If you specify PERF_BASELINE_COMMIT then this can fail if the specific commit you selected didn't have perf test metrics. (This can happen in CI for example if a build fails on master). Therefore instead of just reporting all tests as new, we start searching downwards from this point to try and find a good commit to report numbers from. - - - - - 9552781a by Matthew Pickering at 2021-12-22T14:48:51-05:00 Mark T16525b as fragile on windows See ticket #20852 - - - - - 13a6d85a by Andreas Klebinger at 2021-12-23T10:55:36-05:00 Make callerCC profiling mode represent entry counter flag. Fixes #20854 - - - - - 80daefce by Matthew Pickering at 2021-12-23T10:56:11-05:00 Properly filter for module visibility in resolvePackageImport This completes the fix for #20779 / !7123. Beforehand, the program worked by accident because the two versions of the library happened to be ordered properly (due to how the hashes were computed). In the real world I observed them being the other way around which meant the final lookup failed because we weren't filtering for visibility. I modified the test so that it failed (and it's fixed by this patch). - - - - - e6191d39 by Krzysztof Gogolewski at 2021-12-25T18:26:44+01:00 Fix typos - - - - - 3219610e by Greg Steuck at 2021-12-26T22:12:43-05:00 Use POSIX-compliant egrep expression to fix T8832 on OpenBSD - - - - - fd42ab5f by Matthew Pickering at 2021-12-28T09:47:53+00:00 Multiple Home Units Multiple home units allows you to load different packages which may depend on each other into one GHC session. This will allow both GHCi and HLS to support multi component projects more naturally. Public Interface ~~~~~~~~~~~~~~~~ In order to specify multiple units, the -unit @⟨filename⟩ flag is given multiple times with a response file containing the arguments for each unit. The response file contains a newline separated list of arguments. ``` ghc -unit @unitLibCore -unit @unitLib ``` where the `unitLibCore` response file contains the normal arguments that cabal would pass to `--make` mode. ``` -this-unit-id lib-core-0.1.0.0 -i -isrc LibCore.Utils LibCore.Types ``` The response file for lib, can specify a dependency on lib-core, so then modules in lib can use modules from lib-core. ``` -this-unit-id lib-0.1.0.0 -package-id lib-core-0.1.0.0 -i -isrc Lib.Parse Lib.Render ``` Then when the compiler starts in --make mode it will compile both units lib and lib-core. There is also very basic support for multiple home units in GHCi, at the moment you can start a GHCi session with multiple units but only the :reload is supported. Most commands in GHCi assume a single home unit, and so it is additional work to work out how to modify the interface to support multiple loaded home units. Options used when working with Multiple Home Units There are a few extra flags which have been introduced specifically for working with multiple home units. The flags allow a home unit to pretend it’s more like an installed package, for example, specifying the package name, module visibility and reexported modules. -working-dir ⟨dir⟩ It is common to assume that a package is compiled in the directory where its cabal file resides. Thus, all paths used in the compiler are assumed to be relative to this directory. When there are multiple home units the compiler is often not operating in the standard directory and instead where the cabal.project file is located. In this case the -working-dir option can be passed which specifies the path from the current directory to the directory the unit assumes to be it’s root, normally the directory which contains the cabal file. When the flag is passed, any relative paths used by the compiler are offset by the working directory. Notably this includes -i and -I⟨dir⟩ flags. -this-package-name ⟨name⟩ This flag papers over the awkward interaction of the PackageImports and multiple home units. When using PackageImports you can specify the name of the package in an import to disambiguate between modules which appear in multiple packages with the same name. This flag allows a home unit to be given a package name so that you can also disambiguate between multiple home units which provide modules with the same name. -hidden-module ⟨module name⟩ This flag can be supplied multiple times in order to specify which modules in a home unit should not be visible outside of the unit it belongs to. The main use of this flag is to be able to recreate the difference between an exposed and hidden module for installed packages. -reexported-module ⟨module name⟩ This flag can be supplied multiple times in order to specify which modules are not defined in a unit but should be reexported. The effect is that other units will see this module as if it was defined in this unit. The use of this flag is to be able to replicate the reexported modules feature of packages with multiple home units. Offsetting Paths in Template Haskell splices ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When using Template Haskell to embed files into your program, traditionally the paths have been interpreted relative to the directory where the .cabal file resides. This causes problems for multiple home units as we are compiling many different libraries at once which have .cabal files in different directories. For this purpose we have introduced a way to query the value of the -working-dir flag to the Template Haskell API. By using this function we can implement a makeRelativeToProject function which offsets a path which is relative to the original project root by the value of -working-dir. ``` import Language.Haskell.TH.Syntax ( makeRelativeToProject ) foo = $(makeRelativeToProject "./relative/path" >>= embedFile) ``` > If you write a relative path in a Template Haskell splice you should use the makeRelativeToProject function so that your library works correctly with multiple home units. A similar function already exists in the file-embed library. The function in template-haskell implements this function in a more robust manner by honouring the -working-dir flag rather than searching the file system. Closure Property for Home Units ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For tools or libraries using the API there is one very important closure property which must be adhered to: > Any dependency which is not a home unit must not (transitively) depend on a home unit. For example, if you have three packages p, q and r, then if p depends on q which depends on r then it is illegal to load both p and r as home units but not q, because q is a dependency of the home unit p which depends on another home unit r. If you are using GHC by the command line then this property is checked, but if you are using the API then you need to check this property yourself. If you get it wrong you will probably get some very confusing errors about overlapping instances. Limitations of Multiple Home Units ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There are a few limitations of the initial implementation which will be smoothed out on user demand. * Package thinning/renaming syntax is not supported * More complicated reexports/renaming are not yet supported. * It’s more common to run into existing linker bugs when loading a large number of packages in a session (for example #20674, #20689) * Backpack is not yet supported when using multiple home units. * Dependency chasing can be quite slow with a large number of modules and packages. * Loading wired-in packages as home units is currently not supported (this only really affects GHC developers attempting to load template-haskell). * Barely any normal GHCi features are supported, it would be good to support enough for ghcid to work correctly. Despite these limitations, the implementation works already for nearly all packages. It has been testing on large dependency closures, including the whole of head.hackage which is a total of 4784 modules from 452 packages. Internal Changes ~~~~~~~~~~~~~~~~ * The biggest change is that the HomePackageTable is replaced with the HomeUnitGraph. The HomeUnitGraph is a map from UnitId to HomeUnitEnv, which contains information specific to each home unit. * The HomeUnitEnv contains: - A unit state, each home unit can have different package db flags - A set of dynflags, each home unit can have different flags - A HomePackageTable * LinkNode: A new node type is added to the ModuleGraph, this is used to place the linking step into the build plan so linking can proceed in parralel with other packages being built. * New invariant: Dependencies of a ModuleGraphNode can be completely determined by looking at the value of the node. In order to achieve this, downsweep now performs a more complete job of downsweeping and then the dependenices are recorded forever in the node rather than being computed again from the ModSummary. * Some transitive module calculations are rewritten to use the ModuleGraph which is more efficient. * There is always an active home unit, which simplifies modifying a lot of the existing API code which is unit agnostic (for example, in the driver). The road may be bumpy for a little while after this change but the basics are well-tested. One small metric increase, which we accept and also submodule update to haddock which removes ExtendedModSummary. Closes #10827 ------------------------- Metric Increase: MultiLayerModules ------------------------- Co-authored-by: Fendor <power.walross at gmail.com> - - - - - 72824c63 by Richard Eisenberg at 2021-12-28T10:09:28-05:00 Skip computing superclass origins for equalities This yields a small, but measurable, performance improvement. - - - - - 8b6aafb2 by Matthew Pickering at 2021-12-29T14:09:47-05:00 Cabal: Update submodule Closes #20874 - - - - - 44a5507f by Peter Trommler at 2021-12-29T14:10:22-05:00 RTS: Fix CloneStack.c when no table next to code Function `lookupIPE` does not modify its argument. Reflect this in the type. Module `CloneStack.c` relies on this for RTS without tables next to code. Fixes #20879 - - - - - 246d2782 by sheaf at 2022-01-02T04:20:09-05:00 User's guide: newtype decls can use GADTSyntax The user's guide failed to explicitly mention that GADTSyntax can be used to declare newtypes, so we add an example and a couple of explanations. Also explains that `-XGADTs` generalises `-XExistentialQuantification`. Fixes #20848 and #20865. - - - - - f212cece by Hécate Moonlight at 2022-01-02T04:20:47-05:00 Add a source-repository stanza to rts/rts.cabal - - - - - d9e49195 by Greg Steuck at 2022-01-03T05:18:24+00:00 Replace `seq` with POSIX-standard printf(1) in ManyAlternatives test The test now passes on OpenBSD instead of generating broken source which was rejected by GHC with ManyAlternatives.hs:5:1: error: The type signature for ‘f’ lacks an accompanying binding - - - - - 80e416ae by Greg Steuck at 2022-01-03T05:18:24+00:00 Replace `seq` with POSIX-standard in PmSeriesG test - - - - - 8fa52f5c by Eric Lindblad at 2022-01-03T16:48:51-05:00 fix typo - - - - - a49f5889 by Roland Senn at 2022-01-03T16:49:29-05:00 Add regressiontest for #18045 Issue #18045 got fixed by !6971. - - - - - 7f10686e by sheaf at 2022-01-03T16:50:07-05:00 Add test for #20894 - - - - - 5111028e by sheaf at 2022-01-04T19:56:13-05:00 Check quoted TH names are in the correct namespace When quoting (using a TH single or double quote) a built-in name such as the list constructor (:), we didn't always check that the resulting 'Name' was in the correct namespace. This patch adds a check in GHC.Rename.Splice to ensure we get a Name that is in the term-level/type-level namespace, when using a single/double tick, respectively. Fixes #20884. - - - - - 1de94daa by George Thomas at 2022-01-04T19:56:51-05:00 Fix Haddock parse error in GHC.Exts.Heap.FFIClosures.hs - - - - - e59bd46a by nineonine at 2022-01-05T18:07:18+00:00 Add regression test (#13997) - - - - - c080b443 by Sylvain Henry at 2022-01-06T02:24:54-05:00 Perf: use SmallArray for primops' Ids cache (#20857) SmallArray doesn't perform bounds check (faster). Make primop tags start at 0 to avoid index arithmetic. - - - - - ec26c38b by Sylvain Henry at 2022-01-06T02:24:54-05:00 Use primOpIds cache more often (#20857) Use primOpId instead of mkPrimOpId in a few places to benefit from Id caching. I had to mess a little bit with the module hierarchy to fix cycles and to avoid adding too many new dependencies to count-deps tests. - - - - - f7fc62e2 by Greg Steuck at 2022-01-06T07:56:22-05:00 Disable T2615 on OpenBSD, close #20869 - - - - - 978ea35e by Greg Steuck at 2022-01-06T07:57:00-05:00 Change ulimit -n in openFile008 back to 1024 The test only wants 1000 descriptors, so changing the limit to double that *in the context of just this test* makes no sense. This is a manual revert of 8f7194fae23bdc6db72fc5784933f50310ce51f9. The justification given in the description doesn't instill confidence. As of HEAD, the test fails on OpenBSD where ulimit -n is hard-limited to 1024. The test suite attempts to change it to 2048, which fails. The test proceeds with the unchanged default of 512 and naturally the test program fails due to the low ulimit. The fixed test now passes. - - - - - 7b783c9d by Matthew Pickering at 2022-01-07T18:25:06-05:00 Thoughtful forcing in CoreUnfolding We noticed that the structure of CoreUnfolding could leave double the amount of CoreExprs which were retained in the situation where the template but not all the predicates were forced. This observation was then confirmed using ghc-debug: ``` (["ghc:GHC.Core:App","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 237) (["ghc:GHC.Core:App","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","ghc-prim:GHC.Types:True"],Count 1) (["ghc:GHC.Core:Case","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 12) (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","BLACKHOLE"],Count 1) (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 78) (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","THUNK_1_0","ghc-prim:GHC.Types:False","THUNK_1_0"],Count 1) (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","ghc-prim:GHC.Types:False","THUNK_1_0","THUNK_1_0"],Count 3) (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0"],Count 1) (["ghc:GHC.Core:Lam","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","BLACKHOLE"],Count 31) (["ghc:GHC.Core:Lam","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 4307) (["ghc:GHC.Core:Lam","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","ghc-prim:GHC.Types:True"],Count 6) (["ghc:GHC.Core:Let","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 29) (["ghc:GHC.Core:Lit","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","ghc-prim:GHC.Types:True"],Count 1) (["ghc:GHC.Core:Tick","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 36) (["ghc:GHC.Core:Var","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 1) (["ghc:GHC.Core:Var","ghc-prim:GHC.Types:True","ghc-prim:GHC.Types:False","THUNK_1_0","THUNK_1_0"],Count 6) (["ghc:GHC.Core:Var","ghc-prim:GHC.Types:True","ghc-prim:GHC.Types:False","ghc-prim:GHC.Types:True","THUNK_1_0"],Count 2) ``` Where we can see that the first argument is forced but there are still thunks remaining which retain the old expr. For my test case (a very big module, peak of 3 000 000 core terms) this reduced peak memory usage by 1G (12G -> 11G). Fixes #20905 - - - - - f583eb8e by Joachim Breitner at 2022-01-07T18:25:41-05:00 Remove dangling references to Note [Type-checking overloaded labels] that note was removed in 4196969c53c55191e644d9eb258c14c2bc8467da - - - - - 2b6c2179 by Matthew Pickering at 2022-01-11T19:37:45-05:00 hadrian: Add bootstrap scripts for building without cabal-install These scripts are originally from the cabal-install repo with a few small tweaks. This utility allows you to build hadrian without cabal-install, which can be useful for packagers. If you are a developer then build hadrian using cabal-install. If you want to bootstrap with ghc-8.10.5 then run the ./bootstrap script with the `plan-bootstrap-8.10.5.json` file. bootstrap.py -d plan-bootstrap-8.10.5.json -w /path/to-ghc The result of the bootstrap script will be a hadrian binary in `_build/bin/hadrian`. There is a script (using nix) which can be used to generate the bootstrap plans for the range of supported GHC versions using nix. generate_bootstrap_plans Otherwise you can run the commands in ./generate_bootstrap_plans directly. Fixes #17103 - - - - - a8fb4251 by Zubin Duggal at 2022-01-11T19:37:45-05:00 hadrian: allow offline bootstrapping This patch adds the ability to fetch and store dependencies needed for boostrapping hadrian. By default the script will download the dependencies from the network but some package managers disallow network access so there are also options to build given a supplied tarball. The -s option allos you to provide the tarball bootstrap.py -d plan-bootstrap-8.10.5.json -w /path/to-ghc -s sources-tarball.tar.gz Which dependencies you need can be queried using the `list-sources` option. bootstrap.py list-sources -d plan-bootstrap-8.10.5.json This produces `fetch_plan.json` which tells you where to get each source from. You can instruct the script to create the tarball using the `fetch` option. bootstrap.py fetch -d plan-bootstrap-8.10.5.json -o sources-tarball.tar.gz Together these commands mean you can build GHC without needing cabal-install. Fixes #17103 - - - - - 02cf4bc6 by Zubin Duggal at 2022-01-11T19:37:45-05:00 hadrian: Fully implement source distributions (#19317) We use `git ls-files` to get the list of files to include in the source distribution. Also implements the `-testsuite` and `-extra-tarballs` distributions. - - - - - 85473a09 by Zubin Duggal at 2022-01-11T19:37:45-05:00 ci: test bootstrapping and use hadrian for source dists - - - - - 759f3421 by Matthew Pickering at 2022-01-11T19:38:21-05:00 ci: Nightly, run one head.hackage job with core-lint and one without This fixes serious skew in the performance numbers because the packages were build with core-lint. Fixes #20826 - - - - - 6737c8e1 by Ben Gamari at 2022-01-11T19:38:56-05:00 rts: Depend explicitly on libc As noted in #19029, currently `ghc-prim` explicitly lists `libc` in `extra-libraries`, resulting in incorrect link ordering with the `extra-libraries: pthread` in `libHSrts`. Fix this by adding an explicit dependency on `libc` to `libHSrts`. Closes #19029. - - - - - 247cd336 by Ben Gamari at 2022-01-11T19:39:32-05:00 rts: Only declare environ when necessary Previously we would unconditionally provide a declaration for `environ`, even if `<unistd.h>` already provided one. This would result in `-Werror` builds failing on some platforms. Also `#include <unistd.h>` to ensure that the declaration is visible. Fixes #20861. - - - - - b65e7274 by Greg Steuck at 2022-01-11T19:40:10-05:00 Skip T18623 on OpenBSD The bug it regresses didn't happen on this OS (no RLIMIT_AS) and the regression doesn't work (ulimit: -v: unknown option) - - - - - c6300cb3 by Greg Steuck at 2022-01-11T19:40:50-05:00 Skip T16180 on OpenBSD due to bug #14012 - - - - - addf8e54 by sheaf at 2022-01-11T19:41:28-05:00 Kind TyCons: require KindSignatures, not DataKinds Uses of a TyCon in a kind signature required users to enable DataKinds, which didn't make much sense, e.g. in type U = Type type MyMaybe (a :: U) = MyNothing | MyJust a Now the DataKinds error is restricted to data constructors; the use of kind-level type constructors is instead gated behind -XKindSignatures. This patch also adds a convenience pattern synonym for patching on both a TyCon or a TcTyCon stored in a TcTyThing, used in tcTyVar and tc_infer_id. fixes #20873 - - - - - 34d8bc24 by sheaf at 2022-01-11T19:42:07-05:00 Fix parsing & printing of unboxed sums The pretty-printing of partially applied unboxed sums was incorrect, as we incorrectly dropped the first half of the arguments, even for a partial application such as (# | #) @IntRep @DoubleRep Int# which lead to the nonsensical (# DoubleRep | Int# #). This patch also allows users to write unboxed sum type constructors such as (# | #) :: TYPE r1 -> TYPE r2 -> TYPE (SumRep '[r1,r2]). Fixes #20858 and #20859. - - - - - 49731fed by sheaf at 2022-01-11T19:42:46-05:00 TcPlugins: `newWanted` uses the provided `CtLoc` The `GHC.Tc.Plugin.newWanted` function takes a `CtLoc` as an argument, but it used to discard the location information, keeping only the `CtOrigin`. It would then retrieve the source location from the `TcM` environment using `getCtLocM`. This patch changes this so that `GHC.Tc.Plugin.newWanted` passes on the full `CtLoc`. This means that authors of type-checking plugins no longer need to manually set the `CtLoc` environment in the `TcM` monad if they want to create a new Wanted constraint with the given `CtLoc` (in particular, for setting the `SrcSpan` of an emitted constraint). This makes the `newWanted` function consistent with `newGiven`, which always used the full `CtLoc` instead of using the environment. Fixes #20895 - - - - - 23d215fc by Krzysztof Gogolewski at 2022-01-11T19:43:22-05:00 warnPprTrace: pass separately the reason This makes it more similar to pprTrace, pprPanic etc. - - - - - 833216a3 by Matthew Pickering at 2022-01-11T19:43:57-05:00 Use interactive flags when printing expressions in GHCi The documentation states that the interactive flags should be use for any interactive expressions. The interactive flags are used when typechecking these expressions but not when printing. The session flags (modified by :set) are only used when loading a module. Fixes #20909 - - - - - 19b13698 by Matthew Pickering at 2022-01-11T19:43:57-05:00 Enable :seti in a multi component repl Part of #20889 - - - - - 7ca43a3f by Matthew Pickering at 2022-01-11T19:44:33-05:00 Change assertions in Stats.c to warnings (and introduce WARN macro) ASSERT should be used in situations where something very bad will happen later on if a certain invariant doesn't hold. The idea is that IF we catch the assertion earlier then it will be easier to work out what's going on at that point rather than at some indeterminate point in the future of the program. The assertions in Stats.c do not obey this philsophy and it is quite annoying if you are running a debug build (or a ticky compiler) and one of these assertions fails right at the end of your program, before the ticky report is printed out so you don't get any profiling information. Given that nothing terrible happens if these assertions are not true, or at least the terrible thing will happen in very close proximity to the assertion failure, these assertions use the new WARN macro which prints the assertion failure to stdout but does not exit the program. Of course, it would be better to fix these metrics to not trigger the assertion in the first place but if they did fail again in the future it is frustrating to be bamboozled in this manner. Fixes #20899 - - - - - e505dbd3 by Greg Steuck at 2022-01-11T19:45:11-05:00 Remove from error the parenthesized amount of memory requested Diagnostics for outofmem test on OpenBSD includes the amount of memory that it failed to allocate. This seems like an irrelevant detail that could change over time and isn't required for determining if test passed. Typical elided text is '(requested 2148532224 bytes)' - - - - - 7911aaa9 by Greg Steuck at 2022-01-11T19:45:50-05:00 Feed /dev/null into cgrun025 The test currently times out waiting for end of stdin in getContents. The expected output indicates that nothing should come for the test to pass as written. It is unclear how the test was supposed to pass, but this looks like a sufficient hack to make it work. - - - - - ed39d15c by Greg Steuck at 2022-01-11T19:46:28-05:00 Disable keep-cafs{,-fail} tests on OpenBSD They are likely broken for the same reason as FreeBSD where the tests are already disabled. - - - - - 35bea01b by Peter Trommler at 2022-01-11T19:47:04-05:00 RTS: Remove unused file xxhash.c - - - - - c2099059 by Matthew Pickering at 2022-01-11T19:47:39-05:00 RTTI: Substitute the [rk] skolems into kinds (Fixes #10616 and #10617) Co-authored-by: Roland Senn <rsx at bluewin.ch> - - - - - 92f3e6e4 by Matthew Pickering at 2022-01-11T19:48:15-05:00 docs: MonadComprehension desugar using Alternative rather than MonadPlus Fixes #20928 - - - - - 7b0c9384 by Sylvain Henry at 2022-01-12T23:25:49-05:00 Abstract BangOpts Avoid requiring to pass DynFlags to mkDataConRep/buildDataCon. When we load an interface file, these functions don't use the flags. This is preliminary work to decouple the loader from the type-checker for #14335. - - - - - a31ace56 by Sylvain Henry at 2022-01-12T23:25:49-05:00 Untangled GHC.Types.Id.Make from the driver - - - - - 81a8f7a7 by Zubin Duggal at 2022-01-12T23:26:24-05:00 testsuite: Fix import on python 3.10 - - - - - 66831b94 by Ben Gamari at 2022-01-13T14:50:13-05:00 hadrian: Include bash completion script in bindist See #20802. - - - - - be33d61a by Sebastian Graf at 2022-01-13T14:50:49-05:00 release notes: Changes to CPR analysis - - - - - c2a6c3eb by Sebastian Graf at 2022-01-13T14:50:49-05:00 release notes: Changes to Demand analysis - - - - - 9ccc445a by Eric Lindblad at 2022-01-14T10:35:46-05:00 add NUMJOBS - - - - - 564b89ae by Eric Lindblad at 2022-01-14T10:35:46-05:00 Revert "add NUMJOBS" This reverts commit c0b854e929f82c680530e944e12fad24f9e14f8e - - - - - 2dfc268c by Eric Lindblad at 2022-01-14T10:35:46-05:00 update URLs - - - - - 1aace894 by Eric Lindblad at 2022-01-14T10:35:46-05:00 reinsert target - - - - - 52a4f5ab by Andreas Klebinger at 2022-01-14T10:36:21-05:00 Add test for #20938. - - - - - e2b60be8 by Ben Gamari at 2022-01-15T03:41:16-05:00 rts: Consolidate RtsSymbols from libc Previously (9ebda74ec5331911881d734b21fbb31c00a0a22f) `environ` was added to `RtsSymbols` to ensure that environment was correctly propagated when statically linking. However, this introduced #20577 since platforms are inconsistent in whether they provide a prototype for `environ`. I fixed this by providing a prototype but while doing so dropped symbol-table entry, presumably thinking that it was redundant due to the entry in the mingw-specific table. Here I reintroduce the symbol table entry for `environ` and move libc symbols shared by Windows and Linux into a new macro, `RTS_LIBC_SYMBOLS`, avoiding this potential confusion. - - - - - 0dc72395 by Tamar Christina at 2022-01-15T03:41:55-05:00 winio: fix heap corruption and various leaks. - - - - - 4031ef62 by Eric Lindblad at 2022-01-15T20:11:55+00:00 wikipedia link - - - - - a13aff98 by Eric Lindblad at 2022-01-17T08:25:51-05:00 ms link - - - - - f161e890 by sheaf at 2022-01-17T14:52:50+00:00 Use diagnostic infrastructure in GHC.Tc.Errors - - - - - 18c797b8 by Jens Petersen at 2022-01-18T16:12:14-05:00 hadrian BinaryDist: version ghc in ghciScriptWrapper like we do for the non-Hadrian wrapper script. Otherwise if $bindir/ghc is a different ghc version then versioned ghci will incorrectly run the other ghc version instead. (Normally this would only happen if there are parallel ghc versions installed in bindir.) All the other wrapper scripts already have versioned executablename - - - - - 310424d0 by Matthew Pickering at 2022-01-18T16:12:50-05:00 Correct type of static forms in hsExprType The simplest way to do this seemed to be to persist the whole type in the extension field from the typechecker so that the few relevant places * Desugaring can work out the return type by splitting this type rather than calling `dsExpr` (slightly more efficient). * hsExprType can just return the correct type. * Zonking has to now zonk the type as well The other option we considered was wiring in StaticPtr but that is actually quite tricky because StaticPtr refers to StaticPtrInfo which has field selectors (which we can't easily wire in). Fixes #20150 - - - - - 7ec783de by Matthew Pickering at 2022-01-18T16:12:50-05:00 Add test for using type families with static pointers Issue was reported on #13306 - - - - - 2d205154 by Sebastian Graf at 2022-01-18T16:13:25-05:00 Stricten the Strict State monad I found it weird that most of the combinators weren't actually strict. Making `pure` strict in the state should hopefully give Nested CPR an easier time to unbox the nested state. - - - - - 5a6efd21 by Ben Gamari at 2022-01-18T16:14:01-05:00 rts/winio: Fix #18382 Here we refactor WinIO's IO completion scheme, squashing a memory leak and fixing #18382. To fix #18382 we drop the special thread status introduced for IoPort blocking, BlockedOnIoCompletion, as well as drop the non-threaded RTS's special dead-lock detection logic (which is redundant to the GC's deadlock detection logic), as proposed in #20947. Previously WinIO relied on foreign import ccall "wrapper" to create an adjustor thunk which can be attached to the OVERLAPPED structure passed to the operating system. It would then use foreign import ccall "dynamic" to back out the original continuation from the adjustor. This roundtrip is significantly more expensive than the alternative, using a StablePtr. Furthermore, the implementation let the adjustor leak, meaning that every IO request would leak a page of memory. Fixes T18382. - - - - - 01254ceb by Matthew Pickering at 2022-01-18T16:14:37-05:00 Add note about heap invariant Closed #20904 - - - - - 21510698 by Sergey Vinokurov at 2022-01-18T16:15:12-05:00 Improve detection of lld linker Newer lld versions may include vendor info in --version output and thus the version string may not start with ‘LLD’. Fixes #20907 - - - - - 95e7964b by Peter Trommler at 2022-01-18T20:46:08-05:00 Fix T20638 on big-endian architectures The test reads a 16 bit value from an array of 8 bit values. Naturally, that leads to different values read on big-endian architectures than on little-endian. In this case the value read is 0x8081 on big-endian and 0x8180 on little endian. This patch changes the argument of the `and` machop to mask bit 7 which is the only bit different. The test still checks that bit 15 is zero, which was the original issue in #20638. Fixes #20906. - - - - - fd0019a0 by Eric Lindblad at 2022-01-18T20:46:48-05:00 ms and gh links - - - - - 85dc61ee by Zubin Duggal at 2022-01-18T20:47:23-05:00 ci: Fix subtlety with not taking effect because of time_it (#20898) - - - - - 592e4113 by Anselm Schüler at 2022-01-19T13:31:49-05:00 Note that ImpredicativeTypes doesn’t allow polymorphic instances See #20939 - - - - - 3b009e1a by Ben Gamari at 2022-01-19T13:32:25-05:00 base: Add CTYPE pragmas to all foreign types Fixes #15531 by ensuring that we know the corresponding C type for all marshalling wrappers. Closes #15531. - - - - - 516eeb9e by Robert Hensing at 2022-01-24T21:28:24-05:00 Add -fcompact-unwind This gives users the choice to enable __compact_unwind sections when linking. These were previously hardcoded to be removed. This can be used to solved the problem "C++ does not catch exceptions when used with Haskell-main and linked by ghc", https://gitlab.haskell.org/ghc/ghc/-/issues/11829 It does not change the default behavior, because I can not estimate the impact this would have. When Apple first introduced the compact unwind ABI, a number of open source projects have taken the easy route of disabling it, avoiding errors or even just warnings shortly after its introduction. Since then, about a decade has passed, so it seems quite possible that Apple itself, and presumably many programs with it, have successfully switched to the new format, to the point where the old __eh_frame section support is in disrepair. Perhaps we should get along with the program, but for now we can test the waters with this flag, and use it to fix packages that need it. - - - - - 5262b1e5 by Robert Hensing at 2022-01-24T21:28:24-05:00 Add test case for C++ exception handling - - - - - a5c94092 by Sebastian Graf at 2022-01-24T21:29:00-05:00 Write Note [Strict State monad] to explain what G.U.M.State.Strict does As requested by Simon after review of !7342. I also took liberty to define the `Functor` instance by hand, as the derived one subverts the invariants maintained by the pattern synonym (as already stated in `Note [The one-shot state monad trick]`). - - - - - 9b0d56d3 by Eric Lindblad at 2022-01-24T21:29:38-05:00 links - - - - - 4eac8e72 by Ben Gamari at 2022-01-24T21:30:13-05:00 ghc-heap: Drop mention of BlockedOnIOCompletion Fixes bootstrap with GHC 9.0 after 5a6efd218734dbb5c1350531680cd3f4177690f1 - - - - - 7d7b9a01 by Ryan Scott at 2022-01-24T21:30:49-05:00 Hadrian: update the index-state to allow building with GHC 9.0.2 Fixes #20984. - - - - - aa50e118 by Peter Trommler at 2022-01-24T21:31:25-05:00 testsuite: Mark test that require RTS linker - - - - - 871ce2a3 by Matthew Pickering at 2022-01-25T17:27:30-05:00 ci: Move (most) deb9 jobs to deb10 deb9 is now end-of-life so we are dropping support for producing bindists. - - - - - 9d478d51 by Ryan Scott at 2022-01-25T17:28:06-05:00 DeriveGeneric: look up datacon fixities using getDataConFixityFun Previously, `DeriveGeneric` would look up the fixity of a data constructor using `getFixityEnv`, but this is subtly incorrect for data constructors defined in external modules. This sort of situation can happen with `StandaloneDeriving`, as noticed in #20994. In fact, the same bug has occurred in the past in #9830, and while that bug was fixed for `deriving Read` and `deriving Show`, the fix was never extended to `DeriveGeneric` due to an oversight. This patch corrects that oversight. Fixes #20994. - - - - - 112e9e9e by Zubin Duggal at 2022-01-25T17:28:41-05:00 Fix Werror on alpine - - - - - 781323a3 by Matthew Pickering at 2022-01-25T17:29:17-05:00 Widen T12545 acceptance window This test has been the scourge of contributors for a long time. It has caused many failed CI runs and wasted hours debugging a test which barely does anything. The fact is does nothing is the reason for the flakiness and it's very sensitive to small changes in initialisation costs, in particular adding wired-in things can cause this test to fluctuate quite a bit. Therefore we admit defeat and just bump the threshold up to 10% to catch very large regressions but otherwise don't care what this test does. Fixes #19414 - - - - - e471a680 by sheaf at 2022-01-26T12:01:45-05:00 Levity-polymorphic arrays and mutable variables This patch makes the following types levity-polymorphic in their last argument: - Array# a, SmallArray# a, Weak# b, StablePtr# a, StableName# a - MutableArray# s a, SmallMutableArray# s a, MutVar# s a, TVar# s a, MVar# s a, IOPort# s a The corresponding primops are also made levity-polymorphic, e.g. `newArray#`, `readArray#`, `writeMutVar#`, `writeIOPort#`, etc. Additionally, exception handling functions such as `catch#`, `raise#`, `maskAsyncExceptions#`,... are made levity/representation-polymorphic. Now that Array# and MutableArray# also work with unlifted types, we can simply re-define ArrayArray# and MutableArrayArray# in terms of them. This means that ArrayArray# and MutableArrayArray# are no longer primitive types, but simply unlifted newtypes around Array# and MutableArrayArray#. This completes the implementation of the Pointer Rep proposal https://github.com/ghc-proposals/ghc-proposals/pull/203 Fixes #20911 ------------------------- Metric Increase: T12545 ------------------------- ------------------------- Metric Decrease: T12545 ------------------------- - - - - - 6e94ba54 by Andreas Klebinger at 2022-01-26T12:02:21-05:00 CorePrep: Don't try to wrap partial applications of primops in profiling ticks. This fixes #20938. - - - - - b55d7db3 by sheaf at 2022-01-26T12:03:01-05:00 Ensure that order of instances doesn't matter The insert_overlapping used in lookupInstEnv used to return different results depending on the order in which instances were processed. The problem was that we could end up discarding an overlapping instance in favour of a more specific non-overlapping instance. This is a problem because, even though we won't choose the less-specific instance for matching, it is still useful for pruning away other instances, because it has the overlapping flag set while the new instance doesn't. In insert_overlapping, we now keep a list of "guard" instances, which are instances which are less-specific that one that matches (and hence which we will discard in the end), but want to keep around solely for the purpose of eliminating other instances. Fixes #20946 - - - - - 61f62062 by sheaf at 2022-01-26T12:03:40-05:00 Remove redundant SOURCE import in FitTypes Fixes #20995 - - - - - e8405829 by sheaf at 2022-01-26T12:04:15-05:00 Fix haddock markup in GHC.Tc.Errors.Types - - - - - 590a2918 by Simon Peyton Jones at 2022-01-26T19:45:22-05:00 Make RULE matching insensitive to eta-expansion This patch fixes #19790 by making the rule matcher do on-the-fly eta reduction. See Note [Eta reduction the target] in GHC.Core.Rules I found I also had to careful about casts when matching; see Note [Casts in the target] and Note [Casts in the template] Lots more comments and Notes in the rule matcher - - - - - c61ac4d8 by Matthew Pickering at 2022-01-26T19:45:58-05:00 alwaysRerun generation of ghcconfig This file needs to match exactly what is passed as the testCompiler. Before this change the settings for the first compiler to be tested woudl be stored and not regenerated if --test-compiler changed. - - - - - b5132f86 by Matthew Pickering at 2022-01-26T19:45:58-05:00 Pass config.stage argument to testsuite - - - - - 83d3ad31 by Zubin Duggal at 2022-01-26T19:45:58-05:00 hadrian: Allow testing of the stage1 compiler (#20755) - - - - - a5924b38 by Joachim Breitner at 2022-01-26T19:46:34-05:00 Simplifier: Do the right thing if doFloatFromRhs = False If `doFloatFromRhs` is `False` then the result from `prepareBinding` should not be used. Previously it was in ways that are silly (but not completly wrong, as the simplifier would clean that up again, so no test case). This was spotted by Simon during a phone call. Fixes #20976 - - - - - ce488c2b by Simon Peyton Jones at 2022-01-26T19:47:09-05:00 Better occurrence analysis with casts This patch addresses #20988 by refactoring the way the occurrence analyser deals with lambdas. Previously it used collectBinders to split off a group of binders, and deal with them together. Now I deal with them one at a time in occAnalLam, which allows me to skip casts easily. See Note [Occurrence analysis for lambda binders] about "lambda-groups" This avoidance of splitting out a list of binders has some good consequences. Less code, more efficient, and I think, more clear. The Simplifier needed a similar change, now that lambda-groups can inlude casts. It turned out that I could simplify the code here too, in particular elminating the sm_bndrs field of StrictBind. Simpler, more efficient. Compile-time metrics improve slightly; here are the ones that are +/- 0.5% or greater: Baseline Test Metric value New value Change -------------------------------------------------------------------- T11303b(normal) ghc/alloc 40,736,702 40,543,992 -0.5% T12425(optasm) ghc/alloc 90,443,459 90,034,104 -0.5% T14683(normal) ghc/alloc 2,991,496,696 2,956,277,288 -1.2% T16875(normal) ghc/alloc 34,937,866 34,739,328 -0.6% T17977b(normal) ghc/alloc 37,908,550 37,709,096 -0.5% T20261(normal) ghc/alloc 621,154,237 618,312,480 -0.5% T3064(normal) ghc/alloc 190,832,320 189,952,312 -0.5% T3294(normal) ghc/alloc 1,604,674,178 1,604,608,264 -0.0% T5321FD(normal) ghc/alloc 270,540,489 251,888,480 -6.9% GOOD T5321Fun(normal) ghc/alloc 300,707,814 281,856,200 -6.3% GOOD WWRec(normal) ghc/alloc 588,460,916 585,536,400 -0.5% geo. mean -0.3% Metric Decrease: T5321FD T5321Fun - - - - - 4007905d by Roland Senn at 2022-01-26T19:47:47-05:00 Cleanup tests in directory ghci.debugger. Fixes #21009 * Remove wrong comment about panic in `break003.script`. * Improve test `break008`. * Add test `break028` to `all.T` * Fix wrong comments in `print019.script`, `print026.script` and `result001.script`. * Remove wrong comments from `print024.script` and `print031.script`. * Replace old module name with current name in `print035.script`. - - - - - 3577defb by Matthew Pickering at 2022-01-26T19:48:22-05:00 ci: Move source-tarball and test-bootstrap into full-build - - - - - 6e09b3cf by Matthew Pickering at 2022-01-27T02:39:35-05:00 ci: Add ENABLE_NUMA flag to explicitly turn on libnuma dependency In recent releases a libnuma dependency has snuck into our bindists because the images have started to contain libnuma. We now explicitly pass `--disable-numa` to configure unless explicitly told not to by using the `ENABLE_NUMA` environment variable. So this is tested, there is one random validate job which builds with --enable-numa so that the code in the RTS is still built. Fixes #20957 and #15444 - - - - - f4ce4186 by Simon Peyton Jones at 2022-01-27T02:40:11-05:00 Improve partial signatures As #20921 showed, with partial signatures, it is helpful to use the same algorithm (namely findInferredDiff) for * picking the constraints to retain for the /group/ in Solver.decideQuantification * picking the contraints to retain for the /individual function/ in Bind.chooseInferredQuantifiers This is still regrettably declicate, but it's a step forward. - - - - - 0573aeab by Simon Peyton Jones at 2022-01-27T02:40:11-05:00 Add an Outputable instance for RecTcChecker - - - - - f0adea14 by Ryan Scott at 2022-01-27T02:40:47-05:00 Expand type synonyms in markNominal `markNominal` is repsonsible for setting the roles of type variables that appear underneath an `AppTy` to be nominal. However, `markNominal` previously did not expand type synonyms, so in a data type like this: ```hs data M f a = MkM (f (T a)) type T a = Int ``` The `a` in `M f a` would be marked nominal, even though `T a` would simply expand to `Int`. The fix is simple: call `coreView` as appropriate in `markNominal`. This is much like the fix for #14101, but in a different spot. Fixes #20999. - - - - - 18df4013 by Simon Peyton Jones at 2022-01-27T08:22:30-05:00 Define and use restoreLclEnv This fixes #20981. See Note [restoreLclEnv vs setLclEnv] in GHC.Tc.Utils.Monad. I also use updLclEnv rather than get/set when I can, because it's then much clearer that it's an update rather than an entirely new TcLclEnv coming from who-knows-where. - - - - - 31088dd3 by David Feuer at 2022-01-27T08:23:05-05:00 Add test supplied in T20996 which uses data family result kind polymorphism David (@treeowl) writes: > Following @kcsongor, I've used ridiculous data family result kind > polymorphism in `linear-generics`, and am currently working on getting > it into `staged-gg`. If it should be removed, I'd appreciate a heads up, > and I imagine Csongor would too. > > What do I need by ridiculous polymorphic result kinds? Currently, data > families are allowed to have result kinds that end in `Type` (or maybe > `TYPE r`? I'm not sure), but not in concrete data kinds. However, they > *are* allowed to have polymorphic result kinds. This leads to things I > think most of us find at least quite *weird*. For example, I can write > > ```haskell > data family Silly :: k > data SBool :: Bool -> Type where > SFalse :: SBool False > STrue :: SBool True > SSSilly :: SBool Silly > type KnownBool b where > kb :: SBool b > instance KnownBool False where kb = SFalse > instance KnownBool True where kb = STrue > instance KnownBool Silly where kb = Silly > ``` > > Basically, every kind now has potentially infinitely many "legit" inhabitants. > > As horrible as that is, it's rather useful for GHC's current native > generics system. It's possible to use these absurdly polymorphic result > kinds to probe the structure of generic representations in a relatively > pleasant manner. It's a sort of "formal type application" reminiscent of > the notion of a formal power series (see the test case below). I suspect > a system more like `kind-generics` wouldn't need this extra probing > power, but nothing like that is natively available as yet. > > If the ridiculous result kind polymorphism is banished, we'll still be > able to do what we need as long as we have stuck type families. It's > just rather less ergonomical: a stuck type family has to be used with a > concrete marker type argument. Closes #20996 Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 8fd2ac25 by Andreas Abel at 2022-01-27T18:34:54-05:00 Whitespace only - - - - - 7a854743 by Andreas Abel at 2022-01-27T18:34:54-05:00 Ctd. #18087: complete :since: info for all warnings in users guide Some warnings have been there "forever" and I could not trace back the exact genesis, so I wrote "since at least 5.04". The flag `helpful-errors` could have been added in 7.2 already. I wrote 7.4 since I have no 7.2 available and it is not recognized by 7.0. - - - - - f75411e8 by Andreas Abel at 2022-01-27T18:34:54-05:00 Re #18087 user's guide: add a note that -Wxxx used to be -fwarn-xxx The warning option syntax -W was introduced in GHC 8. The note should clarify what e.g. "since 7.6" means in connection with "-Wxxx": That "-fwarn-xxx" was introduced in 7.6.1. [ci skip] - - - - - 3cae7fde by Peter Trommler at 2022-01-27T18:35:30-05:00 testsuite: Fix AtomicPrimops test on big endian - - - - - 6cc6080c by Ben Gamari at 2022-01-27T18:36:05-05:00 users-guide: Document GHC_CHARENC environment variable As noted in #20963, this was introduced in 1b56c40578374a15b4a2593895710c68b0e2a717 but was no documentation was added at that point. Closes #20963. - - - - - ee21e2de by Ben Gamari at 2022-01-27T18:36:41-05:00 rts: Clean up RTS flags usage message Align flag descriptions and acknowledge that some flags may not be available unless the user linked with `-rtsopts` (as noted in #20961). Fixes #20961. - - - - - 7f8ce19e by Simon Peyton Jones at 2022-01-27T18:37:17-05:00 Fix getHasGivenEqs The second component is supposed to be "insoluble equalities arising from givens". But we were getting wanteds too; and that led to an outright duplication of constraints. It's not harmful, but it's not right either. I came across this when debugging something else. Easily fixed. - - - - - f9ef2d26 by Simon Peyton Jones at 2022-01-27T18:37:17-05:00 Set the TcLclEnv when solving a ForAll constraint Fix a simple omission in GHC.Tc.Solver.Canonical.solveForAll, where we ended up with the wrong TcLclEnv captured in an implication. Result: unhelpful error message (#21006) - - - - - bc6ba8ef by Sylvain Henry at 2022-01-28T12:14:41-05:00 Make most shifts branchless - - - - - 62a6d037 by Simon Peyton Jones at 2022-01-28T12:15:17-05:00 Improve boxity in deferAfterPreciseException As #20746 showed, the demand analyser behaved badly in a key I/O library (`GHC.IO.Handle.Text`), by unnessarily boxing and reboxing. This patch adjusts the subtle function deferAfterPreciseException; it's quite easy, just a bit subtle. See the new Note [deferAfterPreciseException] And this MR deals only with Problem 2 in #20746. Problem 1 is still open. - - - - - 42c47cd6 by Ben Gamari at 2022-01-29T02:40:45-05:00 rts/trace: Shrink tracing flags - - - - - cee66e71 by Ben Gamari at 2022-01-29T02:40:45-05:00 rts/EventLog: Mark various internal globals as static - - - - - 6b0cea29 by Ben Gamari at 2022-01-29T02:40:45-05:00 Propagate PythonCmd to make build system - - - - - 2e29edb7 by Ben Gamari at 2022-01-29T02:40:45-05:00 rts: Refactor event types Previously we would build the eventTypes array at runtime during RTS initialization. However, this is completely unnecessary; it is completely static data. - - - - - bb15c347 by Ben Gamari at 2022-01-29T02:40:45-05:00 rts/eventlog: Ensure that flushCount is initialized - - - - - 268efcc9 by Matthew Pickering at 2022-01-29T02:41:21-05:00 Rework the handling of SkolemInfo The main purpose of this patch is to attach a SkolemInfo directly to each SkolemTv. This fixes the large number of bugs which have accumulated over the years where we failed to report errors due to having "no skolem info" for particular type variables. Now the origin of each type varible is stored on the type variable we can always report accurately where it cames from. Fixes #20969 #20732 #20680 #19482 #20232 #19752 #10946 #19760 #20063 #13499 #14040 The main changes of this patch are: * SkolemTv now contains a SkolemInfo field which tells us how the SkolemTv was created. Used when reporting errors. * Enforce invariants relating the SkolemInfoAnon and level of an implication (ic_info, ic_tclvl) to the SkolemInfo and level of the type variables in ic_skols. * All ic_skols are TcTyVars -- Check is currently disabled * All ic_skols are SkolemTv * The tv_lvl of the ic_skols agrees with the ic_tclvl * The ic_info agrees with the SkolInfo of the implication. These invariants are checked by a debug compiler by checkImplicationInvariants. * Completely refactor kcCheckDeclHeader_sig which kept doing my head in. Plus, it wasn't right because it wasn't skolemising the binders as it decomposed the kind signature. The new story is described in Note [kcCheckDeclHeader_sig]. The code is considerably shorter than before (roughly 240 lines turns into 150 lines). It still has the same awkward complexity around computing arity as before, but that is a language design issue. See Note [Arity inference in kcCheckDeclHeader_sig] * I added new type synonyms MonoTcTyCon and PolyTcTyCon, and used them to be clear which TcTyCons have "finished" kinds etc, and which are monomorphic. See Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon] * I renamed etaExpandAlgTyCon to splitTyConKind, becuase that's a better name, and it is very useful in kcCheckDeclHeader_sig, where eta-expansion isn't an issue. * Kill off the nasty `ClassScopedTvEnv` entirely. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 0a1d0944 by Ben Gamari at 2022-01-29T14:52:55-05:00 Drop SPARC NCG - - - - - 313afb3d by Ben Gamari at 2022-01-29T14:52:56-05:00 A few comment cleanups - - - - - d85a527f by Ben Gamari at 2022-01-29T14:52:56-05:00 Rip out SPARC register support - - - - - c6bede69 by Ben Gamari at 2022-01-29T14:52:56-05:00 rts: Rip out SPARC support - - - - - a67c2471 by Ben Gamari at 2022-01-29T14:52:56-05:00 Rip out remaining SPARC support - - - - - 5771b690 by Ben Gamari at 2022-01-29T14:52:56-05:00 CmmToAsm: Drop RegPair SPARC was its last and only user. - - - - - 512ed3f1 by Ben Gamari at 2022-01-29T14:52:56-05:00 CmmToAsm: Make RealReg a newtype Now that RegPair is gone we no longer need to pay for the additional box. - - - - - 88fea6aa by Ben Gamari at 2022-01-29T14:52:56-05:00 rts: Drop redundant #include <Arena.h> - - - - - ea2a4034 by Ben Gamari at 2022-01-29T14:52:56-05:00 CmmToAsm: Drop ncgExpandTop This was only needed for SPARC's synthetic instructions. - - - - - 88fce740 by Ben Gamari at 2022-01-29T14:54:04-05:00 rel-notes: Note dropping of SPARC support - - - - - eb956cf1 by Ben Gamari at 2022-01-30T06:27:19-05:00 testsuite: Force-enable caret diagnostics in T17786 Otherwise GHC realizes that it's not attached to a proper tty and will disable caret diagnostics. - - - - - d07799ab by Ben Gamari at 2022-01-30T06:27:19-05:00 testsuite: Make T7275 more robust against CCid changes The cost-center numbers are somewhat unstable; normalise them out. - - - - - c76c8050 by Ben Gamari at 2022-01-30T06:27:19-05:00 rts: Don't allocate closurePtrs# pointers on C stack Previously `closurePtrs#` would allocate an aray of the size of the closure being decoded on the C stack. This was ripe for overflowing the C stack overflow. This resulted in `T12492` failing on Windows. - - - - - 3af95f7a by Ben Gamari at 2022-01-30T06:27:19-05:00 testsuite/T4029: Don't depend on echo On Windows the `cmd.exe` shell may be used to execute the command, which will print `ECHO is on.` instead of a newline if you give it no argument. Avoid this by rather using `printf`. - - - - - 3531c478 by Ben Gamari at 2022-01-30T06:27:19-05:00 Use PATH_FMT instead of %s to format `pathchar *` A few %s occurrences have snuck in over the past months. - - - - - ee5c4f9d by Zubin Duggal at 2022-01-31T16:51:55+05:30 Improve migration strategy for the XDG compliance change to the GHC application directory. We want to always use the old path (~/.ghc/..) if it exists. But we never want to create the old path. This ensures that the migration can eventually be completed once older GHC versions are no longer in circulation. Fixes #20684, #20669, #20660 - - - - - 60a54a8f by doyougnu at 2022-01-31T18:46:11-05:00 StgToCmm: decouple DynFlags, add StgToCmmConfig StgToCmm: add Config, remove CgInfoDownwards StgToCmm: runC api change to take StgToCmmConfig StgToCmm: CgInfoDownad -> StgToCmmConfig StgToCmm.Monad: update getters/setters/withers StgToCmm: remove CallOpts in StgToCmm.Closure StgToCmm: remove dynflag references StgToCmm: PtrOpts removed StgToCmm: add TMap to config, Prof - dynflags StgToCmm: add omit yields to config StgToCmm.ExtCode: remove redundant import StgToCmm.Heap: remove references to dynflags StgToCmm: codeGen api change, DynFlags -> Config StgToCmm: remove dynflags in Env and StgToCmm StgToCmm.DataCon: remove dynflags references StgToCmm: remove dynflag references in DataCon StgToCmm: add backend avx flags to config StgToCmm.Prim: remove dynflag references StgToCmm.Expr: remove dynflag references StgToCmm.Bind: remove references to dynflags StgToCmm: move DoAlignSanitisation to Cmm.Type StgToCmm: remove PtrOpts in Cmm.Parser.y DynFlags: update ipInitCode api StgToCmm: Config Module is single source of truth StgToCmm: Lazy config breaks IORef deadlock testsuite: bump countdeps threshold StgToCmm.Config: strictify fields except UpdFrame Strictifying UpdFrameOffset causes the RTS build with stage1 to deadlock. Additionally, before the deadlock performance of the RTS is noticeably slower. StgToCmm.Config: add field descriptions StgToCmm: revert strictify on Module in config testsuite: update CountDeps tests StgToCmm: update comment, fix exports Specifically update comment about loopification passed into dynflags then stored into stgToCmmConfig. And remove getDynFlags from Monad.hs exports Types.Name: add pprFullName function StgToCmm.Ticky: use pprFullname, fixup ExtCode imports Cmm.Info: revert cmmGetClosureType removal StgToCmm.Bind: use pprFullName, Config update comments StgToCmm: update closureDescription api StgToCmm: SAT altHeapCheck StgToCmm: default render for Info table, ticky Use default rendering contexts for info table and ticky ticky, which should be independent of command line input. testsuite: bump count deps pprFullName: flag for ticky vs normal style output convertInfoProvMap: remove unused parameter StgToCmm.Config: add backend flags to config StgToCmm.Config: remove Backend from Config StgToCmm.Prim: refactor Backend call sites StgToCmm.Prim: remove redundant imports StgToCmm.Config: refactor vec compatibility check StgToCmm.Config: add allowQuotRem2 flag StgToCmm.Ticky: print internal names with parens StgToCmm.Bind: dispatch ppr based on externality StgToCmm: Add pprTickyname, Fix ticky naming Accidently removed the ctx for ticky SDoc output. The only relevant flag is sdocPprDebug which was accidental set to False due to using defaultSDocContext without altering the flag. StgToCmm: remove stateful fields in config fixup: config: remove redundant imports StgToCmm: move Sequel type to its own module StgToCmm: proliferate getCallMethod updated api StgToCmm.Monad: add FCodeState to Monad Api StgToCmm: add second reader monad to FCode fixup: Prim.hs: missed a merge conflict fixup: Match countDeps tests to HEAD StgToCmm.Monad: withState -> withCgState To disambiguate it from mtl withState. This withState shouldn't be returning the new state as a value. However, fixing this means tackling the knot tying in CgState and so is very difficult since it changes when the thunk of the knot is forced which either leads to deadlock or to compiler panic. - - - - - 58eccdbc by Ben Gamari at 2022-01-31T18:46:47-05:00 codeGen: Fix two buglets in -fbounds-check logic @Bodigrim noticed that the `compareByteArray#` bounds-checking logic had flipped arguments and an off-by-one. For the sake of clarity I also refactored occurrences of `cmmOffset` to rather use `cmmOffsetB`. I suspect the former should be retired. - - - - - 584f03fa by Simon Peyton Jones at 2022-01-31T18:47:23-05:00 Make typechecker trace less strict Fixes #21011 - - - - - 60ac7300 by Elton at 2022-02-01T12:28:49-05:00 Use braces in TH case pprint (fixes #20893) This patch ensures that the pretty printer formats `case` statements using braces (instead of layout) to remain consistent with the formatting of other statements (like `do`) - - - - - fdda93b0 by Elton at 2022-02-01T12:28:49-05:00 Use braces in TH LambdaCase and where clauses This patch ensures that the pretty printer formats LambdaCase and where clauses using braces (instead of layout) to remain consistent with the formatting of other statements (like `do` and `case`) - - - - - 06185102 by Ben Gamari at 2022-02-01T12:29:26-05:00 Consistently upper-case "Note [" This was achieved with git ls-tree --name-only HEAD -r | xargs sed -i -e 's/note \[/Note \[/g' - - - - - 88fba8a4 by Ben Gamari at 2022-02-01T12:29:26-05:00 Fix a few Note inconsistencies - - - - - 05548a22 by Douglas Wilson at 2022-02-02T19:26:06-05:00 rts: Address failures to inline - - - - - 074945de by Simon Peyton Jones at 2022-02-02T19:26:41-05:00 Two small improvements in the Simplifier As #20941 describes, this patch implements a couple of small fixes to the Simplifier. They make a difference principally with -O0, so few people will notice. But with -O0 they can reduce the number of Simplifer iterations. * In occurrence analysis we avoid making x = (a,b) into a loop breaker because we want to be able to inline x, or (more likely) do case-elimination. But HEAD does not treat x = let y = blah in (a,b) in the same way. We should though, because we are going to float that y=blah out of the x-binding. A one-line fix in OccurAnal. * The crucial function exprIsConApp_maybe uses getUnfoldingInRuleMatch (rightly) but the latter was deeply strange. In HEAD, if rule-rewriting was off (-O0) we only looked inside stable unfoldings. Very stupid. The patch simplifies. * I also noticed that in simplStableUnfolding we were failing to delete the DFun binders from the usage. So I added that. Practically zero perf change across the board, except that we get more compiler allocation in T3064 (which is compiled with -O0). There's a good reason: we get better code. But there are lots of other small compiler allocation decreases: Metrics: compile_time/bytes allocated --------------------- Baseline Test Metric value New value Change ----------------------------------------------------------------- PmSeriesG(normal) ghc/alloc 44,260,817 44,184,920 -0.2% PmSeriesS(normal) ghc/alloc 52,967,392 52,891,632 -0.1% PmSeriesT(normal) ghc/alloc 75,498,220 75,421,968 -0.1% PmSeriesV(normal) ghc/alloc 52,341,849 52,265,768 -0.1% T10421(normal) ghc/alloc 109,702,291 109,626,024 -0.1% T10421a(normal) ghc/alloc 76,888,308 76,809,896 -0.1% T10858(normal) ghc/alloc 125,149,038 125,073,648 -0.1% T11276(normal) ghc/alloc 94,159,364 94,081,640 -0.1% T11303b(normal) ghc/alloc 40,230,059 40,154,368 -0.2% T11822(normal) ghc/alloc 107,424,540 107,346,088 -0.1% T12150(optasm) ghc/alloc 76,486,339 76,426,152 -0.1% T12234(optasm) ghc/alloc 55,585,046 55,507,352 -0.1% T12425(optasm) ghc/alloc 88,343,288 88,265,312 -0.1% T13035(normal) ghc/alloc 98,919,768 98,845,600 -0.1% T13253-spj(normal) ghc/alloc 121,002,153 120,851,040 -0.1% T16190(normal) ghc/alloc 290,313,131 290,074,152 -0.1% T16875(normal) ghc/alloc 34,756,121 34,681,440 -0.2% T17836b(normal) ghc/alloc 45,198,100 45,120,288 -0.2% T17977(normal) ghc/alloc 39,479,952 39,404,112 -0.2% T17977b(normal) ghc/alloc 37,213,035 37,137,728 -0.2% T18140(normal) ghc/alloc 79,430,588 79,350,680 -0.1% T18282(normal) ghc/alloc 128,303,182 128,225,384 -0.1% T18304(normal) ghc/alloc 84,904,713 84,831,952 -0.1% T18923(normal) ghc/alloc 66,817,241 66,731,984 -0.1% T20049(normal) ghc/alloc 86,188,024 86,107,920 -0.1% T5837(normal) ghc/alloc 35,540,598 35,464,568 -0.2% T6048(optasm) ghc/alloc 99,812,171 99,736,032 -0.1% T9198(normal) ghc/alloc 46,380,270 46,304,984 -0.2% geo. mean -0.0% Metric Increase: T3064 - - - - - d2cce453 by Morrow at 2022-02-02T19:27:21-05:00 Fix @since annotation on Nat - - - - - 6438fed9 by Simon Peyton Jones at 2022-02-02T19:27:56-05:00 Refactor the escaping kind check for data constructors As #20929 pointed out, we were in-elegantly checking for escaping kinds in `checkValidType`, even though that check was guaranteed to succeed for type signatures -- it's part of kind-checking a type. But for /data constructors/ we kind-check the pieces separately, so we still need the check. This MR is a pure refactor, moving the test from `checkValidType` to `checkValidDataCon`. No new tests; external behaviour doesn't change. - - - - - fb05e5ac by Andreas Klebinger at 2022-02-02T19:28:31-05:00 Replace sndOfTriple with sndOf3 I also cleaned up the imports slightly while I was at it. - - - - - fbc77d3a by Matthew Pickering at 2022-02-02T19:29:07-05:00 testsuite: Honour PERF_BASELINE_COMMIT when computing allowed metric changes We now get all the commits between the PERF_BASELINE_COMMIT and HEAD and check any of them for metric changes. Fixes #20882 - - - - - 0a82ae0d by Simon Peyton Jones at 2022-02-02T23:49:58-05:00 More accurate unboxing This patch implements a fix for #20817. It ensures that * The final strictness signature for a function accurately reflects the unboxing done by the wrapper See Note [Finalising boxity for demand signatures] and Note [Finalising boxity for let-bound Ids] * A much better "layer-at-a-time" implementation of the budget for how many worker arguments we can have See Note [Worker argument budget] Generally this leads to a bit more worker/wrapper generation, because instead of aborting entirely if the budget is exceeded (and then lying about boxity), we unbox a bit. Binary sizes in increase slightly (around 1.8%) because of the increase in worker/wrapper generation. The big effects are to GHC.Ix, GHC.Show, GHC.IO.Handle.Internals. If we did a better job of dropping dead code, this effect might go away. Some nofib perf improvements: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- VSD +1.8% -0.5% 0.017 0.017 0.0% awards +1.8% -0.1% +2.3% +2.3% 0.0% banner +1.7% -0.2% +0.3% +0.3% 0.0% bspt +1.8% -0.1% +3.1% +3.1% 0.0% eliza +1.8% -0.1% +1.2% +1.2% 0.0% expert +1.7% -0.1% +9.6% +9.6% 0.0% fannkuch-redux +1.8% -0.4% -9.3% -9.3% 0.0% kahan +1.8% -0.1% +22.7% +22.7% 0.0% maillist +1.8% -0.9% +21.2% +21.6% 0.0% nucleic2 +1.7% -5.1% +7.5% +7.6% 0.0% pretty +1.8% -0.2% 0.000 0.000 0.0% reverse-complem +1.8% -2.5% +12.2% +12.2% 0.0% rfib +1.8% -0.2% +2.5% +2.5% 0.0% scc +1.8% -0.4% 0.000 0.000 0.0% simple +1.7% -1.3% +17.0% +17.0% +7.4% spectral-norm +1.8% -0.1% +6.8% +6.7% 0.0% sphere +1.7% -2.0% +13.3% +13.3% 0.0% tak +1.8% -0.2% +3.3% +3.3% 0.0% x2n1 +1.8% -0.4% +8.1% +8.1% 0.0% -------------------------------------------------------------------------------- Min +1.1% -5.1% -23.6% -23.6% 0.0% Max +1.8% +0.0% +36.2% +36.2% +7.4% Geometric Mean +1.7% -0.1% +6.8% +6.8% +0.1% Compiler allocations in CI have a geometric mean of +0.1%; many small decreases but there are three bigger increases (7%), all because we do more worker/wrapper than before, so there is simply more code to compile. That's OK. Perf benchmarks in perf/should_run improve in allocation by a geo mean of -0.2%, which is good. None get worse. T12996 improves by -5.8% Metric Decrease: T12996 Metric Increase: T18282 T18923 T9630 - - - - - d1ef6288 by Peter Trommler at 2022-02-02T23:50:34-05:00 Cmm: fix equality of expressions Compare expressions and types when comparing `CmmLoad`s. Fixes #21016 - - - - - e59446c6 by Peter Trommler at 2022-02-02T23:50:34-05:00 Check type first then expression - - - - - b0e1ef4a by Matthew Pickering at 2022-02-03T14:44:17-05:00 Add failing test for #20791 The test produces different output on static vs dynamic GHC builds. - - - - - cae1fb17 by Matthew Pickering at 2022-02-03T14:44:17-05:00 Frontend01 passes with static GHC - - - - - e343526b by Matthew Pickering at 2022-02-03T14:44:17-05:00 Don't initialise plugins when there are no pipelines to run - - - - - abac45fc by Matthew Pickering at 2022-02-03T14:44:17-05:00 Mark prog003 as expected_broken on static way #20704 - - - - - 13300dfd by Matthew Pickering at 2022-02-03T14:44:17-05:00 Filter out -rtsopts in T16219 to make static/dynamic ways agree - - - - - d89439f2 by Matthew Pickering at 2022-02-03T14:44:17-05:00 T13168: Filter out rtsopts for consistency between dynamic and static ways - - - - - 00180cdf by Matthew Pickering at 2022-02-03T14:44:17-05:00 Accept new output for T14335 test This test was previously not run due to #20960 - - - - - 1accdcff by Matthew Pickering at 2022-02-03T14:44:17-05:00 Add flushes to plugin tests which print to stdout Due to #20791 you need to explicitly flush as otherwise the output from these tests doesn't make it to stdout. - - - - - d820f2e8 by Matthew Pickering at 2022-02-03T14:44:17-05:00 Remove ghc_plugin_way Using ghc_plugin_way had the unintended effect of meaning certain tests weren't run at all when ghc_dynamic=true, if you delete this modifier then the tests work in both the static and dynamic cases. - - - - - aa5ef340 by Matthew Pickering at 2022-02-03T14:44:17-05:00 Unbreak T13168 on windows Fixes #14276 - - - - - 84ab0153 by Matthew Pickering at 2022-02-03T14:44:53-05:00 Rewrite CallerCC parser using ReadP This allows us to remove the dependency on parsec and hence transitively on text. Also added some simple unit tests for the parser and fixed two small issues in the documentation. Fixes #21033 - - - - - 4e6780bb by Matthew Pickering at 2022-02-03T14:45:28-05:00 ci: Add debian 11 jobs (validate/release/nightly) Fixes #21002 - - - - - eddaa591 by Ben Gamari at 2022-02-04T10:01:59-05:00 compiler: Introduce and use RoughMap for instance environments Here we introduce a new data structure, RoughMap, inspired by the previous `RoughTc` matching mechanism for checking instance matches. This allows [Fam]InstEnv to be implemented as a trie indexed by these RoughTc signatures, reducing the complexity of instance lookup and FamInstEnv merging (done during the family instance conflict test) from O(n) to O(log n). The critical performance improvement currently realised by this patch is in instance matching. In particular the RoughMap mechanism allows us to discount many potential instances which will never match for constraints involving type variables (see Note [Matching a RoughMap]). In realistic code bases matchInstEnv was accounting for 50% of typechecker time due to redundant work checking instances when simplifying instance contexts when deriving instances. With this patch the cost is significantly reduced. The larger constants in InstEnv creation do mean that a few small tests regress in allocations slightly. However, the runtime of T19703 is reduced by a factor of 4. Moreover, the compilation time of the Cabal library is slightly improved. A couple of test cases are included which demonstrate significant improvements in compile time with this patch. This unfortunately does not fix the testcase provided in #19703 but does fix #20933 ------------------------- Metric Decrease: T12425 Metric Increase: T13719 T9872a T9872d hard_hole_fits ------------------------- Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 62d670eb by Matthew Pickering at 2022-02-04T10:02:35-05:00 testsuite: Run testsuite dependency calculation before GHC is built The main motivation for this patch is to allow tests to be added to the testsuite which test things about the source tree without needing to build GHC. In particular the notes linter can easily start failing and by integrating it into the testsuite the process of observing these changes is caught by normal validation procedures rather than having to run the linter specially. With this patch I can run ``` ./hadrian/build test --flavour=devel2 --only="uniques" ``` In a clean tree to run the checkUniques linter without having to build GHC. Fixes #21029 - - - - - 4bd52410 by Hécate Moonlight at 2022-02-04T16:14:10-05:00 Add the Ix class to Foreign C integral types Related CLC proposal is here: https://github.com/haskell/core-libraries-committee/issues/30 - - - - - de6d7692 by Ben Gamari at 2022-02-04T16:14:47-05:00 Drop dead code - - - - - b79206f1 by Ben Gamari at 2022-02-04T16:14:47-05:00 Add comments - - - - - 58d7faac by Ben Gamari at 2022-02-04T16:14:47-05:00 cmm: Introduce cmmLoadBWord and cmmLoadGCWord - - - - - 7217156c by Ben Gamari at 2022-02-04T16:14:47-05:00 Introduce alignment in CmmLoad - - - - - 99ea5f2c by Ben Gamari at 2022-02-04T16:14:47-05:00 Introduce alignment to CmmStore - - - - - 606b59a5 by Ben Gamari at 2022-02-04T16:14:47-05:00 Fix array primop alignment - - - - - 1cf9616a by Ben Gamari at 2022-02-04T16:14:47-05:00 llvmGen: Handle unaligned loads/stores This allows us to produce valid code for indexWord8ArrayAs*# on platforms that lack unaligned memory access. - - - - - 8c18feba by Ben Gamari at 2022-02-04T16:14:47-05:00 primops: Fix documentation of setByteArray# Previously the documentation was subtly incorrect regarding the bounds of the operation. Fix this and add a test asserting that a zero-length operation is in fact a no-op. - - - - - 88480e55 by nineonine at 2022-02-04T20:35:45-05:00 Fix unsound behavior of unlifted datatypes in ghci (#20194) Previously, directly calling a function that pattern matches on an unlifted data type which has at least two constructors in GHCi resulted in a segfault. This happened due to unaccounted return frame info table pointer. The fix is to pop the above mentioned frame info table pointer when unlifted things are returned. See Note [Popping return frame for unlifted things] authors: bgamari, nineonine - - - - - a5c7068c by Simon Peyton Jones at 2022-02-04T20:36:20-05:00 Add Outputable instance for Messages c.f. #20980 - - - - - bf495f72 by Simon Peyton Jones at 2022-02-04T20:36:20-05:00 Add a missing restoreLclEnv The commit commit 18df4013f6eaee0e1de8ebd533f7e96c4ee0ff04 Date: Sat Jan 22 01:12:30 2022 +0000 Define and use restoreLclEnv omitted to change one setLclEnv to restoreLclEnv, namely the one in GHC.Tc.Errors.warnRedundantConstraints. This new commit fixes the omission. - - - - - 6af8e71e by Simon Peyton Jones at 2022-02-04T20:36:20-05:00 Improve errors for non-existent labels This patch fixes #17469, by improving matters when you use non-existent field names in a record construction: data T = MkT { x :: Int } f v = MkT { y = 3 } The check is now made in the renamer, in GHC.Rename.Env.lookupRecFieldOcc. That in turn led to a spurious error in T9975a, which is fixed by making GHC.Rename.Names.extendGlobalRdrEnvRn fail fast if it finds duplicate bindings. See Note [Fail fast on duplicate definitions] in that module for more details. This patch was originated and worked on by Alex D (@nineonine) - - - - - 299acff0 by nineonine at 2022-02-05T19:21:49-05:00 Exit with failure when -e fails (fixes #18411 #9916 #17560) - - - - - 549292eb by Matthew Pickering at 2022-02-05T19:22:25-05:00 Make implication tidying agree with Note [Tidying multiple names at once] Note [Tidying multiple names at once] indicates that if multiple variables have the same name then we shouldn't prioritise one of them and instead rename them all to a1, a2, a3... etc This patch implements that change, some error message changes as expected. Closes #20932 - - - - - 2e9248b7 by Ben Gamari at 2022-02-06T01:43:56-05:00 rts/m32: Accept any address within 4GB of program text Previously m32 would assume that the program image was located near the start of the address space and therefore assume that it wanted pages in the bottom 4GB of address space. Instead we now check whether they are within 4GB of whereever the program is loaded. This is necessary on Windows, which now tends to place the image in high memory. The eventual goal is to use m32 to allocate memory for linker sections on Windows. - - - - - 86589b89 by GHC GitLab CI at 2022-02-06T01:43:56-05:00 rts: Generalize mmapForLinkerMarkExecutable Renamed to mprotectForLinker and allowed setting of arbitrary protection modes. - - - - - 88ef270a by GHC GitLab CI at 2022-02-06T01:43:56-05:00 rts/m32: Add consistency-checking infrastructure This adds logic, enabled in the `-debug` RTS for checking the internal consistency of the m32 allocator. This area has always made me a bit nervous so this should help me sleep better at night in exchange for very little overhead. - - - - - 2d6f0b17 by Ben Gamari at 2022-02-06T01:43:56-05:00 rts/m32: Free large objects back to the free page pool Not entirely convinced that this is worth doing. - - - - - e96f50be by GHC GitLab CI at 2022-02-06T01:43:56-05:00 rts/m32: Increase size of free page pool to 256 pages - - - - - fc083b48 by Ben Gamari at 2022-02-06T01:43:56-05:00 rts: Dump memory map on memory mapping failures Fixes #20992. - - - - - 633296bc by Ben Gamari at 2022-02-06T01:43:56-05:00 Fix macro redefinition warnings for PRINTF * Move `PRINTF` macro from `Stats.h` to `Stats.c` as it's only needed in the latter. * Undefine `PRINTF` at the end of `Messages.h` to avoid leaking it. - - - - - 37d435d2 by John Ericson at 2022-02-06T01:44:32-05:00 Purge DynFlags from GHC.Stg Also derive some more instances. GHC doesn't need them, but downstream consumers may need to e.g. put stuff in maps. - - - - - 886baa34 by Peter Trommler at 2022-02-06T10:58:18+01:00 RTS: Fix cabal specification In 35bea01b xxhash.c was removed. Remove the extra-source-files stanza referring to it. - - - - - 27581d77 by Alex D at 2022-02-06T20:50:44-05:00 hadrian: remove redundant import - - - - - 4ff19981 by John Ericson at 2022-02-07T11:04:43-05:00 GHC.HsToCore.Coverage: No more HscEnv, less DynFlags Progress towards #20730 - - - - - b09389a6 by John Ericson at 2022-02-07T11:04:43-05:00 Create `CoverageConfig` As requested by @mpickering to collect the information we project from `HscEnv` - - - - - ff867c46 by Greg Steuck at 2022-02-07T11:05:24-05:00 Avoid using removed utils/checkUniques in validate Asked the question: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7460/diffs#4061f4d17546e239dd10d78c6b48668c2a288e02_1_0 - - - - - a9355e84 by sheaf at 2022-02-08T05:27:25-05:00 Allow HasField in quantified constraints We perform validity checking on user-written HasField instances, for example to disallow: data Foo a = Foo { fld :: Int } instance HasField "fld" (Foo a) Bool However, these checks were also being made on quantified constraints, e.g. data Bar where Bar :: (forall a. HasField s (Foo a) Int) => Proxy s -> Bar This patch simply skips validity checking for quantified constraints, in line with what we already do for equality constraints such as Coercible. Fixes #20989 - - - - - 6d77d3d8 by sheaf at 2022-02-08T05:28:05-05:00 Relax TyEq:N: allow out-of-scope newtype DataCon The 'bad_newtype' assertion in GHC.Tc.Solver.Canonical.canEqCanLHSFinish failed to account for the possibility that the newtype constructor might not be in scope, in which case we don't provide any guarantees about canonicalising away a newtype on the RHS of a representational equality. Fixes #21010 - - - - - a893d2f3 by Matthew Pickering at 2022-02-08T05:28:42-05:00 Remove linter dependency on lint-submods - - - - - 457a5b9c by Ben Gamari at 2022-02-08T05:28:42-05:00 notes-util: initial commit - - - - - 1a943859 by Ben Gamari at 2022-02-08T05:28:42-05:00 gitlab-ci: Add lint-notes job - - - - - bc5cbce6 by Matthew Pickering at 2022-02-08T05:28:42-05:00 Add notes linter to testsuite - - - - - 38c6e301 by Matthew Pickering at 2022-02-08T05:28:42-05:00 Fix some notes - - - - - c3aac0f8 by Matthew Pickering at 2022-02-08T05:28:42-05:00 Add suggestion mode to notes-util - - - - - 5dd29aea by Cale Gibbard at 2022-02-08T05:29:18-05:00 `hscSimpleIface` drop fingerprint param and ret `hscSimpleIface` does not depend on or modify the `Maybe Fingerprint` it is given, only passes it through, so get rid of the extraneous passing. Perhaps the intent was that there would be an iface fingerprint check of some sort? but this was never done. If/when we we want to do that, we can add it back then. - - - - - 4bcbd731 by Cale Gibbard at 2022-02-08T05:29:54-05:00 Document `hscIncrementalFrontend` and flip bool - - - - - b713db1e by John Ericson at 2022-02-08T05:30:29-05:00 StgToCmm: Get rid of GHC.Driver.Session imports `DynFlags` is gone, but let's move a few trivial things around to get rid of its module too. - - - - - f115c382 by Gleb Popov at 2022-02-08T05:31:05-05:00 Fix build on recent FreeBSD. Recent FreeBSD versions gained the sched_getaffinity function, which made two mutually exclusive #ifdef blocks to be enabled. - - - - - 3320ab40 by Ben Gamari at 2022-02-08T10:42:04-05:00 rts/MemoryMap: Use mach_-prefixed type names There appears to be some inconsistency in system-call type naming across Darwin toolchains. Specifically: * the `address` argument to `mach_vm_region` apparently wants to be a `mach_vm_address_t *`, not a `vm_address_t *` * the `vmsize` argument to `mach_vm_region` wants to be a `mach_vm_size_t`, not a `vm_size_t` - - - - - b33f0cfa by Richard Eisenberg at 2022-02-08T10:42:41-05:00 Document that reifyRoles includes kind parameters Close #21056 - - - - - bd493ed6 by PHO at 2022-02-08T10:43:19-05:00 Don't try to build stage1 with -eventlog if stage0 doesn't provide it Like -threaded, stage0 isn't guaranteed to have an event-logging RTS. - - - - - 03c2de0f by Matthew Pickering at 2022-02-09T03:56:22-05:00 testsuite: Use absolute paths for config.libdir Fixes #21052 - - - - - ef294525 by Matthew Pickering at 2022-02-09T03:56:22-05:00 testsuite: Clean up old/redundant predicates - - - - - a39ed908 by Matthew Pickering at 2022-02-09T03:56:22-05:00 testsuite: Add missing dependency on ghcconfig - - - - - a172be07 by PHO at 2022-02-09T03:56:59-05:00 Implement System.Environment.getExecutablePath for NetBSD and also use it from GHC.BaseDir.getBaseDir - - - - - 62fa126d by PHO at 2022-02-09T03:57:37-05:00 Fix a portability issue in m4/find_llvm_prog.m4 `test A == B' is a Bash extension, which doesn't work on platforms where /bin/sh is not Bash. - - - - - fd9981e3 by Ryan Scott at 2022-02-09T03:58:13-05:00 Look through untyped TH splices in tcInferAppHead_maybe Previously, surrounding a head expression with a TH splice would defeat `tcInferAppHead_maybe`, preventing some expressions from typechecking that used to typecheck in previous GHC versions (see #21038 for examples). This is simple enough to fix: just look through `HsSpliceE`s in `tcInferAppHead_maybe`. I've added some additional prose to `Note [Application chains and heads]` in `GHC.Tc.Gen.App` to accompany this change. Fixes #21038. - - - - - 00975981 by sheaf at 2022-02-09T03:58:53-05:00 Add test for #21037 This program was rejected by GHC 9.2, but is accepted on newer versions of GHC. This patch adds a regression test. Closes #21037 - - - - - fad0b2b0 by Ben Gamari at 2022-02-09T08:29:46-05:00 Rename -merge-objs flag to --merge-objs For consistency with --make and friends. - - - - - 1dbe5b2a by Matthew Pickering at 2022-02-09T08:30:22-05:00 driver: Filter out our own boot module in hptSomeThingsBelow hptSomeThingsBelow would return a list of modules which contain the .hs-boot file for a particular module. This caused some problems because we would try and find the module in the HPT (but it's not there when we're compiling the module itself). Fixes #21058 - - - - - 2b1cced1 by Sylvain Henry at 2022-02-09T20:42:23-05:00 NCG: minor code factorization - - - - - e01ffec2 by Sylvain Henry at 2022-02-09T20:42:23-05:00 ByteCode: avoid out-of-bound read Cf https://gitlab.haskell.org/ghc/ghc/-/issues/18431#note_287139 - - - - - 53c26e79 by Ziyang Liu at 2022-02-09T20:43:02-05:00 Include ru_name in toHsRule message See #18147 - - - - - 3df06922 by Ben Gamari at 2022-02-09T20:43:39-05:00 rts: Rename MemoryMap.[ch] -> ReportMemoryMap.[ch] - - - - - e219ac82 by Ben Gamari at 2022-02-09T20:43:39-05:00 rts: Move mmapForLinker and friends to linker/MMap.c They are not particularly related to linking. - - - - - 30e205ca by Ben Gamari at 2022-02-09T20:43:39-05:00 rts/linker: Drop dead IA64 code - - - - - 4d3a306d by Ben Gamari at 2022-02-09T20:43:39-05:00 rts/linker/MMap: Use MemoryAccess in mmapForLinker - - - - - 1db4f1fe by Ben Gamari at 2022-02-09T20:43:39-05:00 linker: Don't use MAP_FIXED As noted in #21057, we really shouldn't be using MAP_FIXED. I would much rather have the process crash with a "failed to map" error than randomly overwrite existing mappings. Closes #21057. - - - - - 1eeae25c by Ben Gamari at 2022-02-09T20:43:39-05:00 rts/mmap: Refactor mmapForLinker Here we try to separate the policy decisions of where to place mappings from the mechanism of creating the mappings. This makes things significantly easier to follow. - - - - - ac2d18a7 by sheaf at 2022-02-09T20:44:18-05:00 Add some perf tests for coercions This patch adds some performance tests for programs that create large coercions. This is useful because the existing test coverage is not very representative of real-world situations. In particular, this adds a test involving an extensible records library, a common pain-point for users. - - - - - 48f25715 by Andreas Klebinger at 2022-02-10T04:35:35-05:00 Add late cost centre support This allows cost centres to be inserted after the core optimization pipeline has run. - - - - - 0ff70427 by Andreas Klebinger at 2022-02-10T04:36:11-05:00 Docs:Mention that safe calls don't keep their arguments alive. - - - - - 1d3ed168 by Ben Gamari at 2022-02-10T04:36:46-05:00 PEi386: Drop Windows Vista fallback in addLibrarySearchPath We no longer support Windows Vista. - - - - - 2a6f2681 by Ben Gamari at 2022-02-10T04:36:46-05:00 linker/PEi386: Make addLibrarySearchPath long-path aware Previously `addLibrarySearchPath` failed to normalise the added path to UNC form before passing it to `AddDllDirectory`. Consequently, the call was subject to the MAX_PATH restriction, leading to the failure of `test-defaulting-plugin-fail`, among others. Happily, this also nicely simplifies the implementation. Closes #21059. - - - - - 2a47ee9c by Daniel Gröber at 2022-02-10T19:18:58-05:00 ghc-boot: Simplify writePackageDb permissions handling Commit ef8a3fbf1 ("ghc-boot: Fix metadata handling of writeFileAtomic") introduced a somewhat over-engineered fix for #14017 by trying to preserve the current permissions if the target file already exists. The problem in the issue is simply that the package db cache file should be world readable but isn't if umask is too restrictive. In fact the previous fix only handles part of this problem. If the file isn't already there in a readable configuration it wont make it so which isn't really ideal either. Rather than all that we now simply always force all the read access bits to allow access while leaving the owner at the system default as it's just not our business to mess with it. - - - - - a1d97968 by Ben Gamari at 2022-02-10T19:19:34-05:00 Bump Cabal submodule Adapts GHC to the factoring-out of `Cabal-syntax`. Fixes #20991. Metric Decrease: haddock.Cabal - - - - - 89cf8caa by Morrow at 2022-02-10T19:20:13-05:00 Add metadata to integer-gmp.cabal - - - - - c995b7e7 by Matthew Pickering at 2022-02-10T19:20:48-05:00 eventlog: Fix event type of EVENT_IPE This leads to corrupted eventlogs because the size of EVENT_IPE is completely wrong. Fixes a bug introduced in 2e29edb7421c21902b47d130d45f60d3f584a0de - - - - - 59ba8fb3 by Matthew Pickering at 2022-02-10T19:20:48-05:00 eventlog: Fix event type of MEM_RETURN This leads to corrupted eventlogs because the size of EVENT_MEM_RETURN is completely wrong. Fixes a bug introduced in 2e29edb7421c21902b47d130d45f60d3f584a0de - - - - - 19413d09 by Matthew Pickering at 2022-02-10T19:20:48-05:00 eventlog: Delete misleading comment in gen_event_types.py Not all events start with CapNo and there's not logic I could see which adds this to the length. - - - - - e06f49c0 by Matthew Pickering at 2022-02-10T19:20:48-05:00 eventlog: Fix size of TICKY_COUNTER_BEGIN_SAMPLE - - - - - 2f99255b by Matthew Pickering at 2022-02-10T19:21:24-05:00 Fix copy-pasto in prof-late-ccs docs - - - - - 19deb002 by Matthew Pickering at 2022-02-10T19:21:59-05:00 Refine tcSemigroupWarnings to work in ghc-prim ghc-prim doesn't depend on base so can't have any Monoid or Semigroup instances. However, attempting to load these definitions ran into issues when the interface for `GHC.Base` did exist as that would try and load the interface for `GHC.Types` (which is the module we are trying to compile and has no interface). The fix is to just not do this check when we are compiling a module in ghc-prim. Fixes #21069 - - - - - 34dec6b7 by sheaf at 2022-02-11T17:55:34-05:00 Decrease the size of the LargeRecord test This test was taking too long to run, so this patch makes it smaller. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 9cab90d9 by Matthew Pickering at 2022-02-11T22:27:19-05:00 Make sure all platforms have a release job The release bindists are currently a mixture of validate and release builds. This is bad because the validate builds don't have profiling libraries. The fix is to make sure there is a release job for each platform we want to produce a release for.t Fixes #21066 - - - - - 4bce3575 by Matthew Pickering at 2022-02-11T22:27:54-05:00 testsuite: Make sure all tests trigger ghc rebuild I made a mistake when implementing #21029 which meant that certain tests didn't trigger a GHC recompilation. By adding the `test:ghc` target to the default settings all tests will now depend on this target unless explicitly opting out via the no_deps modifier. - - - - - 90a26f8b by Sylvain Henry at 2022-02-11T22:28:34-05:00 Fix documentation about Word64Rep/Int64Rep (#16964) - - - - - 0e93023e by Andreas Klebinger at 2022-02-12T13:59:41+00:00 Tag inference work. This does three major things: * Enforce the invariant that all strict fields must contain tagged pointers. * Try to predict the tag on bindings in order to omit tag checks. * Allows functions to pass arguments unlifted (call-by-value). The former is "simply" achieved by wrapping any constructor allocations with a case which will evaluate the respective strict bindings. The prediction is done by a new data flow analysis based on the STG representation of a program. This also helps us to avoid generating redudant cases for the above invariant. StrictWorkers are created by W/W directly and SpecConstr indirectly. See the Note [Strict Worker Ids] Other minor changes: * Add StgUtil module containing a few functions needed by, but not specific to the tag analysis. ------------------------- Metric Decrease: T12545 T18698b T18140 T18923 LargeRecord Metric Increase: LargeRecord ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13253-spj T13379 T15164 T18282 T18304 T18698a T1969 T20049 T3294 T4801 T5321FD T5321Fun T783 T9233 T9675 T9961 T19695 WWRec ------------------------- - - - - - 744f8a11 by Greg Steuck at 2022-02-12T17:13:55-05:00 Only check the exit code in derefnull & divbyzero tests on OpenBSD - - - - - eeead9fc by Ben Gamari at 2022-02-13T03:26:14-05:00 rts/Adjustor: Ensure that allocateExecPage succeeded Previously we failed to handle the case that `allocateExecPage` failed. - - - - - afdfaff0 by Ben Gamari at 2022-02-13T03:26:14-05:00 rts: Drop DEC Alpha adjustor implementation The last Alpha chip was produced in 2004. - - - - - 191dfd2d by Ben Gamari at 2022-02-13T03:26:14-05:00 rts/adjustor: Split Windows path out of NativeAmd64 - - - - - be591e27 by Ben Gamari at 2022-02-13T03:26:14-05:00 rts: Initial commit of AdjustorPool - - - - - d6d48b16 by Ben Gamari at 2022-02-13T03:26:14-05:00 Introduce initAdjustors - - - - - eab37902 by Ben Gamari at 2022-02-13T03:26:14-05:00 adjustors/NativeAmd64: Use AdjustorPool - - - - - 974e73af by Ben Gamari at 2022-02-13T03:26:14-05:00 adjustors/NativeAmd64Mingw: Use AdjustorPool - - - - - 95fab83f by Ben Gamari at 2022-02-13T03:26:14-05:00 configure: Fix result reporting of adjustors method check - - - - - ef5cf55d by nikshalark at 2022-02-13T03:26:16-05:00 (#21044) Documented arithmetic functions in base. Didn't get it right the ninth time. Now everything's formatted correctly. - - - - - acb482cc by Takenobu Tani at 2022-02-16T05:27:17-05:00 Relax load_load_barrier for aarch64 This patch relaxes the instruction for load_load_barrier(). Current load_load_barrier() implements full-barrier with `dmb sy`. It's too strong to order load-load instructions. We can relax it by using `dmb ld`. If current load_load_barrier() is used for full-barriers (load/store - load/store barrier), this patch is not suitable. See also linux-kernel's smp_rmb() implementation: https://github.com/torvalds/linux/blob/v5.14/arch/arm64/include/asm/barrier.h#L90 Hopefully, it's better to use `dmb ishld` rather than `dmb ld` to improve performance. However, I can't validate effects on a real many-core Arm machine. - - - - - 84eaa26f by Oleg Grenrus at 2022-02-16T05:27:56-05:00 Add test for #20562 - - - - - 2c28620d by Adam Sandberg Ericsson at 2022-02-16T05:28:32-05:00 rts: remove struct StgRetry, it is never used - - - - - 74bf9bb5 by Adam Sandberg Ericsson at 2022-02-16T05:28:32-05:00 rts: document some closure types - - - - - 316312ec by nineonine at 2022-02-16T05:29:08-05:00 ghci: fix -ddump-stg-cg (#21052) The pre-codegen Stg AST dump was not available in ghci because it was performed in 'doCodeGen'. This was now moved to 'coreToStg' area. - - - - - a6411d74 by Adam Sandberg Ericsson at 2022-02-16T05:29:43-05:00 docs: mention -fprof-late-ccs in the release notes And note which compiler version it was added in. - - - - - 4127e86d by Adam Sandberg Ericsson at 2022-02-16T05:29:43-05:00 docs: fix release notes formatting - - - - - 4e6c8019 by Matthew Pickering at 2022-02-17T05:25:28-05:00 Always define __GLASGOW_HASKELL_PATCHLEVEL1/2__ macros As #21076 reports if you are using `-Wcpp-undef` then you get warnings when using the `MIN_VERSION_GLASGOW_HASKELL` macro because __GLASGOW_HASKELL_PATCHLEVEL2__ is very rarely explicitliy set (as version numbers are not 4 components long). This macro was introduced in 3549c952b535803270872adaf87262f2df0295a4 and it seems the bug has existed ever since. Fixes #21076 - - - - - 67dd5724 by Ben Gamari at 2022-02-17T05:26:03-05:00 rts/AdjustorPool: Silence unused function warning bitmap_get is only used in the DEBUG RTS configuration. Fixes #21079. - - - - - 4b04f7e1 by Zubin Duggal at 2022-02-20T13:56:15-05:00 Track object file dependencies for TH accurately (#20604) `hscCompileCoreExprHook` is changed to return a list of `Module`s required by a splice. These modules are accumulated in the TcGblEnv (tcg_th_needed_mods). Dependencies on the object files of these modules are recording in the interface. The data structures in `LoaderState` are replaced with more efficient versions to keep track of all the information required. The MultiLayerModulesTH_Make allocations increase slightly but runtime is faster. Fixes #20604 ------------------------- Metric Increase: MultiLayerModulesTH_Make ------------------------- - - - - - 92ab3ff2 by sheaf at 2022-02-20T13:56:55-05:00 Use diagnostics for "missing signature" errors This patch makes the "missing signature" errors from "GHC.Rename.Names" use the diagnostic infrastructure. This encompasses missing type signatures for top-level bindings and pattern synonyms, as well as missing kind signatures for type constructors. This patch also renames TcReportMsg to TcSolverReportMsg, and adds a few convenience functions to compute whether such a TcSolverReportMsg is an expected/actual message. - - - - - 845284a5 by sheaf at 2022-02-20T13:57:34-05:00 Generically: remove redundant Semigroup constraint This patch removes a redundant Semigroup constraint on the Monoid instance for Generically. This constraint can cause trouble when one wants to derive a Monoid instance via Generically through a type that doesn't itself have a Semigroup instance, for example: data Point2D a = Point2D !a !a newtype Vector2D a = Vector2D { tip :: Point2D a } deriving ( Semigroup, Monoid ) via Generically ( Point2D ( Sum a ) ) In this case, we should not require there to be an instance Semigroup ( Point2D ( Sum a ) ) as all we need is an instance for the generic representation of Point2D ( Sum a ), i.e. Semigroup ( Rep ( Point2D ( Sum a) ) () ). - - - - - 6b468f7f by Ben Gamari at 2022-02-20T13:58:10-05:00 Bump time submodule to 1.12.1 - - - - - 2f0ceecc by Zubin Duggal at 2022-02-20T19:06:19+00:00 hadrian: detect if 'main' is not a haskell file and add it to appropriate list of sources - - - - - 7ce1b694 by Zubin Duggal at 2022-02-21T11:18:58+00:00 Reinstallable GHC This patch allows ghc and its dependencies to be built using a normal invocation of cabal-install. Each componenent which relied on generated files or additional configuration now has a Setup.hs file. There are also various fixes to the cabal files to satisfy cabal-install. There is a new hadrian command which will build a stage2 compiler and then a stage3 compiler by using cabal. ``` ./hadrian/build build-cabal ``` There is also a new CI job which tests running this command. For the 9.4 release we will upload all the dependent executables to hackage and then end users will be free to build GHC and GHC executables via cabal. There are still some unresolved questions about how to ensure soundness when loading plugins into a reinstalled GHC (#20742) which will be tighted up in due course. Fixes #19896 - - - - - 78fbc3a3 by Matthew Pickering at 2022-02-21T15:14:28-05:00 hadrian: Enable late-ccs when building profiled_ghc - - - - - 2b890c89 by Matthew Pickering at 2022-02-22T15:59:33-05:00 testsuite: Don't print names of all fragile tests on all runs This information about fragile tests is pretty useless but annoying on CI where you have to scroll up a long way to see the actual issues. - - - - - 0b36801f by sheaf at 2022-02-22T16:00:14-05:00 Forbid standalone instances for built-in classes `check_special_inst_head` includes logic that disallows hand-written instances for built-in classes such as Typeable, KnownNat and KnownSymbol. However, it also allowed standalone deriving declarations. This was because we do want to allow standalone deriving instances with Typeable as they are harmless, but we certainly don't want to allow instances for e.g. KnownNat. This patch ensures that we don't allow derived instances for KnownNat, KnownSymbol (and also KnownChar, which was previously omitted entirely). Fixes #21087 - - - - - ace66dec by Krzysztof Gogolewski at 2022-02-22T16:30:59-05:00 Remove -Wunticked-promoted-constructors from -Wall Update manual; explain ticks as optional disambiguation rather than the preferred default. This is a part of #20531. - - - - - 558c7d55 by Hugo at 2022-02-22T16:31:01-05:00 docs: fix error in annotation guide code snippet - - - - - a599abba by Richard Eisenberg at 2022-02-23T08:16:07-05:00 Kill derived constraints Co-authored by: Sam Derbyshire Previously, GHC had three flavours of constraint: Wanted, Given, and Derived. This removes Derived constraints. Though serving a number of purposes, the most important role of Derived constraints was to enable better error messages. This job has been taken over by the new RewriterSets, as explained in Note [Wanteds rewrite wanteds] in GHC.Tc.Types.Constraint. Other knock-on effects: - Various new Notes as I learned about under-described bits of GHC - A reshuffling around the AST for implicit-parameter bindings, with better integration with TTG. - Various improvements around fundeps. These were caused by the fact that, previously, fundep constraints were all Derived, and Derived constraints would get dropped. Thus, an unsolved Derived didn't stop compilation. Without Derived, this is no longer possible, and so we have to be considerably more careful around fundeps. - A nice little refactoring in GHC.Tc.Errors to center the work on a new datatype called ErrorItem. Constraints are converted into ErrorItems at the start of processing, and this allows for a little preprocessing before the main classification. - This commit also cleans up the behavior in generalisation around functional dependencies. Now, if a variable is determined by functional dependencies, it will not be quantified. This change is user facing, but it should trim down GHC's strange behavior around fundeps. - Previously, reportWanteds did quite a bit of work, even on an empty WantedConstraints. This commit adds a fast path. - Now, GHC will unconditionally re-simplify constraints during quantification. See Note [Unconditionally resimplify constraints when quantifying], in GHC.Tc.Solver. Close #18398. Close #18406. Solve the fundep-related non-confluence in #18851. Close #19131. Close #19137. Close #20922. Close #20668. Close #19665. ------------------------- Metric Decrease: LargeRecord T9872b T9872b_defer T9872d TcPlugin_RewritePerf ------------------------- - - - - - 2ed22ba1 by Matthew Pickering at 2022-02-23T08:16:43-05:00 Introduce predicate for when to enable source notes (needSourceNotes) There were situations where we were using debugLevel == 0 as a proxy for whether to retain source notes but -finfo-table-map also enables and needs source notes so we should act consistently in both cases. Ticket #20847 - - - - - 37deb893 by Matthew Pickering at 2022-02-23T08:16:43-05:00 Use SrcSpan from the binder as initial source estimate There are some situations where we end up with no source notes in useful positions in an expression. In this case we currently fail to provide any source information about where an expression came from. This patch improves the initial estimate by using the position from the top-binder as the guess for the location of the whole inner expression. It provides quite a course estimate but it's better than nothing. Ticket #20847 - - - - - 59b7f764 by Cheng Shao at 2022-02-23T08:17:24-05:00 Don't emit foreign exports initialiser code for empty CAF list - - - - - c7f32f76 by John Ericson at 2022-02-23T13:58:36-05:00 Prepare rechecking logic for new type in a few ways Combine `MustCompile and `NeedsCompile` into a single case. `CompileReason` is put inside to destinguish the two. This makes a number of things easier. `Semigroup RecompileRequired` is no longer used, to make sure we skip doing work where possible. `recompThen` is very similar, but helps remember. `checkList` is rewritten with `recompThen`. - - - - - e60d8df8 by John Ericson at 2022-02-23T13:58:36-05:00 Introduce `MaybeValidated` type to remove invalid states The old return type `(RecompRequired, Maybe _)`, was confusing because it was inhabited by values like `(UpToDate, Nothing)` that made no sense. The new type ensures: - you must provide a value if it is up to date. - you must provide a reason if you don't provide a value. it is used as the return value of: - `checkOldIface` - `checkByteCode` - `checkObjects` - - - - - f07b13e3 by Sylvain Henry at 2022-02-23T13:59:23-05:00 NCG: refactor X86 codegen Preliminary work done to make working on #5444 easier. Mostly make make control-flow easier to follow: * renamed genCCall into genForeignCall * split genForeignCall into the part dispatching on PrimTarget (genPrim) and the one really generating code for a C call (cf ForeignTarget and genCCall) * made genPrim/genSimplePrim only dispatch on MachOp: each MachOp now has its own code generation function. * out-of-line primops are not handled in a partial `outOfLineCmmOp` anymore but in the code generation functions directly. Helper functions have been introduced (e.g. genLibCCall) for code sharing. * the latter two bullets make code generated for primops that are only sometimes out-of-line (e.g. Pdep or Memcpy) and the logic to select between inline/out-of-line much more localized * avoided passing is32bit as an argument as we can easily get it from NatM state when we really need it * changed genCCall type to avoid it being partial (it can't handle PrimTarget) * globally removed 12 calls to `panic` thanks to better control flow and types ("parse, don't validate" ftw!). - - - - - 6fa7591e by Sylvain Henry at 2022-02-23T13:59:23-05:00 NCG: refactor the way registers are handled * add getLocalRegReg to avoid allocating a CmmLocal just to call getRegisterReg * 64-bit registers: in the general case we must always use the virtual higher part of the register, so we might as well always return it with the lower part. The only exception is to implement 64-bit to 32-bit conversions. We now have to explicitly discard the higher part when matching on Reg64/RegCode64 datatypes instead of explicitly fetching the higher part from the lower part: much safer default. - - - - - bc8de322 by Sylvain Henry at 2022-02-23T13:59:23-05:00 NCG: inline some 64-bit primops on x86/32-bit (#5444) Several 64-bit operation were implemented with FFI calls on 32-bit architectures but we can easily implement them with inline assembly code. Also remove unused hs_int64ToWord64 and hs_word64ToInt64 C functions. - - - - - 7b7c6b95 by Matthew Pickering at 2022-02-23T14:00:00-05:00 Simplify/correct implementation of getModuleInfo - - - - - 6215b04c by Matthew Pickering at 2022-02-23T14:00:00-05:00 Remove mg_boot field from ModuleGraph It was unused in the compiler so I have removed it to streamline ModuleGraph. - - - - - 818ff2ef by Matthew Pickering at 2022-02-23T14:00:01-05:00 driver: Remove needsTemplateHaskellOrQQ from ModuleGraph The idea of the needsTemplateHaskellOrQQ query is to check if any of the modules in a module graph need Template Haskell then enable -dynamic-too if necessary. This is quite imprecise though as it will enable -dynamic-too for all modules in the module graph even if only one module uses template haskell, with multiple home units, this is obviously even worse. With -fno-code we already have similar logic to enable code generation just for the modules which are dependeded on my TemplateHaskell modules so we use the same code path to decide whether to enable -dynamic-too rather than using this big hammer. This is part of the larger overall goal of moving as much statically known configuration into the downsweep as possible in order to have fully decided the build plan and all the options before starting to build anything. I also included a fix to #21095, a long standing bug with with the logic which is supposed to enable the external interpreter if we don't have the internal interpreter. Fixes #20696 #21095 - - - - - b6670af6 by Matthew Pickering at 2022-02-23T14:00:40-05:00 testsuite: Normalise output of ghci011 and T7627 The outputs of these tests vary on the order interface files are loaded so we normalise the output to correct for these inconsequential differences. Fixes #21121 - - - - - 9ed3bc6e by Peter Trommler at 2022-02-23T14:01:16-05:00 testsuite: Fix ipeMap test Pointers to closures must be untagged before use. Produce closures of different types so we get different info tables. Fixes #21112 - - - - - 7d426148 by Ziyang Liu at 2022-02-24T04:53:34-05:00 Allow `return` in more cases in ApplicativeDo The doc says that the last statement of an ado-block can be one of `return E`, `return $ E`, `pure E` and `pure $ E`. But `return` is not accepted in a few cases such as: ```haskell -- The ado-block only has one statement x :: F () x = do return () -- The ado-block only has let-statements besides the `return` y :: F () y = do let a = True return () ``` These currently require `Monad` instances. This MR fixes it. Normally `return` is accepted as the last statement because it is stripped in constructing an `ApplicativeStmt`, but this cannot be done in the above cases, so instead we replace `return` by `pure`. A similar but different issue (when the ado-block contains `BindStmt` or `BodyStmt`, the second last statement cannot be `LetStmt`, even if the last statement uses `pure`) is fixed in !6786. - - - - - a5ea7867 by John Ericson at 2022-02-24T20:23:49-05:00 Clarify laws of TestEquality It is unclear what `TestEquality` is for. There are 3 possible choices. Assuming ```haskell data Tag a where TagInt1 :: Tag Int TagInt2 :: Tag Int ``` Weakest -- type param equality semi-decidable --------------------------------------------- `Just Refl` merely means the type params are equal, the values being compared might not be. `Nothing` means the type params may or may not be not equal. ```haskell instance TestEquality Tag where testEquality TagInt1 TagInt1 = Nothing -- oopsie is allowed testEquality TagInt1 TagInt2 = Just Refl testEquality TagInt2 TagInt1 = Just Refl testEquality TagInt2 TagInt2 = Just Refl ``` This option is better demonstrated with a different type: ```haskell data Tag' a where TagInt1 :: Tag Int TagInt2 :: Tag a ``` ```haskell instance TestEquality Tag' where testEquality TagInt1 TagInt1 = Just Refl testEquality TagInt1 TagInt2 = Nothing -- can't be sure testEquality TagInt2 TagInt1 = Nothing -- can't be sure testEquality TagInt2 TagInt2 = Nothing -- can't be sure ``` Weaker -- type param equality decidable --------------------------------------- `Just Refl` merely means the type params are equal, the values being compared might not be. `Nothing` means the type params are not equal. ```haskell instance TestEquality Tag where testEquality TagInt1 TagInt1 = Just Refl testEquality TagInt1 TagInt2 = Just Refl testEquality TagInt2 TagInt1 = Just Refl testEquality TagInt2 TagInt2 = Just Refl ``` Strong -- Like `Eq` ------------------- `Just Refl` means the type params are equal, and the values are equal according to `Eq`. ```haskell instance TestEquality Tag where testEquality TagInt1 TagInt1 = Just Refl testEquality TagInt2 TagInt2 = Just Refl testEquality _ _ = Nothing ``` Strongest -- unique value concrete type --------------------------------------- `Just Refl` means the type params are equal, and the values are equal, and the class assume if the type params are equal the values must also be equal. In other words, the type is a singleton type when the type parameter is a closed term. ```haskell -- instance TestEquality -- invalid instance because two variants for `Int` ``` ------ The discussion in https://github.com/haskell/core-libraries-committee/issues/21 has decided on the "Weaker" option (confusingly formerly called the "Weakest" option). So that is what is implemented. - - - - - 06c18990 by Zubin Duggal at 2022-02-24T20:24:25-05:00 TH: fix pretty printing of GADTs with multiple constuctors (#20842) - - - - - 6555b68c by Matthew Pickering at 2022-02-24T20:25:06-05:00 Move linters into the tree This MR moves the GHC linters into the tree, so that they can be run directly using Hadrian. * Query all files tracked by Git instead of using changed files, so that we can run the exact same linting step locally and in a merge request. * Only check that the changelogs don't contain TBA when RELEASE=YES. * Add hadrian/lint script, which runs all the linting steps. * Ensure the hlint job exits with a failure if hlint is not installed (otherwise we were ignoring the failure). Given that hlint doesn't seem to be available in CI at the moment, I've temporarily allowed failure in the hlint job. * Run all linting tests in CI using hadrian. - - - - - b99646ed by Matthew Pickering at 2022-02-24T20:25:06-05:00 Add rule for generating HsBaseConfig.h If you are running the `lint:{base/compiler}` command locally then this improves the responsiveness because we don't re-run configure everytime if the header file already exists. - - - - - d0deaaf4 by Matthew Pickering at 2022-02-24T20:25:06-05:00 Suggestions due to hlint It turns out this job hasn't been running for quite a while (perhaps ever) so there are quite a few failures when running the linter locally. - - - - - 70bafefb by nineonine at 2022-02-24T20:25:42-05:00 ghci: show helpful error message when loading module with SIMD vector operations (#20214) Previously, when trying to load module with SIMD vector operations, ghci would panic in 'GHC.StgToByteCode.findPushSeq'. Now, a more helpful message is displayed. - - - - - 8ed3d5fd by Matthew Pickering at 2022-02-25T10:24:12+00:00 Remove test-bootstrap and cabal-reinstall jobs from fast-ci [skip ci] - - - - - 8387dfbe by Mario Blažević at 2022-02-25T21:09:41-05:00 template-haskell: Fix two prettyprinter issues Fix two issues regarding printing numeric literals. Fixing #20454. - - - - - 4ad8ce0b by sheaf at 2022-02-25T21:10:22-05:00 GHCi: don't normalise partially instantiated types This patch skips performing type normalisation when we haven't fully instantiated the type. That is, in tcRnExpr (used only for :type in GHCi), skip normalisation if the result type responds True to isSigmaTy. Fixes #20974 - - - - - f35aca4d by Ben Gamari at 2022-02-25T21:10:57-05:00 rts/adjustor: Always place adjustor templates in data section @nrnrnr points out that on his machine ld.lld rejects text relocations. Generalize the Darwin text-relocation avoidance logic to account for this. - - - - - cddb040a by Andreas Klebinger at 2022-02-25T21:11:33-05:00 Ticky: Gate tag-inference dummy ticky-counters behind a flag. Tag inference included a way to collect stats about avoided tag-checks. This was dony by emitting "dummy" ticky entries with counts corresponding to predicted/unpredicated tag checks. This behaviour for ticky is now gated behind -fticky-tag-checks. I also documented ticky-LNE in the process. - - - - - 948bf2d0 by Ben Gamari at 2022-02-25T21:12:09-05:00 Fix comment reference to T4818 - - - - - 9c3edeb8 by Ben Gamari at 2022-02-25T21:12:09-05:00 simplCore: Correctly extend in-scope set in rule matching Note [Matching lets] in GHC.Core.Rules claims the following: > We use GHC.Core.Subst.substBind to freshen the binding, using an > in-scope set that is the original in-scope variables plus the > rs_bndrs (currently floated let-bindings). However, previously the implementation didn't actually do extend the in-scope set with rs_bndrs. This appears to be a regression which was introduced by 4ff4d434e9a90623afce00b43e2a5a1ccbdb4c05. Moreover, the originally reasoning was subtly wrong: we must rather use the in-scope set from rv_lcl, extended with rs_bndrs, not that of `rv_fltR` Fixes #21122. - - - - - 7f9f49c3 by sheaf at 2022-02-25T21:12:47-05:00 Derive some stock instances for OverridingBool This patch adds some derived instances to `GHC.Data.Bool.OverridingBool`. It also changes the order of the constructors, so that the derived `Ord` instance matches the behaviour for `Maybe Bool`. Fixes #20326 - - - - - 140438a8 by nineonine at 2022-02-25T21:13:23-05:00 Add test for #19271 - - - - - ac9f4606 by sheaf at 2022-02-25T21:14:04-05:00 Allow qualified names in COMPLETE pragmas The parser didn't allow qualified constructor names to appear in COMPLETE pragmas. This patch fixes that. Fixes #20551 - - - - - 677c6c91 by Sylvain Henry at 2022-02-25T21:14:44-05:00 Testsuite: remove arch conditional in T8832 Taken from !3658 - - - - - ad04953b by Sylvain Henry at 2022-02-25T21:15:23-05:00 Allow hscGenHardCode to not return CgInfos This is a minor change in preparation for the JS backend: CgInfos aren't mandatory and the JS backend won't return them. - - - - - 929c280f by Sylvain Henry at 2022-02-25T21:15:24-05:00 Derive Enum instances for CCallConv and Safety This is used by the JS backend for serialization. - - - - - 75e4e090 by Sebastian Graf at 2022-02-25T21:15:59-05:00 base: Improve documentation of `throwIO` (#19854) Now it takes a better account of precise vs. imprecise exception semantics. Fixes #19854. - - - - - 61a203ba by Matthew Pickering at 2022-02-26T02:06:51-05:00 Make typechecking unfoldings from interfaces lazier The old logic was unecessarily strict in loading unfoldings because when reading the unfolding we would case on the result of attempting to load the template before commiting to which type of unfolding we were producing. Hence trying to inspect any of the information about an unfolding would force the template to be loaded. This also removes a potentially hard to discover bug where if the template failed to be typechecked for some reason then we would just not return an unfolding. Instead we now panic so these bad situations which should never arise can be identified. - - - - - 2be74460 by Matthew Pickering at 2022-02-26T02:06:51-05:00 Use a more up-to-date snapshot of the current rules in the simplifier As the prescient (now deleted) note warns in simplifyPgmIO we have to be a bit careful about when we gather rules from the EPS so that we get the rules for imported bindings. ``` -- Get any new rules, and extend the rule base -- See Note [Overall plumbing for rules] in GHC.Core.Rules -- We need to do this regularly, because simplification can -- poke on IdInfo thunks, which in turn brings in new rules -- behind the scenes. Otherwise there's a danger we'll simply -- miss the rules for Ids hidden inside imported inlinings ``` Given the previous commit, the loading of unfoldings is now even more delayed so we need to be more careful to read the EPS rule base closer to the point where we decide to try rules. Without this fix GHC performance regressed by a noticeably amount because the `zip` rule was not brought into scope eagerly enough which led to a further series of unfortunate events in the simplifer which tipped `substTyWithCoVars` over the edge of the size threshold, stopped it being inlined and increased allocations by 10% in some cases. Furthermore, this change is noticeably in the testsuite as it changes T19790 so that the `length` rules from GHC.List fires earlier. ------------------------- Metric Increase: T9961 ------------------------- - - - - - b8046195 by Matthew Pickering at 2022-02-26T02:06:52-05:00 Improve efficiency of extending a RuleEnv with a new RuleBase Essentially we apply the identity: > lookupNameEnv n (plusNameEnv_C (++) rb1 rb2) > = lookupNameEnv n rb1 ++ lookupNameEnv n rb2 The latter being more efficient as we don't construct an intermediate map. This is now quite important as each time we try and apply rules we need to combine the current EPS RuleBase with the HPT and ModGuts rule bases. - - - - - 033e9f0f by sheaf at 2022-02-26T02:07:30-05:00 Error on anon wildcards in tcAnonWildCardOcc The code in tcAnonWildCardOcc assumed that it could never encounter anonymous wildcards in illegal positions, because the renamer would have ruled them out. However, it's possible to sneak past the checks in the renamer by using Template Haskell. It isn't possible to simply pass on additional information when renaming Template Haskell brackets, because we don't know in advance in what context the bracket will be spliced in (see test case T15433b). So we accept that we might encounter these bogus wildcards in the typechecker and throw the appropriate error. This patch also migrates the error messages for illegal wildcards in types to use the diagnostic infrastructure. Fixes #15433 - - - - - 32d8fe3a by sheaf at 2022-02-26T14:15:33+01:00 Core Lint: ensure primops can be eta-expanded This patch adds a check to Core Lint, checkCanEtaExpand, which ensures that primops and other wired-in functions with no binding such as unsafeCoerce#, oneShot, rightSection... can always be eta-expanded, by checking that the remaining argument types have a fixed RuntimeRep. Two subtleties came up: - the notion of arity in Core looks through newtypes, so we may need to unwrap newtypes in this check, - we want to avoid calling hasNoBinding on something whose unfolding we are in the process of linting, as this would cause a loop; to avoid this we add some information to the Core Lint environment that holds this information. Fixes #20480 - - - - - 0a80b436 by Peter Trommler at 2022-02-26T17:21:59-05:00 testsuite: Require LLVM for T15155l - - - - - 38cb920e by Oleg Grenrus at 2022-02-28T07:14:04-05:00 Add Monoid a => Monoid (STM a) instance - - - - - d734ef8f by Hécate Moonlight at 2022-02-28T07:14:42-05:00 Make modules in base stable. fix #18963 - - - - - fbf005e9 by Sven Tennie at 2022-02-28T19:16:01-05:00 Fix some hlint issues in ghc-heap This does not fix all hlint issues as the criticised index and length expressions seem to be fine in context. - - - - - adfddf7d by Matthew Pickering at 2022-02-28T19:16:36-05:00 hadrian: Suggest to the user to run ./configure if missing a setting If a setting is missing from the configuration file it's likely the user needs to reconfigure. Fixes #20476 - - - - - 4f0208e5 by Andreas Klebinger at 2022-02-28T19:17:12-05:00 CLabel cleanup: Remove these smart constructors for these reasons: * mkLocalClosureTableLabel : Does the same as the non-local variant. * mkLocalClosureLabel : Does the same as the non-local variant. * mkLocalInfoTableLabel : Decide if we make a local label based on the name and just use mkInfoTableLabel everywhere. - - - - - 065419af by Matthew Pickering at 2022-02-28T19:17:47-05:00 linking: Don't pass --hash-size and --reduce-memory-overhead to ld These flags were added to help with the high linking cost of the old split-objs mode. Now we are using split-sections these flags appear to make no difference to memory usage or time taken to link. I tested various configurations linking together the ghc library with -split-sections enabled. | linker | time (s) | | ------ | ------ | | gold | 0.95 | | ld | 1.6 | | ld (hash-size = 31, reduce-memory-overheads) | 1.6 | | ldd | 0.47 | Fixes #20967 - - - - - 3e65ef05 by Teo Camarasu at 2022-02-28T19:18:27-05:00 template-haskell: fix typo in docstring for Overlap - - - - - 80f9133e by Teo Camarasu at 2022-02-28T19:18:27-05:00 template-haskell: fix docstring for Bytes It seems like a commented out section of code was accidentally included in the docstring for a field. - - - - - 54774268 by Matthew Pickering at 2022-03-01T16:23:10-05:00 Fix longstanding issue with moduleGraphNodes - no hs-boot files case In the case when we tell moduleGraphNodes to drop hs-boot files the idea is to collapse hs-boot files into their hs file nodes. In the old code * nodeDependencies changed edges from IsBoot to NonBoot * moduleGraphNodes just dropped boot file nodes The net result is that any dependencies of the hs-boot files themselves were dropped. The correct thing to do is * nodeDependencies changes edges from IsBoot to NonBoot * moduleGraphNodes merges dependencies of IsBoot and NonBoot nodes. The result is a properly quotiented dependency graph which contains no hs-boot files nor hs-boot file edges. Why this didn't cause endless issues when compiling with boot files, we will never know. - - - - - c84dc506 by Matthew Pickering at 2022-03-01T16:23:10-05:00 driver: Properly add an edge between a .hs and its hs-boot file As noted in #21071 we were missing adding this edge so there were situations where the .hs file would get compiled before the .hs-boot file which leads to issues with -j. I fixed this properly by adding the edge in downsweep so the definition of nodeDependencies can be simplified to avoid adding this dummy edge in. There are plenty of tests which seem to have these redundant boot files anyway so no new test. #21094 tracks the more general issue of identifying redundant hs-boot and SOURCE imports. - - - - - 7aeb6d29 by sheaf at 2022-03-01T16:23:51-05:00 Core Lint: collect args through floatable ticks We were not looking through floatable ticks when collecting arguments in Core Lint, which caused `checkCanEtaExpand` to fail on something like: ```haskell reallyUnsafePtrEquality = \ @a -> (src<loc> reallyUnsafePtrEquality#) @Lifted @a @Lifted @a ``` We fix this by using `collectArgsTicks tickishFloatable` instead of `collectArgs`, to be consistent with the behaviour of eta expansion outlined in Note [Eta expansion and source notes] in GHC.Core.Opt.Arity. Fixes #21152. - - - - - 75caafaa by Matthew Pickering at 2022-03-02T01:14:59-05:00 Ticky profiling improvements. This adds a number of changes to ticky-ticky profiling. When an executable is profiled with IPE profiling it's now possible to associate id-related ticky counters to their source location. This works by emitting the info table address as part of the counter which can be looked up in the IPE table. Add a `-ticky-ap-thunk` flag. This flag prevents the use of some standard thunks which are precompiled into the RTS. This means reduced cache locality and increased code size. But it allows better attribution of execution cost to specific source locations instead of simple attributing it to the standard thunk. ticky-ticky now uses the `arg` field to emit additional information about counters in json format. When ticky-ticky is used in combination with the eventlog eventlog2html can be used to generate a html table from the eventlog similar to the old text output for ticky-ticky. - - - - - aeea6bd5 by doyougnu at 2022-03-02T01:15:39-05:00 StgToCmm.cgTopBinding: no isNCG, use binBlobThresh This is a one line change. It is a fixup from MR!7325, was pointed out in review of MR!7442, specifically: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7442#note_406581 The change removes isNCG check from cgTopBinding. Instead it changes the type of binBlobThresh in DynFlags from Word to Maybe Word, where a Just 0 or a Nothing indicates an infinite threshold and thus the disable CmmFileEmbed case in the original check. This improves the cohesion of the module because more NCG related Backend stuff is moved into, and checked in, StgToCmm.Config. Note, that the meaning of a Just 0 or a Nothing in binBlobThresh is indicated in a comment next to its field in GHC.StgToCmm.Config. DynFlags: binBlobThresh: Word -> Maybe Word StgToCmm.Config: binBlobThesh add not ncg check DynFlags.binBlob: move Just 0 check to dflags init StgToCmm.binBlob: only check isNCG, Just 0 check to dflags StgToCmm.Config: strictify binBlobThresh - - - - - b27b2af3 by sheaf at 2022-03-02T14:08:36-05:00 Introduce ConcreteTv metavariables This patch introduces a new kind of metavariable, by adding the constructor `ConcreteTv` to `MetaInfo`. A metavariable with `ConcreteTv` `MetaInfo`, henceforth a concrete metavariable, can only be unified with a type that is concrete (that is, a type that answers `True` to `GHC.Core.Type.isConcrete`). This solves the problem of dangling metavariables in `Concrete#` constraints: instead of emitting `Concrete# ty`, which contains a secret existential metavariable, we simply emit a primitive equality constraint `ty ~# concrete_tv` where `concrete_tv` is a fresh concrete metavariable. This means we can avoid all the complexity of canonicalising `Concrete#` constraints, as we can just re-use the existing machinery for `~#`. To finish things up, this patch then removes the `Concrete#` special predicate, and instead introduces the special predicate `IsRefl#` which enforces that a coercion is reflexive. Such a constraint is needed because the canonicaliser is quite happy to rewrite an equality constraint such as `ty ~# concrete_tv`, but such a rewriting is not handled by the rest of the compiler currently, as we need to make use of the resulting coercion, as outlined in the FixedRuntimeRep plan. The big upside of this approach (on top of simplifying the code) is that we can now selectively implement PHASE 2 of FixedRuntimeRep, by changing individual calls of `hasFixedRuntimeRep_MustBeRefl` to `hasFixedRuntimeRep` and making use of the obtained coercion. - - - - - 81b7c436 by Matthew Pickering at 2022-03-02T14:09:13-05:00 Make -dannot-lint not panic on let bound type variables After certain simplifier passes we end up with let bound type variables which are immediately inlined in the next pass. The core diff utility implemented by -dannot-lint failed to take these into account and paniced. Progress towards #20965 - - - - - f596c91a by sheaf at 2022-03-02T14:09:51-05:00 Improve out-of-order inferred type variables Don't instantiate type variables for :type in `GHC.Tc.Gen.App.tcInstFun`, to avoid inconsistently instantianting `r1` but not `r2` in the type forall {r1} (a :: TYPE r1) {r2} (b :: TYPE r2). ... This fixes #21088. This patch also changes the primop pretty-printer to ensure that we put all the inferred type variables first. For example, the type of reallyUnsafePtrEquality# is now forall {l :: Levity} {k :: Levity} (a :: TYPE (BoxedRep l)) (b :: TYPE (BoxedRep k)). a -> b -> Int# This means we avoid running into issue #21088 entirely with the types of primops. Users can still write a type signature where the inferred type variables don't come first, however. This change to primops had a knock-on consequence, revealing that we were sometimes performing eta reduction on keepAlive#. This patch updates tryEtaReduce to avoid eta reducing functions with no binding, bringing it in line with tryEtaReducePrep, and thus fixing #21090. - - - - - 1617fed3 by Richard Eisenberg at 2022-03-02T14:10:28-05:00 Make inert_cycle_breakers into a stack. Close #20231. - - - - - c8652a0a by Richard Eisenberg at 2022-03-02T14:11:03-05:00 Make Constraint not *apart* from Type. More details in Note [coreView vs tcView] Close #21092. - - - - - 91a10cb0 by doyougnu at 2022-03-02T14:11:43-05:00 GenStgAlt 3-tuple synonym --> Record type This commit alters GenStgAlt from a type synonym to a Record with field accessors. In pursuit of #21078, this is not a required change but cleans up several areas for nicer code in the upcoming js-backend, and in GHC itself. GenStgAlt: 3-tuple -> record Stg.Utils: GenStgAlt 3-tuple -> record Stg.Stats: StgAlt 3-tuple --> record Stg.InferTags.Rewrite: StgAlt 3-tuple -> record Stg.FVs: GenStgAlt 3-tuple -> record Stg.CSE: GenStgAlt 3-tuple -> record Stg.InferTags: GenStgAlt 3-tuple --> record Stg.Debug: GenStgAlt 3-tuple --> record Stg.Lift.Analysis: GenStgAlt 3-tuple --> record Stg.Lift: GenStgAlt 3-tuple --> record ByteCode.Instr: GenStgAlt 3-tuple --> record Stg.Syntax: add GenStgAlt helper functions Stg.Unarise: GenStgAlt 3-tuple --> record Stg.BcPrep: GenStgAlt 3-tuple --> record CoreToStg: GenStgAlt 3-tuple --> record StgToCmm.Expr: GenStgAlt 3-tuple --> record StgToCmm.Bind: GenStgAlt 3-tuple --> record StgToByteCode: GenStgAlt 3-tuple --> record Stg.Lint: GenStgAlt 3-tuple --> record Stg.Syntax: strictify GenStgAlt GenStgAlt: add haddock, some cleanup fixup: remove calls to pure, single ViewPattern StgToByteCode: use case over viewpatterns - - - - - 73864f00 by Matthew Pickering at 2022-03-02T14:12:19-05:00 base: Remove default method from bitraversable The default instance leads to an infinite loop. bisequenceA is defined in terms of bisquence which is defined in terms of bitraverse. ``` bitraverse f g = (defn of bitraverse) bisequenceA . bimap f g = (defn of bisequenceA) bitraverse id id . bimap f g = (defn of bitraverse) ... ``` Any instances defined without an explicitly implementation are currently broken, therefore removing it will alert users to an issue in their code. CLC issue: https://github.com/haskell/core-libraries-committee/issues/47 Fixes #20329 #18901 - - - - - 9579bf35 by Matthew Pickering at 2022-03-02T14:12:54-05:00 ci: Add check to CI to ensure compiler uses correct BIGNUM_BACKEND - - - - - c48a7c3a by Sylvain Henry at 2022-03-03T07:37:12-05:00 Use Word64# primops in Word64 Num instance Taken froù!3658 - - - - - ce65d0cc by Matthew Pickering at 2022-03-03T07:37:48-05:00 hadrian: Correctly set whether we have a debug compiler when running tests For example, running the `slow-validate` flavour would incorrectly run the T16135 test which would fail with an assertion error, despite the fact that is should be skipped when we have a debug compiler. - - - - - e0c3e757 by Matthew Pickering at 2022-03-03T13:48:41-05:00 docs: Add note to unsafeCoerce function that you might want to use coerce [skip ci] Fixes #15429 - - - - - 559d4cf3 by Matthew Pickering at 2022-03-03T13:49:17-05:00 docs: Add note to RULES documentation about locally bound variables [skip ci] Fixes #20100 - - - - - c534b3dd by Matthew Pickering at 2022-03-03T13:49:53-05:00 Replace ad-hoc CPP with constant from GHC.Utils.Constant Fixes #21154 - - - - - de56cc7e by Krzysztof Gogolewski at 2022-03-04T12:44:26-05:00 Update documentation of LiberalTypeSynonyms We no longer require LiberalTypeSynonyms to use 'forall' or an unboxed tuple in a synonym. I also removed that kind checking before expanding synonyms "could be changed". This was true when type synonyms were thought of macros, but with the extensions such as SAKS or matchability I don't see it changing. - - - - - c0a39259 by Simon Jakobi at 2022-03-04T12:45:01-05:00 base: Mark GHC.Bits not-home for haddock Most (all) of the exports are re-exported from the preferable Data.Bits. - - - - - 3570eda5 by Sylvain Henry at 2022-03-04T12:45:42-05:00 Fix comments about Int64/Word64 primops - - - - - 6f84ee33 by Artem Pelenitsyn at 2022-03-05T01:06:47-05:00 remove MonadFail instances of ST CLC proposal: https://github.com/haskell/core-libraries-committee/issues/33 The instances had `fail` implemented in terms of `error`, whereas the idea of the `MonadFail` class is that the `fail` method should be implemented in terms of the monad itself. - - - - - 584cd5ae by sheaf at 2022-03-05T01:07:25-05:00 Don't allow Float#/Double# literal patterns This patch does the following two things: 1. Fix the check in Core Lint to properly throw an error when it comes across Float#/Double# literal patterns. The check was incorrect before, because it expected the type to be Float/Double instead of Float#/Double#. 2. Add an error in the parser when the user writes a floating-point literal pattern such as `case x of { 2.0## -> ... }`. Fixes #21115 - - - - - 706deee0 by Greg Steuck at 2022-03-05T17:44:10-08:00 Make T20214 terminate promptly be setting input to /dev/null It was hanging and timing out on OpenBSD before. - - - - - 14e90098 by Simon Peyton Jones at 2022-03-07T14:05:41-05:00 Always generalise top-level bindings Fix #21023 by always generalising top-level binding; change the documentation of -XMonoLocalBinds to match. - - - - - c9c31c3c by Matthew Pickering at 2022-03-07T14:06:16-05:00 hadrian: Add little flavour transformer to build stage2 with assertions This can be useful to build a `perf+assertions` build or even better `default+no_profiled_libs+omit_pragmas+assertions`. - - - - - 89c14a6c by Matthew Pickering at 2022-03-07T14:06:16-05:00 ci: Convert all deb10 make jobs into hadrian jobs This is the first step in converting all the CI configs to use hadrian rather than make. (#21129) The metrics increase due to hadrian using --hyperlinked-source for haddock builds. (See #21156) ------------------------- Metric Increase: haddock.Cabal haddock.base haddock.compiler ------------------------- - - - - - 7bfae2ee by Matthew Pickering at 2022-03-07T14:06:16-05:00 Replace use of BIN_DIST_PREP_TAR_COMP with BIN_DIST_NAME And adds a check to make sure we are not accidently settings BIN_DIST_PREP_TAR_COMP when using hadrian. - - - - - 5b35ca58 by Matthew Pickering at 2022-03-07T14:06:16-05:00 Fix gen_contents_index logic for hadrian bindist - - - - - 273bc133 by Krzysztof Gogolewski at 2022-03-07T14:06:52-05:00 Fix reporting constraints in pprTcSolverReportMsg 'no_instance_msg' and 'no_deduce_msg' were omitting the first wanted. - - - - - 5874a30a by Simon Jakobi at 2022-03-07T14:07:28-05:00 Improve setBit for Natural Previously the default definition was used, which involved allocating intermediate Natural values. Fixes #21173. - - - - - 7a02aeb8 by Matthew Pickering at 2022-03-07T14:08:03-05:00 Remove leftover trace in testsuite - - - - - 6ce6c250 by Andreas Klebinger at 2022-03-07T23:48:56-05:00 Expand and improve the Note [Strict Worker Ids]. I've added an explicit mention of the invariants surrounding those. As well as adding more direct cross references to the Strict Field Invariant. - - - - - d0f892fe by Ryan Scott at 2022-03-07T23:49:32-05:00 Delete GenericKind_ in favor of GenericKind_DC When deriving a `Generic1` instance, we need to know what the last type variable of a data type is. Previously, there were two mechanisms to determine this information: * `GenericKind_`, where `Gen1_` stored the last type variable of a data type constructor (i.e., the `tyConTyVars`). * `GenericKind_DC`, where `Gen1_DC` stored the last universally quantified type variable in a data constructor (i.e., the `dataConUnivTyVars`). These had different use cases, as `GenericKind_` was used for generating `Rep(1)` instances, while `GenericKind_DC` was used for generating `from(1)` and `to(1)` implementations. This was already a bit confusing, but things went from confusing to outright wrong after !6976. This is because after !6976, the `deriving` machinery stopped using `tyConTyVars` in favor of `dataConUnivTyVars`. Well, everywhere with the sole exception of `GenericKind_`, which still continued to use `tyConTyVars`. This lead to disaster when deriving a `Generic1` instance for a GADT family instance, as the `tyConTyVars` do not match the `dataConUnivTyVars`. (See #21185.) The fix is to stop using `GenericKind_` and replace it with `GenericKind_DC`. For the most part, this proves relatively straightforward. Some highlights: * The `forgetArgVar` function was deleted entirely, as it no longer proved necessary after `GenericKind_`'s demise. * The substitution that maps from the last type variable to `Any` (see `Note [Generating a correctly typed Rep instance]`) had to be moved from `tc_mkRepTy` to `tc_mkRepFamInsts`, as `tc_mkRepTy` no longer has access to the last type variable. Fixes #21185. - - - - - a60ddffd by Matthew Pickering at 2022-03-08T22:51:37+00:00 Move bootstrap and cabal-reinstall test jobs to nightly CI is creaking under the pressure of too many jobs so attempt to reduce the strain by removing a couple of jobs. - - - - - 7abe3288 by Matthew Pickering at 2022-03-09T10:24:15+00:00 Add 10 minute timeout to linters job - - - - - 3cf75ede by Matthew Pickering at 2022-03-09T10:24:16+00:00 Revert "hadrian: Correctly set whether we have a debug compiler when running tests" Needing the arguments for "GHC/Utils/Constant.hs" implies a dependency on the previous stage compiler. Whilst we work out how to get around this I will just revert this commit (as it only affects running the testsuite in debug way). This reverts commit ce65d0cceda4a028f30deafa3c39d40a250acc6a. - - - - - 18b9ba56 by Matthew Pickering at 2022-03-09T11:07:23+00:00 ci: Fix save_cache function Each interation of saving the cache would copy the whole `cabal` store into a subfolder in the CACHE_DIR rather than copying the contents of the cabal store into the cache dir. This resulted in a cache which looked like: ``` /builds/ghc/ghc/cabal-cache/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/ ``` So it would get one layer deeper every CI run and take longer and longer to compress. - - - - - bc684dfb by Ben Gamari at 2022-03-10T03:20:07-05:00 mr-template: Mention timeframe for review - - - - - 7f5f4ede by Vladislav Zavialov at 2022-03-10T03:20:43-05:00 Bump submodules: containers, exceptions GHC Proposal #371 requires TypeOperators to use type equality a~b. This submodule update pulls in the appropriate forward-compatibility changes in 'libraries/containers' and 'libraries/exceptions' - - - - - 8532b8a9 by Matthew Pickering at 2022-03-10T03:20:43-05:00 Add an inline pragma to lookupVarEnv The containers bump reduced the size of the Data.IntMap.Internal.lookup function so that it no longer experienced W/W. This means that the size of lookupVarEnv increased over the inlining threshold and it wasn't inlined into the hot code path in substTyVar. See containers#821, #21159 and !7638 for some more explanation. ------------------------- Metric Decrease: LargeRecord T12227 T13386 T15703 T18223 T5030 T8095 T9872a T9872b T9872c TcPlugin_RewritePerf ------------------------- - - - - - 844cf1e1 by Matthew Pickering at 2022-03-10T03:20:43-05:00 Normalise output of T10970 test The output of this test changes each time the containers submodule version updates. It's easier to apply the version normaliser so that the test checks that there is a version number, but not which one it is. - - - - - 24b6af26 by Ryan Scott at 2022-03-11T19:56:28-05:00 Refactor tcDeriving to generate tyfam insts before any bindings Previously, there was an awful hack in `genInst` (now called `genInstBinds` after this patch) where we had to return a continutation rather than directly returning the bindings for a derived instance. This was done for staging purposes, as we had to first infer the instance contexts for derived instances and then feed these contexts into the continuations to ensure the generated instance bindings had accurate instance contexts. `Note [Staging of tcDeriving]` in `GHC.Tc.Deriving` described this confusing state of affairs. The root cause of this confusing design was the fact that `genInst` was trying to generate instance bindings and associated type family instances for derived instances simultaneously. This really isn't possible, however: as `Note [Staging of tcDeriving]` explains, one needs to have access to the associated type family instances before one can properly infer the instance contexts for derived instances. The use of continuation-returning style was an attempt to circumvent this dependency, but it did so in an awkward way. This patch detangles this awkwardness by splitting up `genInst` into two functions: `genFamInsts` (for associated type family instances) and `genInstBinds` (for instance bindings). Now, the `tcDeriving` function calls `genFamInsts` and brings all the family instances into scope before calling `genInstBinds`. This removes the need for the awkward continuation-returning style seen in the previous version of `genInst`, making the code easier to understand. There are some knock-on changes as well: 1. `hasStockDeriving` now needs to return two separate functions: one that describes how to generate family instances for a stock-derived instance, and another that describes how to generate the instance bindings. I factored out this pattern into a new `StockGenFns` data type. 2. While documenting `StockGenFns`, I realized that there was some inconsistency regarding which `StockGenFns` functions needed which arguments. In particular, the function in `GHC.Tc.Deriv.Generics` which generates `Rep(1)` instances did not take a `SrcSpan` like other `gen_*` functions did, and it included an extra `[Type]` argument that was entirely redundant. As a consequence, I refactored the code in `GHC.Tc.Deriv.Generics` to more closely resemble other `gen_*` functions. A happy result of all this is that all `StockGenFns` functions now take exactly the same arguments, which makes everything more uniform. This is purely a refactoring that should not have any effect on user-observable behavior. The new design paves the way for an eventual fix for #20719. - - - - - 62caaa9b by Ben Gamari at 2022-03-11T19:57:03-05:00 gitlab-ci: Use the linters image in hlint job As the `hlint` executable is only available in the linters image. Fixes #21146. - - - - - 4abd7eb0 by Matthew Pickering at 2022-03-11T19:57:38-05:00 Remove partOfGhci check in the loader This special logic has been part of GHC ever since template haskell was introduced in 9af77fa423926fbda946b31e174173d0ec5ebac8. It's hard to believe in any case that this special logic pays its way at all. Given * The list is out-of-date, which has potential to lead to miscompilation when using "editline", which was removed in 2010 (46aed8a4). * The performance benefit seems negligable as each load only happens once anyway and packages specified by package flags are preloaded into the linker state at the start of compilation. Therefore we just remove this logic. Fixes #19791 - - - - - c40cbaa2 by Andreas Klebinger at 2022-03-11T19:58:14-05:00 Improve -dtag-inference-checks checks. FUN closures don't get tagged when evaluated. So no point in checking their tags. - - - - - ab00d23b by Simon Jakobi at 2022-03-11T19:58:49-05:00 Improve clearBit and complementBit for Natural Also optimize bigNatComplementBit#. Fixes #21175, #21181, #21194. - - - - - a6d8facb by Sebastian Graf at 2022-03-11T19:59:24-05:00 gitignore all (build) directories headed by _ - - - - - 524795fe by Sebastian Graf at 2022-03-11T19:59:24-05:00 Demand: Document why we need three additional equations of multSubDmd - - - - - 6bdcd557 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: make 64-bit word splitting for 32-bit targets respect target endianness This used to been broken for little-endian targets. - - - - - 9e67c69e by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: fix Double# literal payload for 32-bit targets Contrary to the legacy comment, the splitting didn't happen and we ended up with a single StgWord64 literal in the output code! Let's just do the splitting here. - - - - - 1eee2e28 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: use __builtin versions of memcpyish functions to fix type mismatch Our memcpyish primop's type signatures doesn't match the C type signatures. It's not a problem for typical archs, since their C ABI permits dropping the result, but it doesn't work for wasm. The previous logic would cast the memcpyish function pointer to an incorrect type and perform an indirect call, which results in a runtime trap on wasm. The most straightforward fix is: don't emit EFF_ for memcpyish functions. Since we don't want to include extra headers in .hc to bring in their prototypes, we can just use the __builtin versions. - - - - - 9d8d4837 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: emit __builtin_unreachable() when CmmSwitch doesn't contain fallback case Otherwise the C compiler may complain "warning: non-void function does not return a value in all control paths [-Wreturn-type]". - - - - - 27da5540 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: make floatToWord32/doubleToWord64 faster Use castFloatToWord32/castDoubleToWord64 in base to perform the reinterpret cast. - - - - - c98e8332 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: fix -Wunused-value warning in ASSIGN_BaseReg When ASSIGN_BaseReg is a no-op, we shouldn't generate any C code, otherwise C compiler complains a bunch of -Wunused-value warnings when doing unregisterised codegen. - - - - - 5932247c by Ben Gamari at 2022-03-11T20:00:36-05:00 users guide: Eliminate spurious \spxentry mentions We were failing to pass the style file to `makeindex`, as is done by the mklatex configuration generated by Sphinx. Fixes #20913. - - - - - e40cf4ef by Simon Jakobi at 2022-03-11T20:01:11-05:00 ghc-bignum: Tweak integerOr The result of ORing two BigNats is always greater or equal to the larger of the two. Therefore it is safe to skip the magnitude checks of integerFromBigNat#. - - - - - cf081476 by Vladislav Zavialov at 2022-03-12T07:02:40-05:00 checkUnboxedLitPat: use non-fatal addError This enables GHC to report more parse errors in a single pass. - - - - - 7fe07143 by Andreas Klebinger at 2022-03-12T07:03:16-05:00 Rename -fprof-late-ccs to -fprof-late - - - - - 88a94541 by Sylvain Henry at 2022-03-12T07:03:56-05:00 Hadrian: avoid useless allocations in trackArgument Cf ticky report before the change: Entries Alloc Alloc'd Non-void Arguments STG Name -------------------------------------------------------------------------------- 696987 29044128 0 1 L main:Target.trackArgument_go5{v r24kY} (fun) - - - - - 2509d676 by Sylvain Henry at 2022-03-12T07:04:36-05:00 Hadrian: avoid allocating in stageString (#19209) - - - - - c062fac0 by Sylvain Henry at 2022-03-12T07:04:36-05:00 Hadrian: remove useless imports Added for no reason in 7ce1b694f7be7fbf6e2d7b7eb0639e61fbe358c6 - - - - - c82fb934 by Sylvain Henry at 2022-03-12T07:05:16-05:00 Hadrian: avoid allocations in WayUnit's Read instance (#19209) - - - - - ed04aed2 by Sylvain Henry at 2022-03-12T07:05:16-05:00 Hadrian: use IntSet Binary instance for Way (#19209) - - - - - ad835531 by Simon Peyton Jones at 2022-03-13T18:12:12-04:00 Fix bug in weak loop-breakers in OccurAnal Note [Weak loop breakers] explains why we need to track variables free in RHS of rules. But we need to do this for /inactive/ rules as well as active ones, unlike the rhs_fv_env stuff. So we now have two fields in node Details, one for free vars of active rules, and one for free vars of all rules. This was shown up by #20820, which is now fixed. - - - - - 76b94b72 by Sebastian Graf at 2022-03-13T18:12:48-04:00 Worker/wrapper: Preserve float barriers (#21150) Issue #21150 shows that worker/wrapper allocated a worker function for a function with multiple calls that said "called at most once" when the first argument was absent. That's bad! This patch makes it so that WW preserves at least one non-one-shot value lambda (see `Note [Preserving float barriers]`) by passing around `void#` in place of absent arguments. Fixes #21150. Since the fix is pretty similar to `Note [Protecting the last value argument]`, I put the logic in `mkWorkerArgs`. There I realised (#21204) that `-ffun-to-thunk` is basically useless with `-ffull-laziness`, so I deprecated the flag, simplified and split into `needsVoidWorkerArg`/`addVoidWorkerArg`. SpecConstr is another client of that API. Fixes #21204. Metric Decrease: T14683 - - - - - 97db789e by romes at 2022-03-14T11:36:39-04:00 Fix up Note [Bind free vars] Move GHC-specific comments from Language.Haskell.Syntax.Binds to GHC.Hs.Binds It looks like the Note was deleted but there were actually two copies of it. L.H.S.B no longer references it, and GHC.Hs.Binds keeps an updated copy. (See #19252) There are other duplicated notes -- they will be fixed in the next commit - - - - - 135888dd by romes at 2022-03-14T11:36:39-04:00 TTG Pull AbsBinds and ABExport out of the main AST AbsBinds and ABExport both depended on the typechecker, and were thus removed from the main AST Expr. CollectPass now has a new function `collectXXHsBindsLR` used for the new HsBinds extension point Bumped haddock submodule to work with AST changes. The removed Notes from Language.Haskell.Syntax.Binds were duplicated (and not referenced) and the copies in GHC.Hs.Binds are kept (and referenced there). (See #19252) - - - - - 106413f0 by sheaf at 2022-03-14T11:37:21-04:00 Add two coercion optimisation perf tests - - - - - 8eadea67 by sheaf at 2022-03-14T15:08:24-04:00 Fix isLiftedType_maybe and handle fallout As #20837 pointed out, `isLiftedType_maybe` returned `Just False` in many situations where it should return `Nothing`, because it didn't take into account type families or type variables. In this patch, we fix this issue. We rename `isLiftedType_maybe` to `typeLevity_maybe`, which now returns a `Levity` instead of a boolean. We now return `Nothing` for types with kinds of the form `TYPE (F a1 ... an)` for a type family `F`, as well as `TYPE (BoxedRep l)` where `l` is a type variable. This fix caused several other problems, as other parts of the compiler were relying on `isLiftedType_maybe` returning a `Just` value, and were now panicking after the above fix. There were two main situations in which panics occurred: 1. Issues involving the let/app invariant. To uphold that invariant, we need to know whether something is lifted or not. If we get an answer of `Nothing` from `isLiftedType_maybe`, then we don't know what to do. As this invariant isn't particularly invariant, we can change the affected functions to not panic, e.g. by behaving the same in the `Just False` case and in the `Nothing` case (meaning: no observable change in behaviour compared to before). 2. Typechecking of data (/newtype) constructor patterns. Some programs involving patterns with unknown representations were accepted, such as T20363. Now that we are stricter, this caused further issues, culminating in Core Lint errors. However, the behaviour was incorrect the whole time; the incorrectness only being revealed by this change, not triggered by it. This patch fixes this by overhauling where the representation polymorphism involving pattern matching are done. Instead of doing it in `tcMatches`, we instead ensure that the `matchExpected` functions such as `matchExpectedFunTys`, `matchActualFunTySigma`, `matchActualFunTysRho` allow return argument pattern types which have a fixed RuntimeRep (as defined in Note [Fixed RuntimeRep]). This ensures that the pattern matching code only ever handles types with a known runtime representation. One exception was that patterns with an unknown representation type could sneak in via `tcConPat`, which points to a missing representation-polymorphism check, which this patch now adds. This means that we now reject the program in #20363, at least until we implement PHASE 2 of FixedRuntimeRep (allowing type families in RuntimeRep positions). The aforementioned refactoring, in which checks have been moved to `matchExpected` functions, is a first step in implementing PHASE 2 for patterns. Fixes #20837 - - - - - 8ff32124 by Sebastian Graf at 2022-03-14T15:09:01-04:00 DmdAnal: Don't unbox recursive data types (#11545) As `Note [Demand analysis for recursive data constructors]` describes, we now refrain from unboxing recursive data type arguments, for two reasons: 1. Relating to run/alloc perf: Similar to `Note [CPR for recursive data constructors]`, it seldomly improves run/alloc performance if we just unbox a finite number of layers of a potentially huge data structure. 2. Relating to ghc/alloc perf: Inductive definitions on single-product recursive data types like the one in T11545 will (diverge, and) have very deep demand signatures before any other abortion mechanism in Demand analysis is triggered. That leads to great and unnecessary churn on Demand analysis when ultimately we will never make use of any nested strictness information anyway. Conclusion: Discard nested demand and boxity information on such recursive types with the help of `Note [Detecting recursive data constructors]`. I also implemented `GHC.Types.Unique.MemoFun.memoiseUniqueFun` in order to avoid the overhead of repeated calls to `GHC.Core.Opt.WorkWrap.Utils.isRecDataCon`. It's nice and simple and guards against some smaller regressions in T9233 and T16577. ghc/alloc performance-wise, this patch is a very clear win: Test Metric value New value Change --------------------------------------------------------------------------------------- LargeRecord(normal) ghc/alloc 6,141,071,720 6,099,871,216 -0.7% MultiLayerModulesTH_OneShot(normal) ghc/alloc 2,740,973,040 2,705,146,640 -1.3% T11545(normal) ghc/alloc 945,475,492 85,768,928 -90.9% GOOD T13056(optasm) ghc/alloc 370,245,880 326,980,632 -11.7% GOOD T18304(normal) ghc/alloc 90,933,944 76,998,064 -15.3% GOOD T9872a(normal) ghc/alloc 1,800,576,840 1,792,348,760 -0.5% T9872b(normal) ghc/alloc 2,086,492,432 2,073,991,848 -0.6% T9872c(normal) ghc/alloc 1,750,491,240 1,737,797,832 -0.7% TcPlugin_RewritePerf(normal) ghc/alloc 2,286,813,400 2,270,957,896 -0.7% geo. mean -2.9% No noteworthy change in run/alloc either. NoFib results show slight wins, too: -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- constraints -1.9% -1.4% fasta -3.6% -2.7% reverse-complem -0.3% -0.9% treejoin -0.0% -0.3% -------------------------------------------------------------------------------- Min -3.6% -2.7% Max +0.1% +0.1% Geometric Mean -0.1% -0.1% Metric Decrease: T11545 T13056 T18304 - - - - - ab618309 by Vladislav Zavialov at 2022-03-15T18:34:38+03:00 Export (~) from Data.Type.Equality (#18862) * Users can define their own (~) type operator * Haddock can display documentation for the built-in (~) * New transitional warnings implemented: -Wtype-equality-out-of-scope -Wtype-equality-requires-operators Updates the haddock submodule. - - - - - 577135bf by Aaron Allen at 2022-03-16T02:27:48-04:00 Convert Diagnostics in GHC.Tc.Gen.Foreign Converts all uses of 'TcRnUnknownMessage' to proper diagnostics. - - - - - c1fed9da by Aaron Allen at 2022-03-16T02:27:48-04:00 Suggest FFI extensions as hints (#20116) - Use extension suggestion hints instead of suggesting extensions in the error message body for several FFI errors. - Adds a test case for `TcRnForeignImportPrimExtNotSet` - - - - - a33d1045 by Zubin Duggal at 2022-03-16T02:28:24-04:00 TH: allow negative patterns in quotes (#20711) We still don't allow negative overloaded patterns. Earler all negative patterns were treated as negative overloaded patterns. Now, we expliclty check the extension field to see if the pattern is actually a negative overloaded pattern - - - - - 1575c4a5 by Sebastian Graf at 2022-03-16T02:29:03-04:00 Demand: Let `Boxed` win in `lubBoxity` (#21119) Previously, we let `Unboxed` win in `lubBoxity`, which is unsoundly optimistic in terms ob Boxity analysis. "Unsoundly" in the sense that we sometimes unbox parameters that we better shouldn't unbox. Examples are #18907 and T19871.absent. Until now, we thought that this hack pulled its weight becuase it worked around some shortcomings of the phase separation between Boxity analysis and CPR analysis. But it is a gross hack which caused regressions itself that needed all kinds of fixes and workarounds. See for example #20767. It became impossible to work with in !7599, so I want to remove it. For example, at the moment, `lubDmd B dmd` will not unbox `dmd`, but `lubDmd A dmd` will. Given that `B` is supposed to be the bottom element of the lattice, it's hardly justifiable to get a better demand when `lub`bing with `A`. The consequence of letting `Boxed` win in `lubBoxity` is that we *would* regress #2387, #16040 and parts of #5075 and T19871.sumIO, until Boxity and CPR are able to communicate better. Fortunately, that is not the case since I could tweak the other source of optimism in Boxity analysis that is described in `Note [Unboxed demand on function bodies returning small products]` so that we *recursively* assume unboxed demands on function bodies returning small products. See the updated Note. `Note [Boxity for bottoming functions]` describes why we need bottoming functions to have signatures that say that they deeply unbox their arguments. In so doing, I had to tweak `finaliseArgBoxities` so that it will never unbox recursive data constructors. This is in line with our handling of them in CPR. I updated `Note [Which types are unboxed?]` to reflect that. In turn we fix #21119, #20767, #18907, T19871.absent and get a much simpler implementation (at least to think about). We can also drop the very ad-hoc definition of `deferAfterPreciseException` and its Note in favor of the simple, intuitive definition we used to have. Metric Decrease: T16875 T18223 T18698a T18698b hard_hole_fits Metric Increase: LargeRecord MultiComponentModulesRecomp T15703 T8095 T9872d Out of all the regresions, only the one in T9872d doesn't vanish in a perf build, where the compiler is bootstrapped with -O2 and thus SpecConstr. Reason for regressions: * T9872d is due to `ty_co_subst` taking its `LiftingContext` boxed. That is because the context is passed to a function argument, for example in `liftCoSubstTyVarBndrUsing`. * In T15703, LargeRecord and T8095, we get a bit more allocations in `expand_syn` and `piResultTys`, because a `TCvSubst` isn't unboxed. In both cases that guards against reboxing in some code paths. * The same is true for MultiComponentModulesRecomp, where we get less unboxing in `GHC.Unit.Finder.$wfindInstalledHomeModule`. In a perf build, allocations actually *improve* by over 4%! Results on NoFib: -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- awards -0.4% +0.3% cacheprof -0.3% +2.4% fft -1.5% -5.1% fibheaps +1.2% +0.8% fluid -0.3% -0.1% ida +0.4% +0.9% k-nucleotide +0.4% -0.1% last-piece +10.5% +13.9% lift -4.4% +3.5% mandel2 -99.7% -99.8% mate -0.4% +3.6% parser -1.0% +0.1% puzzle -11.6% +6.5% reverse-complem -3.0% +2.0% scs -0.5% +0.1% sphere -0.4% -0.2% wave4main -8.2% -0.3% -------------------------------------------------------------------------------- Summary excludes mandel2 because of excessive bias Min -11.6% -5.1% Max +10.5% +13.9% Geometric Mean -0.2% +0.3% -------------------------------------------------------------------------------- Not bad for a bug fix. The regression in `last-piece` could become a win if SpecConstr would work on non-recursive functions. The regression in `fibheaps` is due to `Note [Reboxed crud for bottoming calls]`, e.g., #21128. - - - - - bb779b90 by sheaf at 2022-03-16T02:29:42-04:00 Add a regression test for #21130 This problem was due to a bug in cloneWanted, which was incorrectly creating a coercion hole to hold an evidence variable. This bug was introduced by 8bb52d91 and fixed in 81740ce8. Fixes #21130 - - - - - 0f0e2394 by Tamar Christina at 2022-03-17T10:16:37-04:00 linker: Initial Windows C++ exception unwinding support - - - - - 36d20d4d by Tamar Christina at 2022-03-17T10:16:37-04:00 linker: Fix ADDR32NB relocations on Windows - - - - - 8a516527 by Tamar Christina at 2022-03-17T10:16:37-04:00 testsuite: properly escape string paths - - - - - 1a0dd008 by sheaf at 2022-03-17T10:17:13-04:00 Hadrian: account for change in late-ccs flag The late cost centre flag was renamed from -fprof-late-ccs to -fprof-late in 7fe07143, but this change hadn't been propagated to Hadrian. - - - - - 8561c1af by romes at 2022-03-18T05:10:58-04:00 TTG: Refactor HsBracket - - - - - 19163397 by romes at 2022-03-18T05:10:58-04:00 Type-checking untyped brackets When HsExpr GhcTc, the HsBracket constructor should hold a HsBracket GhcRn, rather than an HsBracket GhcTc. We make use of the HsBracket p extension constructor (XBracket (XXBracket p)) to hold an HsBracket GhcRn when the pass is GhcTc See !4782 https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782 - - - - - 310890a5 by romes at 2022-03-18T05:10:58-04:00 Separate constructors for typed and untyped brackets Split HsBracket into HsTypedBracket and HsUntypedBracket. Unfortunately, we still cannot get rid of instance XXTypedBracket GhcTc = HsTypedBracket GhcRn despite no longer requiring it for typechecking, but rather because the TH desugarer works on GhcRn rather than GhcTc (See GHC.HsToCore.Quote) - - - - - 4a2567f5 by romes at 2022-03-18T05:10:58-04:00 TTG: Refactor bracket for desugaring during tc When desugaring a bracket we want to desugar /renamed/ rather than /typechecked/ code; So in (HsExpr GhcTc) tree, we must have a (HsExpr GhcRn) for the quotation itself. This commit reworks the TTG refactor on typed and untyped brackets by storing the /renamed/ code in the bracket field extension rather than in the constructor extension in `HsQuote` (previously called `HsUntypedBracket`) See Note [The life cycle of a TH quotation] and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782 - - - - - b056adc8 by romes at 2022-03-18T05:10:58-04:00 TTG: Make HsQuote GhcTc isomorphic to NoExtField An untyped bracket `HsQuote p` can never be constructed with `p ~ GhcTc`. This is because we don't typecheck `HsQuote` at all. That's OK, because we also never use `HsQuote GhcTc`. To enforce this at the type level we make `HsQuote GhcTc` isomorphic to `NoExtField` and impossible to construct otherwise, by using TTG field extensions to make all constructors, except for `XQuote` (which takes `NoExtField`), unconstructable, with `DataConCantHappen` This is explained more in detail in Note [The life cycle of a TH quotation] Related discussion: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782 - - - - - ac3b2e7d by romes at 2022-03-18T05:10:58-04:00 TTG: TH brackets finishing touches Rewrite the critical notes and fix outdated ones, use `HsQuote GhcRn` (in `HsBracketTc`) for desugaring regardless of the bracket being typed or untyped, remove unused `EpAnn` from `Hs*Bracket GhcRn`, zonkExpr factor out common brackets code, ppr_expr factor out common brackets code, and fix tests, to finish MR https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782. ------------------------- Metric Decrease: hard_hole_fits ------------------------- - - - - - d147428a by Ben Gamari at 2022-03-18T05:11:35-04:00 codeGen: Fix signedness of jump table indexing Previously while constructing the jump table index we would zero-extend the discriminant before subtracting the start of the jump-table. This goes subtly wrong in the case of a sub-word, signed discriminant, as described in the included Note. Fix this in both the PPC and X86 NCGs. Fixes #21186. - - - - - 435a3d5d by Ben Gamari at 2022-03-18T05:11:35-04:00 testsuite: Add test for #21186 - - - - - e9d8de93 by Zubin Duggal at 2022-03-19T07:35:49-04:00 TH: Fix pretty printing of newtypes with operators and GADT syntax (#20868) The pretty printer for regular data types already accounted for these, and had some duplication with the newtype pretty printer. Factoring the logic out into a common function and using it for both newtypes and data declarations is enough to fix the bug. - - - - - 244da9eb by sheaf at 2022-03-19T07:36:24-04:00 List GHC.Event.Internal in base.cabal on Windows GHC.Event.Internal was not listed in base.cabal on Windows. This caused undefined reference errors. This patch adds it back, by moving it out of the OS-specific logic in base.cabal. Fixes #21245. - - - - - d1c03719 by Andreas Klebinger at 2022-03-19T07:37:00-04:00 Compact regions: Maintain tags properly Fixes #21251 - - - - - d45bb701 by romes at 2022-03-19T07:37:36-04:00 Remove dead code HsDoRn - - - - - c842611f by nineonine at 2022-03-20T21:16:06-04:00 Revamp derived Eq instance code generation (#17240) This patch improves code generation for derived Eq instances. The idea is to use 'dataToTag' to evaluate both arguments. This allows to 'short-circuit' when tags do not match. Unfortunately, inner evals are still present when we branch on tags. This is due to the way 'dataToTag#' primop evaluates its argument in the code generator. #21207 was created to explore further optimizations. Metric Decrease: LargeRecord - - - - - 52ffd38c by Sylvain Henry at 2022-03-20T21:16:46-04:00 Avoid some SOURCE imports - - - - - b91798be by Zubin Duggal at 2022-03-23T13:39:39-04:00 hi haddock: Lex and store haddock docs in interface files Names appearing in Haddock docstrings are lexed and renamed like any other names appearing in the AST. We currently rename names irrespective of the namespace, so both type and constructor names corresponding to an identifier will appear in the docstring. Haddock will select a given name as the link destination based on its own heuristics. This patch also restricts the limitation of `-haddock` being incompatible with `Opt_KeepRawTokenStream`. The export and documenation structure is now computed in GHC and serialised in .hi files. This can be used by haddock to directly generate doc pages without reparsing or renaming the source. At the moment the operation of haddock is not modified, that's left to a future patch. Updates the haddock submodule with the minimum changes needed. - - - - - 78db231f by Cheng Shao at 2022-03-23T13:40:17-04:00 configure: bump LlvmMaxVersion to 14 LLVM 13.0.0 is released in Oct 2021, and latest head validates against LLVM 13 just fine if LlvmMaxVersion is bumped. - - - - - b06e5dd8 by Adam Sandberg Ericsson at 2022-03-23T13:40:54-04:00 docs: clarify the eventlog format documentation a little bit - - - - - 4dc62498 by Matthew Pickering at 2022-03-23T13:41:31-04:00 Fix behaviour of -Wunused-packages in ghci Ticket #21110 points out that -Wunused-packages behaves a bit unusually in GHCi. Now we define the semantics for -Wunused-packages in interactive mode as follows: * If you use -Wunused-packages on an initial load then the warning is reported. * If you explicitly set -Wunused-packages on the command line then the warning is displayed (until it is disabled) * If you then subsequently modify the set of available targets by using :load or :cd (:cd unloads everything) then the warning is (silently) turned off. This means that every :r the warning is printed if it's turned on (but you did ask for it). Fixes #21110 - - - - - fed05347 by Ben Gamari at 2022-03-23T13:42:07-04:00 rts/adjustor: Place adjustor templates in data section on all OSs In !7604 we started placing adjustor templates in the data section on Linux as some toolchains there reject relocations in the text section. However, it turns out that OpenBSD also exhibits this restriction. Fix this by *always* placing adjustor templates in the data section. Fixes #21155. - - - - - db32bb8c by Zubin Duggal at 2022-03-23T13:42:44-04:00 Improve error message when warning about unsupported LLVM version (#20958) Change the wording to make it clear that the upper bound is non-inclusive. - - - - - f214349a by Ben Gamari at 2022-03-23T13:43:20-04:00 rts: Untag function field in scavenge_PAP_payload Previously we failed to untag the function closure when scavenging the payload of a PAP, resulting in an invalid closure pointer being passed to scavenge_large_bitmap and consequently #21254. Fix this. Fixes #21254 - - - - - e6d0e287 by Ben Gamari at 2022-03-23T13:43:20-04:00 rts: Don't mark object code in markCAFs unless necessary Previously `markCAFs` would call `markObjectCode` even in non-major GCs. This is problematic since `prepareUnloadCheck` is not called in such GCs, meaning that the section index has not been updated. Fixes #21254 - - - - - 1a7cf096 by Sylvain Henry at 2022-03-23T13:44:05-04:00 Avoid redundant imports of GHC.Driver.Session Remove GHC.Driver.Session imports that weren't considered as redundant because of the reexport of PlatformConstants. Also remove this reexport as modules using this datatype should import GHC.Platform instead. - - - - - e3f60577 by Sylvain Henry at 2022-03-23T13:44:05-04:00 Reverse dependency between StgToCmm and Runtime.Heap.Layout - - - - - e6585ca1 by Sylvain Henry at 2022-03-23T13:44:46-04:00 Define filterOut with filter filter has fusion rules that filterOut lacks - - - - - c58d008c by Ryan Scott at 2022-03-24T06:10:43-04:00 Fix and simplify DeriveAnyClass's context inference using SubTypePredSpec As explained in `Note [Gathering and simplifying constraints for DeriveAnyClass]` in `GHC.Tc.Deriv.Infer`, `DeriveAnyClass` infers instance contexts by emitting implication constraints. Previously, these implication constraints were constructed by hand. This is a terribly trick thing to get right, as it involves a delicate interplay of skolemisation, metavariable instantiation, and `TcLevel` bumping. Despite much effort, we discovered in #20719 that the implementation was subtly incorrect, leading to valid programs being rejected. While we could scrutinize the code that manually constructs implication constraints and repair it, there is a better, less error-prone way to do things. After all, the heart of `DeriveAnyClass` is generating code which fills in each class method with defaults, e.g., `foo = $gdm_foo`. Typechecking this sort of code is tantamount to calling `tcSubTypeSigma`, as we much ensure that the type of `$gdm_foo` is a subtype of (i.e., more polymorphic than) the type of `foo`. As an added bonus, `tcSubTypeSigma` is a battle-tested function that handles skolemisation, metvariable instantiation, `TcLevel` bumping, and all other means of tricky bookkeeping correctly. With this insight, the solution to the problems uncovered in #20719 is simple: use `tcSubTypeSigma` to check if `$gdm_foo`'s type is a subtype of `foo`'s type. As a side effect, `tcSubTypeSigma` will emit exactly the implication constraint that we were attempting to construct by hand previously. Moreover, it does so correctly, fixing #20719 as a consequence. This patch implements the solution thusly: * The `PredSpec` data type (previously named `PredOrigin`) is now split into `SimplePredSpec`, which directly stores a `PredType`, and `SubTypePredSpec`, which stores the actual and expected types in a subtype check. `SubTypePredSpec` is only used for `DeriveAnyClass`; all other deriving strategies use `SimplePredSpec`. * Because `tcSubTypeSigma` manages the finer details of type variable instantiation and constraint solving under the hood, there is no longer any need to delicately split apart the method type signatures in `inferConstraintsAnyclass`. This greatly simplifies the implementation of `inferConstraintsAnyclass` and obviates the need to store skolems, metavariables, or given constraints in a `ThetaSpec` (previously named `ThetaOrigin`). As a bonus, this means that `ThetaSpec` now simply becomes a synonym for a list of `PredSpec`s, which is conceptually much simpler than it was before. * In `simplifyDeriv`, each `SubTypePredSpec` results in a call to `tcSubTypeSigma`. This is only performed for its side effect of emitting an implication constraint, which is fed to the rest of the constraint solving machinery in `simplifyDeriv`. I have updated `Note [Gathering and simplifying constraints for DeriveAnyClass]` to explain this in more detail. To make the changes in `simplifyDeriv` more manageable, I also performed some auxiliary refactoring: * Previously, every iteration of `simplifyDeriv` was skolemising the type variables at the start, simplifying, and then performing a reverse substitution at the end to un-skolemise the type variables. This is not necessary, however, since we can just as well skolemise once at the beginning of the `deriving` pipeline and zonk the `TcTyVar`s after `simplifyDeriv` is finished. This patch does just that, having been made possible by prior work in !7613. I have updated `Note [Overlap and deriving]` in `GHC.Tc.Deriv.Infer` to explain this, and I have also left comments on the relevant data structures (e.g., `DerivEnv` and `DerivSpec`) to explain when things might be `TcTyVar`s or `TyVar`s. * All of the aforementioned cleanup allowed me to remove an ad hoc deriving-related in `checkImplicationInvariants`, as all of the skolems in a `tcSubTypeSigma`–produced implication constraint should now be `TcTyVar` at the time the implication is created. * Since `simplifyDeriv` now needs a `SkolemInfo` and `UserTypeCtxt`, I have added `ds_skol_info` and `ds_user_ctxt` fields to `DerivSpec` to store these. Similarly, I have also added a `denv_skol_info` field to `DerivEnv`, which ultimately gets used to initialize the `ds_skol_info` in a `DerivSpec`. Fixes #20719. - - - - - 21680fb0 by Sebastian Graf at 2022-03-24T06:11:19-04:00 WorkWrap: Handle partial FUN apps in `isRecDataCon` (#21265) Partial FUN apps like `(->) Bool` aren't detected by `splitFunTy_maybe`. A silly oversight that is easily fixed by replacing `splitFunTy_maybe` with a guard in the `splitTyConApp_maybe` case. But fortunately, Simon nudged me into rewriting the whole `isRecDataCon` function in a way that makes it much shorter and hence clearer which DataCons are actually considered as recursive. Fixes #21265. - - - - - a2937e2b by Matthew Pickering at 2022-03-24T17:13:22-04:00 Add test for T21035 This test checks that you are allowed to explicitly supply object files for dependencies even if you haven't got the shared object for that library yet. Fixes #21035 - - - - - 1756d547 by Matthew Pickering at 2022-03-24T17:13:58-04:00 Add check to ensure we are not building validate jobs for releases - - - - - 99623358 by Matthew Pickering at 2022-03-24T17:13:58-04:00 hadrian: Correct generation of hsc2hs wrapper If you inspect the inside of a wrapper script for hsc2hs you will see that the cflag and lflag values are concatenated incorrectly. ``` HSC2HS_EXTRA="--cflag=-U__i686--lflag=-fuse-ld=gold" ``` It should instead be ``` HSC2HS_EXTRA="--cflag=-U__i686 --lflag=-fuse-ld=gold" ``` Fixes #21221 - - - - - fefd4e31 by Matthew Pickering at 2022-03-24T17:13:59-04:00 testsuite: Remove library dependenices from T21119 These dependencies would affect the demand signature depending on various rules and so on. Fixes #21271 - - - - - 5ff690b8 by Matthew Pickering at 2022-03-24T17:13:59-04:00 ci: Generate jobs for all normal builds and use hadrian for all builds This commit introduces a new script (.gitlab/gen_ci.hs) which generates a yaml file (.gitlab/jobs.yaml) which contains explicit descriptions for all the jobs we want to run. The jobs are separated into three categories: * validate - jobs run on every MR * nightly - jobs run once per day on the master branch * release - jobs for producing release artifacts The generation script is a Haskell program which includes a DSL for specifying the different jobs. The hope is that it's easier to reason about the different jobs and how the variables are merged together rather than the unclear and opaque yaml syntax. The goal is to fix issues like #21190 once and for all.. The `.gitlab/jobs.yaml` can be generated by running the `.gitlab/generate_jobs` script. You have to do this manually. Another consequence of this patch is that we use hadrian for all the validate, nightly and release builds on all platforms. - - - - - 1d673aa2 by Christiaan Baaij at 2022-03-25T11:35:49-04:00 Add the OPAQUE pragma A new pragma, `OPAQUE`, that ensures that every call of a named function annotated with an `OPAQUE` pragma remains a call of that named function, not some name-mangled variant. Implements GHC proposal 0415: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0415-opaque-pragma.rst This commit also updates the haddock submodule to handle the newly introduced lexer tokens corresponding to the OPAQUE pragma. - - - - - 83f5841b by Bodigrim at 2022-03-25T11:36:31-04:00 Add instance Lift ByteArray - - - - - 7cc1184a by Matthew Pickering at 2022-03-25T11:37:07-04:00 Make -ddump-rn-ast and -ddump-tc-ast work in GHCi Fixes #17830 - - - - - 940feaf3 by Sylvain Henry at 2022-03-25T11:37:47-04:00 Modularize Tidy (#17957) - Factorize Tidy options into TidyOpts datatype. Initialize it in GHC.Driver.Config.Tidy - Same thing for StaticPtrOpts - Perform lookups of unpackCString[Utf8]# once in initStaticPtrOpts instead of for every use of mkStringExprWithFS - - - - - 25101813 by Takenobu Tani at 2022-03-28T01:16:02-04:00 users-guide: Correct markdown for profiling This patch corrects some markdown. [skip ci] - - - - - c832ae93 by Matthew Pickering at 2022-03-28T01:16:38-04:00 hadrian: Flag cabal flag handling This patch basically deletes some ad-hoc handling of Cabal Flags and replaces it with a correct query of the LocalBuildInfo. The flags in the local build info can be modified by users by passing hadrian options For example (!4331) ``` *.genapply.cabal.configure.opts += --flags=unregisterised ``` And all the flags specified by the `Cabal Flags` builder were already passed to configure properly using `--flags`. - - - - - a9f3a5c6 by Ben Gamari at 2022-03-28T01:16:38-04:00 Disable text's dependency on simdutf by default Unfortunately we are simply not currently in a good position to robustly ship binary distributions which link against C++ code like simdutf. Fixes #20724. - - - - - eff86e8a by Richard Eisenberg at 2022-03-28T01:17:14-04:00 Add Red Herring to Note [What might equal later?] Close #21208. - - - - - 12653be9 by jberryman at 2022-03-28T01:17:55-04:00 Document typed splices inhibiting unused bind detection (#16524) - - - - - 4aeade15 by Adam Sandberg Ericsson at 2022-03-28T01:18:31-04:00 users-guide: group ticky-ticky profiling under one heading - - - - - cc59648a by Sylvain Henry at 2022-03-28T01:19:12-04:00 Hadrian: allow testsuite to run with cross-compilers (#21292) - - - - - 89cb1315 by Matthew Pickering at 2022-03-28T01:19:48-04:00 hadrian: Add show target to bindist makefile Some build systems use "make show" to query facts about the bindist, for example: ``` make show VALUE=ProjectVersion > version ``` to determine the ProjectVersion - - - - - 8229885c by Alan Zimmerman at 2022-03-28T19:23:28-04:00 EPA: let stmt with semicolon has wrong anchor The code let ;x =1 Captures the semicolon annotation, but did not widen the anchor in the ValBinds. Fix that. Closes #20247 - - - - - 2c12627c by Ryan Scott at 2022-03-28T19:24:04-04:00 Consistently attach SrcSpans to sub-expressions in TH splices Before, `GHC.ThToHs` was very inconsistent about where various sub-expressions would get the same `SrcSpan` from the original TH splice location or just a generic `noLoc` `SrcSpan`. I have ripped out all uses of `noLoc` in favor of the former instead, and I have added a `Note [Source locations within TH splices]` to officially enshrine this design choice. Fixes #21299. - - - - - 789add55 by Zubin Duggal at 2022-03-29T13:07:22-04:00 Fix all invalid haddock comments in the compiler Fixes #20935 and #20924 - - - - - 967dad03 by Zubin Duggal at 2022-03-29T13:07:22-04:00 hadrian: Build lib:GHC with -haddock and -Winvalid-haddock (#21273) - - - - - ad09a5f7 by sheaf at 2022-03-29T13:08:05-04:00 Hadrian: make DDEBUG separate from debugged RTS This patchs separates whether -DDEBUG is enabled (i.e. whether debug assertions are enabled) from whether we are using the debugged RTS (i.e. GhcDebugged = YES). This means that we properly skip tests which have been marked with `when(compiler_debugged(), skip)`. Fixes #21113, #21153 and #21234 - - - - - 840a6811 by Matthew Pickering at 2022-03-29T13:08:42-04:00 RTS: Zero gc_cpu_start and gc_cpu_end after accounting When passed a combination of `-N` and `-qn` options the cpu time for garbage collection was being vastly overcounted because the counters were not being zeroed appropiately. When -qn1 is passed, only 1 of the N avaiable GC threads is chosen to perform work, the rest are idle. At the end of the GC period, stat_endGC traverses all the GC threads and adds up the elapsed time from each of them. For threads which didn't participate in this GC, the value of the cpu time should be zero, but before this patch, the counters were not zeroed and hence we would count the same elapsed time on many subsequent iterations (until the thread participated in a GC again). The most direct way to zero these fields is to do so immediately after the value is added into the global counter, after which point they are never used again. We also tried another approach where we would zero the counter in yieldCapability but there are some (undiagnosed) siations where a capbility would not pass through yieldCapability before the GC ended and the same double counting problem would occur. Fixes #21082 - - - - - dda46e2d by Matthew Pickering at 2022-03-29T13:09:18-04:00 Add test for T21306 Fixes #21306 - - - - - f07c7766 by Jakob Brünker at 2022-03-30T03:10:33-04:00 Give parsing plugins access to errors Previously, when the parser produced non-fatal errors (i.e. it produced errors but the 'PState' is 'POk'), compilation would be aborted before the 'parsedResultAction' of any plugin was invoked. This commit changes that, so that such that 'parsedResultAction' gets collections of warnings and errors as argument, and must return them after potentially modifying them. Closes #20803 - - - - - e5dfde75 by Ben Gamari at 2022-03-30T03:11:10-04:00 Fix reference to Note [FunBind vs PatBind] This Note was renamed in 2535a6716202253df74d8190b028f85cc6d21b72 yet this occurrence was not updated. - - - - - 21894a63 by Krzysztof Gogolewski at 2022-03-30T03:11:45-04:00 Refactor: make primtypes independent of PrimReps Previously, 'pcPrimTyCon', the function used to define a primitive type, was taking a PrimRep, only to convert it to a RuntimeRep. Now it takes a RuntimeRep directly. Moved primRepToRuntimeRep to GHC.Types.RepType. It is now located next to its inverse function runtimeRepPrimRep. Now GHC.Builtin.Types.Prim no longer mentions PrimRep, and GHC.Types.RepType no longer imports GHC.Builtin.Types.Prim. Removed unused functions `primRepsToRuntimeRep` and `mkTupleRep`. Removed Note [PrimRep and kindPrimRep] - it was never referenced, didn't belong to Types.Prim, and Note [Getting from RuntimeRep to PrimRep] is more comprehensive. - - - - - 43da2963 by Matthew Pickering at 2022-03-30T09:55:49+01:00 Fix mention of non-existent "rehydrateIface" function [skip ci] Fixes #21303 - - - - - 6793a20f by gershomb at 2022-04-01T10:33:46+01:00 Remove wrong claim about naturality law. This docs change removes a longstanding confusion in the Traversable docs. The docs say "(The naturality law is implied by parametricity and thus so is the purity law [1, p15].)". However if one reads the reference a different "natural" law is implied by parametricity. The naturality law given as a law here is imposed. Further, the reference gives examples which violate both laws -- so they cannot be implied by parametricity. This PR just removes the wrong claim. - - - - - 5beeff46 by Ben Gamari at 2022-04-01T10:34:39+01:00 Refactor handling of global initializers GHC uses global initializers for a number of things including cost-center registration, info-table provenance registration, and setup of foreign exports. Previously, the global initializer arrays which referenced these initializers would live in the object file of the C stub, which would then be merged into the main object file of the module. Unfortunately, this approach is no longer tenable with the move to Clang/LLVM on Windows (see #21019). Specifically, lld's PE backend does not support object merging (that is, the -r flag). Instead we are now rather packaging a module's object files into a static library. However, this is problematic in the case of initializers as there are no references to the C stub object in the archive, meaning that the linker may drop the object from the final link. This patch refactors our handling of global initializers to instead place initializer arrays within the object file of the module to which they belong. We do this by introducing a Cmm data declaration containing the initializer array in the module's Cmm stream. While the initializer functions themselves remain in separate C stub objects, the reference from the module's object ensures that they are not dropped from the final link. In service of #21068. - - - - - 3e6fe71b by Matthew Pickering at 2022-04-01T10:35:41+01:00 Fix remaining issues in eventlog types (gen_event_types.py) * The size of End concurrent mark phase looks wrong and, it used to be 4 and now it's 0. * The size of Task create is wrong, used to be 18 and now 14. * The event ticky-ticky entry counter begin sample has the wrong name * The event ticky-ticky entry counter being sample has the wrong size, was 0 now 32. Closes #21070 - - - - - 7847f47a by Ben Gamari at 2022-04-01T10:35:41+01:00 users-guide: Fix a few small issues in eventlog format descriptions The CONC_MARK_END event description didn't mention its payload. Clarify the meaning of the CREATE_TASK's payload. - - - - - acfd5a4c by Matthew Pickering at 2022-04-01T10:35:53+01:00 ci: Regenerate jobs.yaml It seems I forgot to update this to reflect the current state of gen_ci.hs - - - - - a952dd80 by Matthew Pickering at 2022-04-01T10:35:59+01:00 ci: Attempt to fix windows cache issues It appears that running the script directly does nothing (no info is printed about saving the cache). - - - - - fb65e6e3 by Adrian Ratiu at 2022-04-01T10:49:52+01:00 fp_prog_ar.m4: take AR var into consideration In ChromeOS and Gentoo we want the ability to use LLVM ar instead of GNU ar even though both are installed, thus we pass (for eg) AR=llvm-ar to configure. Unfortunately GNU ar always gets picked regardless of the AR setting because the check does not consider the AR var when setting fp_prog_ar, hence this fix. - - - - - 1daaefdf by Greg Steuck at 2022-04-01T10:50:16+01:00 T13366 requires c++ & c++abi libraries on OpenBSD Fixes this failure: =====> 1 of 1 [0, 0, 0] T13366(normal) 1 of 1 [0, 0, 0] Compile failed (exit code 1) errors were: <no location info>: error: user specified .o/.so/.DLL could not be loaded (File not found) Whilst trying to load: (dynamic) stdc++ Additional directories searched: (none) *** unexpected failure for T13366(normal) - - - - - 18e6c85b by Jakob Bruenker at 2022-04-01T10:54:28+01:00 new datatypes for parsedResultAction Previously, the warnings and errors were given and returned as a tuple (Messages PsWarnings, Messages PsErrors). Now, it's just PsMessages. This, together with the HsParsedModule the parser plugin gets and returns, has been wrapped up as ParsedResult. - - - - - 9727e592 by Morrow at 2022-04-01T10:55:12+01:00 Clarify that runghc interprets the input program - - - - - f589dea3 by sheaf at 2022-04-01T10:59:58+01:00 Unify RuntimeRep arguments in ty_co_match The `ty_co_match` function ignored the implicit RuntimeRep coercions that occur in a `FunCo`. Even though a comment explained that this should be fine, #21205 showed that it could result in discarding a RuntimeRep coercion, and thus discarding an important cast entirely. With this patch, we first match the kinds in `ty_co_match`. Fixes #21205 ------------------------- Metric Increase: T12227 T18223 ------------------------- - - - - - 6f4dc372 by Andreas Klebinger at 2022-04-01T11:01:35+01:00 Export MutableByteArray from Data.Array.Byte This implements CLC proposal #49 - - - - - 5df9f5e7 by ARATA Mizuki at 2022-04-01T11:02:35+01:00 Add test cases for #20640 Closes #20640 - - - - - 8334ff9e by Krzysztof Gogolewski at 2022-04-01T11:03:16+01:00 Minor cleanup - Remove unused functions exprToCoercion_maybe, applyTypeToArg, typeMonoPrimRep_maybe, runtimeRepMonoPrimRep_maybe. - Replace orValid with a simpler check - Use splitAtList in applyTysX - Remove calls to extra_clean in the testsuite; it does not do anything. Metric Decrease: T18223 - - - - - b2785cfc by Eric Lindblad at 2022-04-01T11:04:07+01:00 hadrian typos - - - - - 418e6fab by Eric Lindblad at 2022-04-01T11:04:12+01:00 two typos - - - - - dd7c7c99 by Phil de Joux at 2022-04-01T11:04:56+01:00 Add tests and docs on plugin args and order. - - - - - 3e209a62 by MaxHearnden at 2022-04-01T11:05:19+01:00 Change may not to might not - - - - - b84380d3 by Matthew Pickering at 2022-04-01T11:07:27+01:00 hadrian: Remove linters-common from bindist Zubin observed that the bindists contains the utility library linters-common. There are two options: 1. Make sure only the right files are added into the bindist.. a bit tricky due to the non-trivial structure of the lib directory. 2. Remove the bad files once they get copied in.. a bit easier So I went for option 2 but we perhaps should go for option 1 in the future. Fixes #21203 - - - - - ba9904c1 by Zubin Duggal at 2022-04-01T11:07:31+01:00 hadrian: allow testing linters with out of tree compilers - - - - - 26547759 by Matthew Pickering at 2022-04-01T11:07:35+01:00 hadrian: Introduce CheckProgram datatype to replace a 7-tuple - - - - - df65d732 by Jakob Bruenker at 2022-04-01T11:08:28+01:00 Fix panic when pretty printing HsCmdLam When pretty printing a HsCmdLam with more than one argument, GHC panicked because of a missing case. This fixes that. Closes #21300 - - - - - ad6cd165 by John Ericson at 2022-04-01T11:10:06+01:00 hadrian: Remove vestigial -this-unit-id support check This has been dead code since 400ead81e80f66ad7b1260b11b2a92f25ccc3e5a. - - - - - 8ca7ab81 by Matthew Pickering at 2022-04-01T11:10:23+01:00 hadrian: Fix race involving empty package databases There was a small chance of a race occuring between the small window of 1. The first package (.conf) file get written into the database 2. hadrian calling "ghc-pkg recache" to refresh the package.conf file In this window the package database would contain rts.conf but not a package.cache file, and therefore if ghc was invoked it would error because it was missing. To solve this we call "ghc-pkg recache" at when the database is created by shake by writing the stamp file into the database folder. This also creates the package.cache file and so avoids the possibility of this race. - - - - - cc4ec64b by Matthew Pickering at 2022-04-01T11:11:05+01:00 hadrian: Add assertion that in/out tree args are the same There have been a few instances where this calculation was incorrect, so we add a non-terminal assertion when now checks they the two computations indeed compute the same thing. Fixes #21285 - - - - - 691508d8 by Matthew Pickering at 2022-04-01T11:13:10+01:00 hlint: Ignore suggestions in generated HaddockLex file With the make build system this file ends up in the compiler/ subdirectory so is linted. With hadrian, the file ends up in _build so it's not linted. Fixes #21313 - - - - - f8f152e7 by Krzysztof Gogolewski at 2022-04-01T11:14:08+01:00 Change GHC.Prim to GHC.Exts in docs and tests Users are supposed to import GHC.Exts rather than GHC.Prim. Part of #18749. - - - - - f8fc6d2e by Matthew Pickering at 2022-04-01T11:15:24+01:00 driver: Improve -Wunused-packages error message (and simplify implementation) In the past I improved the part of -Wunused-packages which found which packages were used. Now I improve the part which detects which ones were specified. The key innovation is to use the explicitUnits field from UnitState which has the result of resolving the package flags, so we don't need to mess about with the flag arguments from DynFlags anymore. The output now always includes the package name and version (and the flag which exposed it). ``` The following packages were specified via -package or -package-id flags, but were not needed for compilation: - bytestring-0.11.2.0 (exposed by flag -package bytestring) - ghc-9.3 (exposed by flag -package ghc) - process-1.6.13.2 (exposed by flag -package process) ``` Fixes #21307 - - - - - 5e5a12d9 by Matthew Pickering at 2022-04-01T11:15:32+01:00 driver: In oneshot mode, look for interface files in hidir How things should work: * -i is the search path for source files * -hidir explicitly sets the search path for interface files and the output location for interface files. * -odir sets the search path and output location for object files. Before in one shot mode we would look for the interface file in the search locations given by `-i`, but then set the path to be in the `hidir`, so in unusual situations the finder could find an interface file in the `-i` dir but later fail because it tried to read the interface file from the `-hidir`. A bug identified by #20569 - - - - - 950f58e7 by Matthew Pickering at 2022-04-01T11:15:36+01:00 docs: Update documentation interaction of search path, -hidir and -c mode. As noted in #20569 the documentation for search path was wrong because it seemed to indicate that `-i` dirs were important when looking for interface files in `-c` mode, but they are not important if `-hidir` is set. Fixes #20569 - - - - - d85c7dcb by sheaf at 2022-04-01T11:17:56+01:00 Keep track of promotion ticks in HsOpTy This patch adds a PromotionFlag field to HsOpTy, which is used in pretty-printing and when determining whether to emit warnings with -fwarn-unticked-promoted-constructors. This allows us to correctly report tick-related warnings for things like: type A = Int : '[] type B = [Int, Bool] Updates haddock submodule Fixes #19984 - - - - - 32070e6c by Jakob Bruenker at 2022-04-01T20:31:08+02:00 Implement \cases (Proposal 302) This commit implements proposal 302: \cases - Multi-way lambda expressions. This adds a new expression heralded by \cases, which works exactly like \case, but can match multiple apats instead of a single pat. Updates submodule haddock to support the ITlcases token. Closes #20768 - - - - - c6f77f39 by sheaf at 2022-04-01T20:33:05+02:00 Add a regression test for #21323 This bug was fixed at some point between GHC 9.0 and GHC 9.2; this patch simply adds a regression test. - - - - - 3596684e by Jakob Bruenker at 2022-04-01T20:33:05+02:00 Fix error when using empty case in arrow notation It was previously not possible to use -XEmptyCase in Arrow notation, since GHC would print "Exception: foldb of empty list". This is now fixed. Closes #21301 - - - - - 9a325b59 by Ben Gamari at 2022-04-01T20:33:05+02:00 users-guide: Fix various markup issues - - - - - aefb1e6d by sheaf at 2022-04-01T20:36:01+02:00 Ensure implicit parameters are lifted `tcExpr` typechecked implicit parameters by introducing a metavariable of kind `TYPE kappa`, without enforcing that `kappa ~ LiftedRep`. This patch instead creates a metavariable of kind `Type`. Fixes #21327 - - - - - ed62dc66 by Ben Gamari at 2022-04-05T11:44:51-04:00 gitlab-ci: Disable cabal-install store caching on Windows For reasons that remain a mystery, cabal-install seems to consistently corrupt its cache on Windows. Disable caching for now. Works around #21347. - - - - - 5ece5c5a by Ryan Scott at 2022-04-06T13:00:51-04:00 Add /linters/*/dist-install/ to .gitignore Fixes #21335. [ci skip] - - - - - 410c76ee by Ben Gamari at 2022-04-06T13:01:28-04:00 Use static archives as an alternative to object merging Unfortunately, `lld`'s COFF backend does not currently support object merging. With ld.bfd having broken support for high image-load base addresses, it's necessary to find an alternative. Here I introduce support in the driver for generating static archives, which we use on Windows instead of object merging. Closes #21068. - - - - - 400666c8 by Ben Gamari at 2022-04-06T13:01:28-04:00 rts/linker: Catch archives masquerading as object files Check the file's header to catch static archive bearing the `.o` extension, as may happen on Windows after the Clang refactoring. See #21068 - - - - - 694d39f0 by Ben Gamari at 2022-04-06T13:01:28-04:00 driver: Make object merging optional On Windows we don't have a linker which supports object joining (i.e. the `-r` flag). Consequently, `-pgmlm` is now a `Maybe`. See #21068. - - - - - 41fcb5cd by Ben Gamari at 2022-04-06T13:01:28-04:00 hadrian: Refactor handling of ar flags Previously the setup was quite fragile as it had to assume which arguments were file arguments and which were flags. - - - - - 3ac80a86 by Ben Gamari at 2022-04-06T13:01:28-04:00 hadrian: Produce ar archives with L modifier on Windows Since object files may in fact be archive files, we must ensure that their contents are merged rather than constructing an archive-of-an-archive. See #21068. - - - - - 295c35c5 by Ben Gamari at 2022-04-06T13:01:28-04:00 Add a Note describing lack of object merging on Windows See #21068. - - - - - d2ae0a3a by Ben Gamari at 2022-04-06T13:01:28-04:00 Build ar archives with -L when "joining" objects Since there may be .o files which are in fact archives. - - - - - babb47d2 by Zubin Duggal at 2022-04-06T13:02:04-04:00 Add warnings for file header pragmas that appear in the body of a module (#20385) Once we are done parsing the header of a module to obtain the options, we look through the rest of the tokens in order to determine if they contain any misplaced file header pragmas that would usually be ignored, potentially resulting in bad error messages. The warnings are reported immediately so that later errors don't shadow over potentially helpful warnings. Metric Increase: T13719 - - - - - 3f31825b by Ben Gamari at 2022-04-06T13:02:40-04:00 rts/AdjustorPool: Generalize to allow arbitrary contexts Unfortunately the i386 adjustor logic needs this. - - - - - 9b645ee1 by Ben Gamari at 2022-04-06T13:02:40-04:00 adjustors/i386: Use AdjustorPool In !7511 (closed) I introduced a new allocator for adjustors, AdjustorPool, which eliminates the address space fragmentation issues which adjustors can introduce. In that work I focused on amd64 since that was the platform where I observed issues. However, in #21132 we noted that the size of adjustors is also a cause of CI fragility on i386. In this MR I port i386 to use AdjustorPool. Sadly the complexity of the i386 adjustor code does cause require a bit of generalization which makes the code a bit more opaque but such is the world. Closes #21132. - - - - - c657a616 by Ben Gamari at 2022-04-06T13:03:16-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. - - - - - 9ce273b9 by Ben Gamari at 2022-04-06T13:03:16-04:00 gitlab-ci: Drop dead HACKAGE_INDEX_STATE variable - - - - - 01845375 by Ben Gamari at 2022-04-06T13:03:16-04:00 gitlab/darwin: Factor out bindists This makes it a bit easier to bump them. - - - - - c41c478e by Ben Gamari at 2022-04-06T13:03:16-04:00 Fix a few new warnings when booting with GHC 9.2.2 -Wuni-incomplete-patterns and apparent improvements in the pattern match checker surfaced these. - - - - - 6563cd24 by Ben Gamari at 2022-04-06T13:03:16-04:00 gitlab-ci: Bump bootstrap compiler to 9.2.2 This is necessary to build recent `text` commits. Bumps Hackage index state for a hashable which builds with GHC 9.2. - - - - - a62e983e by Ben Gamari at 2022-04-06T13:03:16-04:00 Bump text submodule to current `master` Addresses #21295. - - - - - 88d61031 by Vladislav Zavialov at 2022-04-06T13:03:53-04:00 Refactor OutputableBndrFlag instances The matching on GhcPass introduced by 95275a5f25a is not necessary. This patch reverts it to make the code simpler. - - - - - f601f002 by GHC GitLab CI at 2022-04-06T15:18:26-04:00 rts: Eliminate use of nested functions This is a gcc-specific extension. - - - - - d4c5f29c by Ben Gamari at 2022-04-06T15:18:26-04:00 driver: Drop hacks surrounding windres invocation Drop hack for #1828, among others as they appear to be unnecessary when using `llvm-windres`. - - - - - 6be2c5a7 by Ben Gamari at 2022-04-06T15:18:26-04:00 Windows/Clang: Build system adaptation * Bump win32-tarballs to 0.7 * Move Windows toolchain autoconf logic into separate file * Use clang and LLVM utilities as described in #21019 * Disable object merging as lld doesn't support -r * Drop --oformat=pe-bigobj-x86-64 arguments from ld flags as LLD detects that the output is large on its own. * Drop gcc wrapper since Clang finds its root fine on its own. - - - - - c6fb7aff by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Test that we can build bigobj PE objects - - - - - 79851c07 by Ben Gamari at 2022-04-06T15:18:26-04:00 Drop -static-libgcc This flag is not applicable when Clang is used. - - - - - 1f8a8264 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Port T16514 to C Previously this test was C++ which made it a bit of a portability problem. - - - - - d7e650d1 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Mark Windows as a libc++ platform - - - - - d7886c46 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Mark T9405 as fixed on Windows I have not seen it fail since moving to clang. Closes #12714. - - - - - 4c3fbb4e by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Mark FloatFnInverses as fixed The new toolchain has fixed it. Closes #15670. - - - - - 402c36ba by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Rework T13606 to avoid gcc dependence Previously we used libgcc_s's import library in T13606. However, now that we ship with clang we no longer have this library. Instead we now use gdi32. - - - - - 9934ad54 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Clean up tests depending on C++ std lib - - - - - 12fcdef2 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Split T13366 into two tests Split up the C and C++ uses since the latter is significantly more platform-dependent. - - - - - 3c08a198 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Fix mk-big-obj I'm a bit unclear on how this previously worked as it attempted to build an executable without defining `main`. - - - - - 7e97cc23 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Provide module definitions in T10955dyn Otherwise the linker will export all symbols, including those provided by the RTS, from the produced shared object. Consequently, attempting to link against multiple objects simultaneously will cause the linker to complain that RTS symbols are multiply defined. Avoid this by limiting the DLL exports with a module definition file. - - - - - 9a248afa by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Mark test-defaulting-plugin as fragile on Windows Currently llvm-ar does not handle long file paths, resulting in occassional failures of these tests and #21293. - - - - - 39371aa4 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite/driver: Treat framework failures of fragile tests as non-fatal Previously we would report framework failures of tests marked as fragile as failures. Now we rather treat them as fragile test failures, which are not fatal to the testsuite run. Noticed while investigating #21293. - - - - - a1e6661d by Ben Gamari at 2022-04-06T15:18:32-04:00 Bump Cabal submodule - Disable support for library-for-ghci on Windows as described in #21068. - Teach Cabal to use `ar -L` when available - - - - - f7b0f63c by Ben Gamari at 2022-04-06T15:18:37-04:00 Bump process submodule Fixes missing TEST_CC_OPTS in testsuite tests. - - - - - 109cee19 by Ben Gamari at 2022-04-06T15:18:37-04:00 hadrian: Disable ghci libraries when object merging is not available - - - - - c22fba5c by Ben Gamari at 2022-04-06T15:18:37-04:00 Bump bytestring submodule - - - - - 6e2744cc by Ben Gamari at 2022-04-06T15:18:37-04:00 Bump text submodule - - - - - 32333747 by Ben Gamari at 2022-04-06T15:18:37-04:00 hadrian: Build wrappers using ghc rather than cc - - - - - 59787ba5 by Ben Gamari at 2022-04-06T15:18:37-04:00 linker/PEi386: More descriptive error message - - - - - 5e3c3c4f by Ben Gamari at 2022-04-06T15:18:37-04:00 testsuite: Mark TH_spliceE5_prof as unbroken on Windows It was previously failing due to #18721 and now passes with the new toolchain. Closes #18721. - - - - - 9eb0a9d9 by GHC GitLab CI at 2022-04-06T15:23:48-04:00 rts/PEi386: Move some debugging output to -DL - - - - - ce874595 by Ben Gamari at 2022-04-06T15:24:01-04:00 nativeGen/x86: Use %rip-relative addressing On Windows with high-entropy ASLR we must use %rip-relative addressing to avoid overflowing the signed 32-bit immediate size of x86-64. Since %rip-relative addressing comes essentially for free and can make linking significantly easier, we use it on all platforms. - - - - - 52deee64 by Ben Gamari at 2022-04-06T15:24:01-04:00 Generate LEA for label expressions - - - - - 105a0056 by Ben Gamari at 2022-04-06T15:24:01-04:00 Refactor is32BitLit to take Platform rather than Bool - - - - - ec4526b5 by Ben Gamari at 2022-04-06T15:24:01-04:00 Don't assume that labels are 32-bit on Windows - - - - - ffdbe457 by Ben Gamari at 2022-04-06T15:24:01-04:00 nativeGen: Note signed-extended nature of MOV - - - - - bfb79697 by Ben Gamari at 2022-04-06T15:30:56-04:00 rts: Move __USE_MINGW_ANSI_STDIO definition to PosixSource.h It's easier to ensure that this is included first than Rts.h - - - - - 5ad143fd by Ben Gamari at 2022-04-06T15:30:56-04:00 rts: Fix various #include issues This fixes various violations of the newly-added RTS includes linter. - - - - - a59a66a8 by Ben Gamari at 2022-04-06T15:30:56-04:00 testsuite: Lint RTS #includes Verifies two important properties of #includes in the RTS: * That system headers don't appear inside of a `<BeginPrivate.h>` block as this can hide system library symbols, resulting in very hard-to-diagnose linker errors * That no headers precede `Rts.h`, ensuring that __USE_MINGW_ANSI_STDIO is set correctly before system headers are included. - - - - - 42bf7528 by GHC GitLab CI at 2022-04-06T16:25:04-04:00 rts/PEi386: Fix memory leak Previously we would leak the section information of the `.bss` section. - - - - - d286a55c by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker: Preserve information about symbol types As noted in #20978, the linker would previously handle overflowed relocations by creating a jump island. While this is fine in the case of code symbols, it's very much not okay in the case of data symbols. To fix this we must keep track of whether each symbol is code or data and relocate them appropriately. This patch takes the first step in this direction, adding a symbol type field to the linker's symbol table. It doesn't yet change relocation behavior to take advantage of this knowledge. Fixes #20978. - - - - - e689e9d5 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PEi386: Fix relocation overflow behavior This fixes handling of overflowed relocations on PEi386 targets: * Refuse to create jump islands for relocations of data symbols * Correctly handle the `__imp___acrt_iob_func` symbol, which is an new type of symbol: `SYM_TYPE_INDIRECT_DATA` - - - - - 655e7d8f by GHC GitLab CI at 2022-04-06T16:25:25-04:00 rts: Mark anything that might have an info table as data Tables-next-to-code mandates that we treat symbols with info tables like data since we cannot relocate them using a jump island. See #20983. - - - - - 7e8cc293 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PEi386: Rework linker This is a significant rework of the PEi386 linker, making the linker compatible with high image base addresses. Specifically, we now use the m32 allocator instead of `HeapAllocate`. In addition I found a number of latent bugs in our handling of import libraries and relocations. I've added quite a few comments describing what I've learned about Windows import libraries while fixing these. Thanks to Tamar Christina (@Phyx) for providing the address space search logic, countless hours of help while debugging, and his boundless Windows knowledge. Co-Authored-By: Tamar Christina <tamar at zhox.com> - - - - - ff625218 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PEi386: Move allocateBytes to MMap.c - - - - - f562b5ca by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PEi386: Avoid accidentally-quadratic allocation cost We now preserve the address that we last mapped, allowing us to resume our search and avoiding quadratic allocation costs. This fixes the runtime of T10296a, which allocates many adjustors. - - - - - 3247b7db by Ben Gamari at 2022-04-06T16:25:25-04:00 Move msvcrt dep out of base - - - - - fa404335 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker: More descriptive debug output - - - - - 140f338f by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PathUtils: Define pathprintf in terms of snwprintf on Windows swprintf deviates from usual `snprintf` semantics in that it does not guarantee reasonable behavior when the buffer is NULL (that is, returning the number of bytes that would have been emitted). - - - - - eb60565b by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker: Report archive member index - - - - - 209fd61b by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker: Split up object resolution and initialization Previously the RTS linker would call initializers during the "resolve" phase of linking. However, this is problematic in the case of cyclic dependencies between objects. In particular, consider the case where we have a situation where a static library contains a set of recursive objects: * object A has depends upon symbols in object B * object B has an initializer that depends upon object A * we try to load object A The linker would previously: 1. start resolving object A 2. encounter the reference to object B, loading it resolve object B 3. run object B's initializer 4. the initializer will attempt to call into object A, which hasn't been fully resolved (and therefore protected) Fix this by moving constructor execution to a new linking phase, which follows resolution. Fix #21253. - - - - - 8e8a1021 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker/LoadArchive: Fix leaking file handle Previously `isArchive` could leak a `FILE` handle if the `fread` returned a short read. - - - - - 429ea5d9 by sheaf at 2022-04-07T07:55:52-04:00 Remove Fun pattern from Typeable COMPLETE set GHC merge request !963 improved warnings in the presence of COMPLETE annotations. This allows the removal of the Fun pattern from the complete set. Doing so expectedly causes some redundant pattern match warnings, in particular in GHC.Utils.Binary.Typeable and Data.Binary.Class from the binary library; this commit addresses that. Updates binary submodule Fixes #20230 - - - - - 54b18824 by Alan Zimmerman at 2022-04-07T07:56:28-04:00 EPA: handling of con_bndrs in mkGadtDecl Get rid of unnnecessary case clause that always matched. Closes #20558 - - - - - 9c838429 by Ben Gamari at 2022-04-07T09:38:53-04:00 testsuite: Mark T10420 as broken on Windows Due to #21322. - - - - - 50739d2b by Ben Gamari at 2022-04-07T09:42:42-04:00 rts: Refactor and fix printf attributes on clang Clang on Windows does not understand the `gnu_printf` attribute; use `printf` instead. - - - - - 9eeaeca4 by Ben Gamari at 2022-04-07T09:42:42-04:00 rts: Add missing newline in error message - - - - - fcef9a17 by Ben Gamari at 2022-04-07T09:42:42-04:00 configure: Make environ decl check more robust Some platforms (e.g. Windows/clang64) declare `environ` in `<stdlib.h>`, not `<unistd.h>` - - - - - 8162b4f3 by Ben Gamari at 2022-04-07T09:42:42-04:00 rts: Adjust RTS symbol table on Windows for ucrt - - - - - 633280d7 by Ben Gamari at 2022-04-07T09:43:21-04:00 testsuite: Fix exit code of bounds checking tests on Windows `abort` exits with 255, not 134, on Windows. - - - - - cab4dc01 by Ben Gamari at 2022-04-07T09:43:31-04:00 testsuite: Update expected output from T5435 tests on Windows I'll admit, I don't currently see *why* this output is reordered but it is a fairly benign difference and I'm out of time to investigate. - - - - - edf5134e by Ben Gamari at 2022-04-07T09:43:35-04:00 testsuite: Mark T20918 as broken on Windows Our toolchain on Windows doesn't currently have Windows support. - - - - - d0ddeff3 by Ben Gamari at 2022-04-07T09:43:39-04:00 testsuite: Mark linker unloading tests as broken on Windows Due to #20354. We will need to investigate this prior the release. - - - - - 5a86da2b by Ben Gamari at 2022-04-07T09:43:43-04:00 testsuite: Mark T9405 as broken on Windows Due to #21361. - - - - - 4aa86dcf by Ben Gamari at 2022-04-07T09:44:18-04:00 Merge branches 'wip/windows-high-codegen', 'wip/windows-high-linker', 'wip/windows-clang-2' and 'wip/lint-rts-includes' into wip/windows-clang-join - - - - - 7206f055 by Ben Gamari at 2022-04-07T09:45:07-04:00 rts/CloneStack: Ensure that Rts.h is #included first As is necessary on Windows. - - - - - 9cfcb27b by Ben Gamari at 2022-04-07T09:45:07-04:00 rts: Fallback to ucrtbase not msvcrt Since we have switched to Clang the toolchain now links against ucrt rather than msvcrt. - - - - - d6665d85 by Ben Gamari at 2022-04-07T09:46:25-04:00 Accept spurious perf test shifts on Windows Metric Decrease: T16875 Metric Increase: T12707 T13379 T3294 T4801 T5321FD T5321Fun T783 - - - - - 83363c8b by Simon Peyton Jones at 2022-04-07T12:57:21-04:00 Use prepareBinding in tryCastWorkerWrapper As #21144 showed, tryCastWorkerWrapper was calling prepareRhs, and then unconditionally floating the bindings, without the checks of doFloatFromRhs. That led to floating an unlifted binding into a Rec group. This patch refactors prepareBinding to make these checks, and do them uniformly across all calls. A nice improvement. Other changes * Instead of passing around a RecFlag and a TopLevelFlag; and sometimes a (Maybe SimplCont) for join points, define a new Simplifier-specific data type BindContext: data BindContext = BC_Let TopLevelFlag RecFlag | BC_Join SimplCont and use it consistently. * Kill off completeNonRecX by inlining it. It was only called in one place. * Add a wrapper simplImpRules for simplRules. Compile time on T9630 drops by 4.7%; little else changes. Metric Decrease: T9630 - - - - - 02279a9c by Vladislav Zavialov at 2022-04-07T12:57:59-04:00 Rename [] to List (#21294) This patch implements a small part of GHC Proposal #475. The key change is in GHC.Types: - data [] a = [] | a : [a] + data List a = [] | a : List a And the rest of the patch makes sure that List is pretty-printed as [] in various contexts. Updates the haddock submodule. - - - - - 08480d2a by Simon Peyton Jones at 2022-04-07T12:58:36-04:00 Fix the free-var test in validDerivPred The free-var test (now documented as (VD3)) was too narrow, affecting only class predicates. #21302 demonstrated that this wasn't enough! Fixes #21302. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - b3d6d23d by Andreas Klebinger at 2022-04-07T12:59:12-04:00 Properly explain where INLINE pragmas can appear. Fixes #20676 - - - - - 23ef62b3 by Ben Gamari at 2022-04-07T14:28:28-04:00 rts: Fix off-by-one in snwprintf usage - - - - - b2dbcc7d by Simon Jakobi at 2022-04-08T03:00:38-04:00 Improve seq[D]VarSet Previously, the use of size[D]VarSet would involve a traversal of the entire underlying IntMap. Since IntMaps are already spine-strict, this is unnecessary. - - - - - 64ac20a7 by sheaf at 2022-04-08T03:01:16-04:00 Add test for #21338 This no-skolem-info bug was fixed by the no-skolem-info patch that will be part of GHC 9.4. This patch adds a regression test for the issue reported in issue #21338. Fixes #21338. - - - - - c32c4db6 by Ben Gamari at 2022-04-08T03:01:53-04:00 rts: Move __USE_MINGW_ANSI_STDIO definition to PosixSource.h It's easier to ensure that this is included first than Rts.h - - - - - 56f85d62 by Ben Gamari at 2022-04-08T03:01:53-04:00 rts: Fix various #include issues This fixes various violations of the newly-added RTS includes linter. - - - - - cb1f31f5 by Ben Gamari at 2022-04-08T03:01:53-04:00 testsuite: Lint RTS #includes Verifies two important properties of #includes in the RTS: * That system headers don't appear inside of a `<BeginPrivate.h>` block as this can hide system library symbols, resulting in very hard-to-diagnose linker errors * That no headers precede `Rts.h`, ensuring that __USE_MINGW_ANSI_STDIO is set correctly before system headers are included. - - - - - c44432db by Krzysztof Gogolewski at 2022-04-08T03:02:29-04:00 Fixes to 9.4 release notes - Mention -Wforall-identifier - Improve description of withDict - Fix formatting - - - - - 777365f1 by sheaf at 2022-04-08T09:43:35-04:00 Correctly report SrcLoc of redundant constraints We were accidentally dropping the source location information in certain circumstances when reporting redundant constraints. This patch makes sure that we set the TcLclEnv correctly before reporting the warning. Fixes #21315 - - - - - af300a43 by Vladislav Zavialov at 2022-04-08T09:44:11-04:00 Reject illegal quote mark in data con declarations (#17865) * Non-fatal (i.e. recoverable) parse error * Checking infix constructors * Extended the regression test - - - - - 56254e6b by Ben Gamari at 2022-04-08T09:59:46-04:00 Merge remote-tracking branch 'origin/master' - - - - - 6e2c3b7c by Matthew Pickering at 2022-04-08T13:55:15-04:00 driver: Introduce HomeModInfoCache abstraction The HomeModInfoCache is a mutable cache which is updated incrementally as the driver completes, this makes it robust to exceptions including (SIGINT) The interface for the cache is described by the `HomeMOdInfoCache` data type: ``` data HomeModInfoCache = HomeModInfoCache { hmi_clearCache :: IO [HomeModInfo] , hmi_addToCache :: HomeModInfo -> IO () } ``` The first operation clears the cache and returns its contents. This is designed so it's harder to end up in situations where the cache is retained throughout the execution of upsweep. The second operation allows a module to be added to the cache. The one slightly nasty part is in `interpretBuildPlan` where we have to be careful to ensure that the cache writes happen: 1. In parralel 2. Before the executation continues after upsweep. This requires some simple, localised MVar wrangling. Fixes #20780 - - - - - 85f4a3c9 by Andreas Klebinger at 2022-04-08T13:55:50-04:00 Add flag -fprof-manual which controls if GHC should honour manual cost centres. This allows disabling of manual control centres in code a user doesn't control like libraries. Fixes #18867 - - - - - 3415981c by Vladislav Zavialov at 2022-04-08T13:56:27-04:00 HsUniToken for :: in GADT constructors (#19623) One more step towards the new design of EPA. Updates the haddock submodule. - - - - - 23f95735 by sheaf at 2022-04-08T13:57:07-04:00 Docs: datacon eta-expansion, rep-poly checks The existing notes weren't very clear on how the eta-expansion of data constructors that occurs in tcInferDataCon/dsConLike interacts with the representation polymorphism invariants. So we explain with a few more details how we ensure that the representation-polymorphic lambdas introduced by tcInferDataCon/dsConLike don't end up causing problems, by checking they are properly instantiated and then relying on the simple optimiser to perform beta reduction. A few additional changes: - ConLikeTc just take type variables instead of binders, as we never actually used the binders. - Removed the FRRApp constructor of FRROrigin; it was no longer used now that we use ExpectedFunTyOrigin. - Adds a bit of documentation to the constructors of ExpectedFunTyOrigin. - - - - - d4480490 by Matthew Pickering at 2022-04-08T13:57:43-04:00 ci: Replace "always" with "on_success" to stop build jobs running before hadrian-ghci has finished See https://docs.gitlab.com/ee/ci/yaml/#when * always means, always run not matter what * on_success means, run if the dependencies have built successfully - - - - - 0736e949 by Vladislav Zavialov at 2022-04-08T13:58:19-04:00 Disallow (->) as a data constructor name (#16999) The code was misusing isLexCon, which was never meant for validation. In fact, its documentation states the following: Use these functions to figure what kind of name a 'FastString' represents; these functions do /not/ check that the identifier is valid. Ha! This sign can't stop me because I can't read. The fix is to use okConOcc instead. The other checks (isTcOcc or isDataOcc) seem superfluous, so I also removed those. - - - - - e58d5eeb by Simon Peyton Jones at 2022-04-08T13:58:55-04:00 Tiny documentation wibble This commit commit 83363c8b04837ee871a304cf85207cf79b299fb0 Author: Simon Peyton Jones <simon.peytonjones at gmail.com> Date: Fri Mar 11 16:55:38 2022 +0000 Use prepareBinding in tryCastWorkerWrapper refactored completeNonRecX away, but left a Note referring to it. This MR fixes that Note. - - - - - 4bb00839 by Matthew Pickering at 2022-04-09T07:40:28-04:00 ci: Fix nightly head.hackage pipelines This also needs a corresponding commit to head.hackage, I also made the job explicitly depend on the fedora33 job so that it isn't blocked by a failing windows job, which causes docs-tarball to fail. - - - - - 3c48e12a by Matthew Pickering at 2022-04-09T07:40:28-04:00 ci: Remove doc-tarball dependency from perf and perf-nofib jobs These don't depend on the contents of the tarball so we can run them straight after the fedora33 job finishes. - - - - - 27362265 by Matthew Pickering at 2022-04-09T07:41:04-04:00 Bump deepseq to 1.4.7.0 Updates deepseq submodule Fixes #20653 - - - - - 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 - - - - - 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]. - - - - - 2eb0fb87 by Matthew Pickering at 2022-12-15T03:54:39-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 - - - - - 552b7908 by Ben Gamari at 2022-12-15T03:55:15-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. - - - - - 933d61a4 by Simon Peyton Jones at 2022-12-15T03:55:51-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. - - - - - 03ed0b95 by Ryan Scott at 2022-12-15T03:56:26-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. - - - - - ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/ThreadPaused: Ordering fixes - - - - - 914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00 eventlog: Silence spurious data race - - - - - fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts: Use fences instead of explicit barriers - - - - - 2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - 70999283 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 98689f77 by Ben Gamari at 2022-12-16T16:12:44-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. - - - - - 605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - 86f20258 by Ben Gamari at 2022-12-16T16:12:45-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. - - - - - f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate access to capabilities array - - - - - 7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate sched_state - - - - - 1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Style fix - - - - - 82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00 compiler: Use release store in eager blackholing - - - - - eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Fix ordering of makeStableName - - - - - ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Note race with wakeBlockingQueue - - - - - 5acf33dd by Bodigrim at 2022-12-16T16:13:22-05:00 Bump submodule directory to 1.3.8.0 and hpc to HEAD - - - - - 0dd95421 by Bodigrim at 2022-12-16T16:13:22-05:00 Accept allocations increase on Windows This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips between lists and ByteArray. See #22625 for discussion. Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T10547 T12150 T12227 T12234 T12425 T13035 T13253 T13253-spj T13701 T13719 T15703 T16875 T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T21839r T5837 T6048 T9198 T9961 TcPlugin_RewritePerf hard_hole_fits - - - - - ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00 testsuite: Mark T9405 as fragile instead of broken on Windows It's starting to pass again, and the unexpected pass blocks CI. - - - - - 1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: remove obsolete commented code in wasm NCG It was just a temporary hack to workaround a bug in the relooper, that bug has been fixed long before the wasm backend is merged. - - - - - e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm Also removes some unreachable code here. - - - - - 1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: change fallback function signature to Cmm function signature in wasm NCG In the wasm NCG, when handling a `CLabel` of undefined function without knowing its function signature, we used to fallback to `() -> ()` which is accepted by `wasm-ld`. This patch changes it to the signature of Cmm functions, which equally works, but would be required when we emit tail call instructions. - - - - - 8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add optional tail-call support in wasm NCG When the `-mtail-call` clang flag is passed at configure time, wasm tail-call extension is enabled, and the wasm NCG will emit `return_call`/`return_call_indirect` instructions to take advantage of it and avoid the `StgRun` trampoline overhead. Closes #22461. - - - - - d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00 base: add missing autoconf checks for waitpid/umask These are not present in wasi-libc. Required for fixing #22589 - - - - - da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00 compiler: make .wasm the default executable extension on wasm32 Following convention as in other wasm toolchains. Fixes #22594. - - - - - ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00 ci: support hello.wasm in ci.sh cross testing logic - - - - - 6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00 Correct `exitWith` Haddocks The `IOError`-specific `catch` in the Prelude is long gone. - - - - - b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-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. - - - - - 761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00 rts/libdw: Silence uninitialized usage warnings As noted in #22538, previously some GCC versions warned that various locals in Libdw.c may be used uninitialized. Although this wasn't strictly true (since they were initialized in an inline assembler block) we fix this by providing explicit empty initializers. Fixes #22538 - - - - - 5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00 testsuite: Mark T16392 as fragile on windows See #22649 - - - - - 703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00 Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`. - - - - - 9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05: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 - - - - - 7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Drop uses of AC_PROG_CC_C99 As noted in #22566, this macro is deprecated as of autoconf-2.70 `AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself. Closes #22566. - - - - - 36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Use AS_HELP_STRING instead of AC_HELP_STRING The latter has been deprecated. See #22566. - - - - - befe6ff8 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: fix various usages of head and tail - - - - - 666d0ba7 by Bodigrim at 2022-12-20T21:16:37-05:00 GHCi.UI: avoid head and tail in parseCallEscape and around - - - - - 5d96fd50 by Bodigrim at 2022-12-20T21:16:37-05:00 Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty - - - - - 3ce2ab94 by Bodigrim at 2022-12-21T06:17:56-05:00 Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian - - - - - 954de93a by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule haskeline to HEAD (to allow transformers-0.6) - - - - - cefbeec3 by Bodigrim at 2022-12-21T06:17:56-05:00 Update submodule transformers to 0.6.0.4 - - - - - b4730b62 by Bodigrim at 2022-12-21T06:17:56-05:00 Fix tests T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations Metric Increase: T13253 - - - - - 0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05: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. - - - - - df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00 rts: explicitly store return value of ccall checkClosure to prevent type error (#22617) - - - - - e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix shadowing lacuna in OccurAnal Issue #22623 demonstrated another lacuna in the implementation of wrinkle (BS3) in Note [The binder-swap substitution] in the occurrence analyser. I was failing to add TyVar lambda binders using addInScope/addOneInScope and that led to a totally bogus binder-swap transformation. Very easy to fix. - - - - - 3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix an assertion check in addToEqualCtList The old assertion saw that a constraint ct could rewrite itself (of course it can) and complained (stupid). Fixes #22645 - - - - - ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00 configure: Bump version to 9.6 - - - - - fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00 base: Bump version to 4.18 Requires various submodule bumps. - - - - - 93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00 ghc-boot: Fix bootstrapping - - - - - fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00 Bump GHC version to 9.7 - - - - - 914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05: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. - - - - - 32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00 hadrian bindist: Install manpages to share/man/man1/ghc.1 When the installation makefile was copied over the manpages were no longer installed in the correct place. Now we install it into share/man/man1/ghc.1 as the make build system did. Fixes #22371 - - - - - b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00 rts: Drop paths from configure from cabal file A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them. - - - - - b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00 Bump libffi-tarballs submodule We will now use libffi-3.4.4. - - - - - 3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00 EPA: Make EOF position part of AnnsModule Closes #20951 Closes #19697 - - - - - 99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00 JS: fix support for -outputdir (#22641) The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug. - - - - - 02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00 Refactor mkRuntimeError This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions. - - - - - 35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00 base: Fix event manager shutdown race on non-Linux platforms During shutdown it's possible that we will attempt to use a closed fd to wakeup another capability's event manager. On the Linux eventfd path we were careful to handle this. However on the non-Linux path we failed to do so. Fix this. - - - - - 317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00 Fix unifier bug: failing to decompose over-saturated type family This simple patch fixes #22647 - - - - - 14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00 rts/m32: Fix sanity checking Previously we would attempt to clear pages which were marked as read-only. Fix this. - - - - - 16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00 ci: Move wasm pipelines into nightly rather than master See #22664 for the changes which need to be made to bring one of these back to the validate pipeline. - - - - - 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-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. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-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). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Bodigrim at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00: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. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - 541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - 28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00 Add support for sized literals in the bytecode interpreter. The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945 - - - - - ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00 rts: MUT_VAR is not a StgMutArrPtrs There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs. - - - - - 6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s - - - - - 73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. - - - - - 8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 3bbfadf4 by Ben Gamari at 2023-01-10T18:54:37-05:00 gitlab-ci: Bump Darwin bootstrap toolchain This updates the bootstrap compiler on Darwin from 8.10.7 to 9.2.5, ensuring that we have the fix for #21964. - - - - - 11 changed files: - − .appveyor.sh - .editorconfig - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/darwin/nix/sources.json - + .gitlab/darwin/nix/sources.nix - + .gitlab/darwin/toolchain.nix - + .gitlab/gen_ci.hs - + .gitlab/generate_jobs - + .gitlab/hello.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0643eb2309fe1ae25b6a7af7a6a3341e036662da...3bbfadf4c76b99eff0f4d60bc992cafdebc0991e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0643eb2309fe1ae25b6a7af7a6a3341e036662da...3bbfadf4c76b99eff0f4d60bc992cafdebc0991e You're receiving 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 Jan 11 00:33:34 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 10 Jan 2023 19:33:34 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/rocky-ci Message-ID: <63be03dea113e_3b1bf91d2c59a8714469@gitlab.mail> Ben Gamari pushed new branch wip/rocky-ci at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/rocky-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 Wed Jan 11 01:35:26 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 10 Jan 2023 20:35:26 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Fix tcPluginRewrite example Message-ID: <63be125e254df_3b1bf91fb12f147231a7@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 57fa420c by Jade Lovelace at 2023-01-10T20:35:08-05:00 Fix tcPluginRewrite example - - - - - be541bdc by Jade Lovelace at 2023-01-10T20:35:08-05:00 fix missing haddock pipe - - - - - f59a9150 by Florian Weimer at 2023-01-10T20:35:11-05:00 m4/fp_leading_underscore.m4: Avoid implicit exit function declaration And switch to a new-style function definition. Fixes build issues with compilers that do not accept implicit function declarations. - - - - - 6317e641 by HaskellMouse at 2023-01-10T20:35:15-05:00 Added a new warning about compatibility with RequiredTypeArguments This commit introduces a new warning that indicates code incompatible with future extension: RequiredTypeArguments. Enabling this extension may break some code and the warning will help to make it compatible in advance. - - - - - c144795a by Ben Gamari at 2023-01-10T20:35:17-05:00 testsuite: Drop testheapalloced.c As noted in #22414, this file (which appears to be a benchmark for characterising the one-step allocator's MBlock cache) is currently unreferenced. Remove it. Closes #22414. - - - - - b9e7e8c3 by Vladislav Zavialov at 2023-01-10T20:35:18-05:00 Introduce the TypeAbstractions language flag GHC Proposals #448 "Modern scoped type variables" and #425 "Invisible binders in type declarations" introduce a new language extension flag: TypeAbstractions. Part of the functionality guarded by this flag has already been implemented, namely type abstractions in constructor patterns, but it was guarded by a combination of TypeApplications and ScopedTypeVariables instead of a dedicated language extension flag. This patch does the following: * introduces a new language extension flag TypeAbstractions * requires TypeAbstractions for @a-syntax in constructor patterns instead of TypeApplications and ScopedTypeVariables * creates a User's Guide page for TypeAbstractions and moves the "Type Applications in Patterns" section there To avoid a breaking change, the new flag is implied by ScopedTypeVariables and is retroactively added to GHC2021. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 6f5ca4da by Krzysztof Gogolewski at 2023-01-10T20:35:18-05:00 Misc cleanup - Remove unused mkWildEvBinder - Use typeTypeOrConstraint - more symmetric and asserts that that the type is Type or Constraint - Fix escape sequences in Python; they raise a deprecation warning with -Wdefault - - - - - 30 changed files: - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Hint.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Types/Name/Reader.hs - docs/users_guide/9.6.1-notes.rst - docs/users_guide/exts/gadt.rst - + docs/users_guide/exts/type_abstractions.rst - docs/users_guide/exts/type_applications.rst - docs/users_guide/exts/types.rst - docs/users_guide/using-warnings.rst - libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs - m4/fp_leading_underscore.m4 - testsuite/driver/runtests.py - testsuite/tests/cabal/all.T - testsuite/tests/cmm/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/2cfbc97a95949c7f3e4a5097f5e38bf02def6ef5...6f5ca4da90b016555d4650bd33c2635ce284cfac -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2cfbc97a95949c7f3e4a5097f5e38bf02def6ef5...6f5ca4da90b016555d4650bd33c2635ce284cfac You're receiving 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 Jan 11 02:06:36 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 10 Jan 2023 21:06:36 -0500 Subject: [Git][ghc/ghc][ghc-9.6] configure: Use three-component version number Message-ID: <63be19acdba3e_3b1bf95632473688c@gitlab.mail> Ben Gamari pushed to branch ghc-9.6 at Glasgow Haskell Compiler / GHC Commits: ed5aaafd by Ben Gamari at 2023-01-10T21:06:13-05:00 configure: Use three-component version number - - - - - 1 changed file: - configure.ac Changes: ===================================== 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.6], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.6.0], [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 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ed5aaafdbc649df6bce18c51827a2576d7948f35 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ed5aaafdbc649df6bce18c51827a2576d7948f35 You're receiving 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 Jan 11 02:49:17 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 10 Jan 2023 21:49:17 -0500 Subject: [Git][ghc/ghc][wip/rocky-ci] gitlab-ci: Add Rocky8 jobs Message-ID: <63be23adeb862_3b1bf93c57d8c7386e4@gitlab.mail> Ben Gamari pushed to branch wip/rocky-ci at Glasgow Haskell Compiler / GHC Commits: 1c08703e by Ben Gamari at 2023-01-10T21:49:11-05:00 gitlab-ci: Add Rocky8 jobs Addresses #22268. - - - - - 2 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -99,7 +99,13 @@ data Opsys | Windows deriving (Eq) data LinuxDistro - = Debian11 | Debian10 | Debian9 | Fedora33 | Ubuntu2004 | Centos7 | Alpine deriving (Eq) + = Debian11 | Debian10 | Debian9 + | Fedora33 + | Ubuntu2004 + | Centos7 + | Alpine + | Rocky8 + deriving (Eq) data Arch = Amd64 | AArch64 | I386 @@ -255,6 +261,7 @@ distroName Fedora33 = "fedora33" distroName Ubuntu2004 = "ubuntu20_04" distroName Centos7 = "centos7" distroName Alpine = "alpine3_12" +distroName Rocky8 = "rocky8" opsysName :: Opsys -> String opsysName (Linux distro) = "linux-" ++ distroName distro @@ -823,6 +830,7 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ ) { bignumBackend = Native } + , standardBuilds Amd64 (Linux Rocky8) ] where ===================================== .gitlab/jobs.yaml ===================================== @@ -1685,6 +1685,65 @@ "XZ_OPT": "-9" } }, + "nightly-x86_64-linux-rocky8-validate": { + "after_script": [ + ".gitlab/ci.sh save_cache", + ".gitlab/ci.sh clean", + "cat ci_timings" + ], + "allow_failure": false, + "artifacts": { + "expire_in": "8 weeks", + "paths": [ + "ghc-x86_64-linux-rocky8-validate.tar.xz", + "junit.xml" + ], + "reports": { + "junit": "junit.xml" + }, + "when": "always" + }, + "cache": { + "key": "x86_64-linux-rocky8-$CACHE_REV", + "paths": [ + "cabal-cache", + "toolchain" + ] + }, + "dependencies": [], + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-rocky8:$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\")", + "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": [ + "x86_64-linux" + ], + "variables": { + "BIGNUM_BACKEND": "gmp", + "BIN_DIST_NAME": "ghc-x86_64-linux-rocky8-validate", + "BUILD_FLAVOUR": "validate", + "CONFIGURE_ARGS": "", + "TEST_ENV": "x86_64-linux-rocky8-validate", + "XZ_OPT": "-9" + } + }, "nightly-x86_64-linux-ubuntu20_04-validate": { "after_script": [ ".gitlab/ci.sh save_cache", @@ -2848,6 +2907,66 @@ "XZ_OPT": "-9" } }, + "release-x86_64-linux-rocky8-release": { + "after_script": [ + ".gitlab/ci.sh save_cache", + ".gitlab/ci.sh clean", + "cat ci_timings" + ], + "allow_failure": false, + "artifacts": { + "expire_in": "1 year", + "paths": [ + "ghc-x86_64-linux-rocky8-release.tar.xz", + "junit.xml" + ], + "reports": { + "junit": "junit.xml" + }, + "when": "always" + }, + "cache": { + "key": "x86_64-linux-rocky8-$CACHE_REV", + "paths": [ + "cabal-cache", + "toolchain" + ] + }, + "dependencies": [], + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-rocky8:$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\")", + "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": [ + "x86_64-linux" + ], + "variables": { + "BIGNUM_BACKEND": "gmp", + "BIN_DIST_NAME": "ghc-x86_64-linux-rocky8-release", + "BUILD_FLAVOUR": "release", + "CONFIGURE_ARGS": "", + "IGNORE_PERF_FAILURES": "all", + "TEST_ENV": "x86_64-linux-rocky8-release", + "XZ_OPT": "-9" + } + }, "release-x86_64-linux-ubuntu20_04-release": { "after_script": [ ".gitlab/ci.sh save_cache", @@ -4219,6 +4338,64 @@ "TEST_ENV": "x86_64-linux-fedora33-validate+debug_info" } }, + "x86_64-linux-rocky8-validate": { + "after_script": [ + ".gitlab/ci.sh save_cache", + ".gitlab/ci.sh clean", + "cat ci_timings" + ], + "allow_failure": false, + "artifacts": { + "expire_in": "2 weeks", + "paths": [ + "ghc-x86_64-linux-rocky8-validate.tar.xz", + "junit.xml" + ], + "reports": { + "junit": "junit.xml" + }, + "when": "always" + }, + "cache": { + "key": "x86_64-linux-rocky8-$CACHE_REV", + "paths": [ + "cabal-cache", + "toolchain" + ] + }, + "dependencies": [], + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-rocky8:$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\")", + "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": [ + "x86_64-linux" + ], + "variables": { + "BIGNUM_BACKEND": "gmp", + "BIN_DIST_NAME": "ghc-x86_64-linux-rocky8-validate", + "BUILD_FLAVOUR": "validate", + "CONFIGURE_ARGS": "", + "TEST_ENV": "x86_64-linux-rocky8-validate" + } + }, "x86_64-linux-ubuntu20_04-validate": { "after_script": [ ".gitlab/ci.sh save_cache", View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1c08703e6e13ce88c5ff304ea0a70c1998940ffc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1c08703e6e13ce88c5ff304ea0a70c1998940ffc You're receiving 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 Jan 11 02:51:19 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 10 Jan 2023 21:51:19 -0500 Subject: [Git][ghc/ghc][wip/bump-win32-tarballs] 1812 commits: rts: Consolidate RtsSymbols from libc Message-ID: <63be242713f50_3b1bf91d2c59a8739251@gitlab.mail> Ben Gamari pushed to branch wip/bump-win32-tarballs at Glasgow Haskell Compiler / GHC Commits: e2b60be8 by Ben Gamari at 2022-01-15T03:41:16-05:00 rts: Consolidate RtsSymbols from libc Previously (9ebda74ec5331911881d734b21fbb31c00a0a22f) `environ` was added to `RtsSymbols` to ensure that environment was correctly propagated when statically linking. However, this introduced #20577 since platforms are inconsistent in whether they provide a prototype for `environ`. I fixed this by providing a prototype but while doing so dropped symbol-table entry, presumably thinking that it was redundant due to the entry in the mingw-specific table. Here I reintroduce the symbol table entry for `environ` and move libc symbols shared by Windows and Linux into a new macro, `RTS_LIBC_SYMBOLS`, avoiding this potential confusion. - - - - - 0dc72395 by Tamar Christina at 2022-01-15T03:41:55-05:00 winio: fix heap corruption and various leaks. - - - - - 4031ef62 by Eric Lindblad at 2022-01-15T20:11:55+00:00 wikipedia link - - - - - a13aff98 by Eric Lindblad at 2022-01-17T08:25:51-05:00 ms link - - - - - f161e890 by sheaf at 2022-01-17T14:52:50+00:00 Use diagnostic infrastructure in GHC.Tc.Errors - - - - - 18c797b8 by Jens Petersen at 2022-01-18T16:12:14-05:00 hadrian BinaryDist: version ghc in ghciScriptWrapper like we do for the non-Hadrian wrapper script. Otherwise if $bindir/ghc is a different ghc version then versioned ghci will incorrectly run the other ghc version instead. (Normally this would only happen if there are parallel ghc versions installed in bindir.) All the other wrapper scripts already have versioned executablename - - - - - 310424d0 by Matthew Pickering at 2022-01-18T16:12:50-05:00 Correct type of static forms in hsExprType The simplest way to do this seemed to be to persist the whole type in the extension field from the typechecker so that the few relevant places * Desugaring can work out the return type by splitting this type rather than calling `dsExpr` (slightly more efficient). * hsExprType can just return the correct type. * Zonking has to now zonk the type as well The other option we considered was wiring in StaticPtr but that is actually quite tricky because StaticPtr refers to StaticPtrInfo which has field selectors (which we can't easily wire in). Fixes #20150 - - - - - 7ec783de by Matthew Pickering at 2022-01-18T16:12:50-05:00 Add test for using type families with static pointers Issue was reported on #13306 - - - - - 2d205154 by Sebastian Graf at 2022-01-18T16:13:25-05:00 Stricten the Strict State monad I found it weird that most of the combinators weren't actually strict. Making `pure` strict in the state should hopefully give Nested CPR an easier time to unbox the nested state. - - - - - 5a6efd21 by Ben Gamari at 2022-01-18T16:14:01-05:00 rts/winio: Fix #18382 Here we refactor WinIO's IO completion scheme, squashing a memory leak and fixing #18382. To fix #18382 we drop the special thread status introduced for IoPort blocking, BlockedOnIoCompletion, as well as drop the non-threaded RTS's special dead-lock detection logic (which is redundant to the GC's deadlock detection logic), as proposed in #20947. Previously WinIO relied on foreign import ccall "wrapper" to create an adjustor thunk which can be attached to the OVERLAPPED structure passed to the operating system. It would then use foreign import ccall "dynamic" to back out the original continuation from the adjustor. This roundtrip is significantly more expensive than the alternative, using a StablePtr. Furthermore, the implementation let the adjustor leak, meaning that every IO request would leak a page of memory. Fixes T18382. - - - - - 01254ceb by Matthew Pickering at 2022-01-18T16:14:37-05:00 Add note about heap invariant Closed #20904 - - - - - 21510698 by Sergey Vinokurov at 2022-01-18T16:15:12-05:00 Improve detection of lld linker Newer lld versions may include vendor info in --version output and thus the version string may not start with ‘LLD’. Fixes #20907 - - - - - 95e7964b by Peter Trommler at 2022-01-18T20:46:08-05:00 Fix T20638 on big-endian architectures The test reads a 16 bit value from an array of 8 bit values. Naturally, that leads to different values read on big-endian architectures than on little-endian. In this case the value read is 0x8081 on big-endian and 0x8180 on little endian. This patch changes the argument of the `and` machop to mask bit 7 which is the only bit different. The test still checks that bit 15 is zero, which was the original issue in #20638. Fixes #20906. - - - - - fd0019a0 by Eric Lindblad at 2022-01-18T20:46:48-05:00 ms and gh links - - - - - 85dc61ee by Zubin Duggal at 2022-01-18T20:47:23-05:00 ci: Fix subtlety with not taking effect because of time_it (#20898) - - - - - 592e4113 by Anselm Schüler at 2022-01-19T13:31:49-05:00 Note that ImpredicativeTypes doesn’t allow polymorphic instances See #20939 - - - - - 3b009e1a by Ben Gamari at 2022-01-19T13:32:25-05:00 base: Add CTYPE pragmas to all foreign types Fixes #15531 by ensuring that we know the corresponding C type for all marshalling wrappers. Closes #15531. - - - - - 516eeb9e by Robert Hensing at 2022-01-24T21:28:24-05:00 Add -fcompact-unwind This gives users the choice to enable __compact_unwind sections when linking. These were previously hardcoded to be removed. This can be used to solved the problem "C++ does not catch exceptions when used with Haskell-main and linked by ghc", https://gitlab.haskell.org/ghc/ghc/-/issues/11829 It does not change the default behavior, because I can not estimate the impact this would have. When Apple first introduced the compact unwind ABI, a number of open source projects have taken the easy route of disabling it, avoiding errors or even just warnings shortly after its introduction. Since then, about a decade has passed, so it seems quite possible that Apple itself, and presumably many programs with it, have successfully switched to the new format, to the point where the old __eh_frame section support is in disrepair. Perhaps we should get along with the program, but for now we can test the waters with this flag, and use it to fix packages that need it. - - - - - 5262b1e5 by Robert Hensing at 2022-01-24T21:28:24-05:00 Add test case for C++ exception handling - - - - - a5c94092 by Sebastian Graf at 2022-01-24T21:29:00-05:00 Write Note [Strict State monad] to explain what G.U.M.State.Strict does As requested by Simon after review of !7342. I also took liberty to define the `Functor` instance by hand, as the derived one subverts the invariants maintained by the pattern synonym (as already stated in `Note [The one-shot state monad trick]`). - - - - - 9b0d56d3 by Eric Lindblad at 2022-01-24T21:29:38-05:00 links - - - - - 4eac8e72 by Ben Gamari at 2022-01-24T21:30:13-05:00 ghc-heap: Drop mention of BlockedOnIOCompletion Fixes bootstrap with GHC 9.0 after 5a6efd218734dbb5c1350531680cd3f4177690f1 - - - - - 7d7b9a01 by Ryan Scott at 2022-01-24T21:30:49-05:00 Hadrian: update the index-state to allow building with GHC 9.0.2 Fixes #20984. - - - - - aa50e118 by Peter Trommler at 2022-01-24T21:31:25-05:00 testsuite: Mark test that require RTS linker - - - - - 871ce2a3 by Matthew Pickering at 2022-01-25T17:27:30-05:00 ci: Move (most) deb9 jobs to deb10 deb9 is now end-of-life so we are dropping support for producing bindists. - - - - - 9d478d51 by Ryan Scott at 2022-01-25T17:28:06-05:00 DeriveGeneric: look up datacon fixities using getDataConFixityFun Previously, `DeriveGeneric` would look up the fixity of a data constructor using `getFixityEnv`, but this is subtly incorrect for data constructors defined in external modules. This sort of situation can happen with `StandaloneDeriving`, as noticed in #20994. In fact, the same bug has occurred in the past in #9830, and while that bug was fixed for `deriving Read` and `deriving Show`, the fix was never extended to `DeriveGeneric` due to an oversight. This patch corrects that oversight. Fixes #20994. - - - - - 112e9e9e by Zubin Duggal at 2022-01-25T17:28:41-05:00 Fix Werror on alpine - - - - - 781323a3 by Matthew Pickering at 2022-01-25T17:29:17-05:00 Widen T12545 acceptance window This test has been the scourge of contributors for a long time. It has caused many failed CI runs and wasted hours debugging a test which barely does anything. The fact is does nothing is the reason for the flakiness and it's very sensitive to small changes in initialisation costs, in particular adding wired-in things can cause this test to fluctuate quite a bit. Therefore we admit defeat and just bump the threshold up to 10% to catch very large regressions but otherwise don't care what this test does. Fixes #19414 - - - - - e471a680 by sheaf at 2022-01-26T12:01:45-05:00 Levity-polymorphic arrays and mutable variables This patch makes the following types levity-polymorphic in their last argument: - Array# a, SmallArray# a, Weak# b, StablePtr# a, StableName# a - MutableArray# s a, SmallMutableArray# s a, MutVar# s a, TVar# s a, MVar# s a, IOPort# s a The corresponding primops are also made levity-polymorphic, e.g. `newArray#`, `readArray#`, `writeMutVar#`, `writeIOPort#`, etc. Additionally, exception handling functions such as `catch#`, `raise#`, `maskAsyncExceptions#`,... are made levity/representation-polymorphic. Now that Array# and MutableArray# also work with unlifted types, we can simply re-define ArrayArray# and MutableArrayArray# in terms of them. This means that ArrayArray# and MutableArrayArray# are no longer primitive types, but simply unlifted newtypes around Array# and MutableArrayArray#. This completes the implementation of the Pointer Rep proposal https://github.com/ghc-proposals/ghc-proposals/pull/203 Fixes #20911 ------------------------- Metric Increase: T12545 ------------------------- ------------------------- Metric Decrease: T12545 ------------------------- - - - - - 6e94ba54 by Andreas Klebinger at 2022-01-26T12:02:21-05:00 CorePrep: Don't try to wrap partial applications of primops in profiling ticks. This fixes #20938. - - - - - b55d7db3 by sheaf at 2022-01-26T12:03:01-05:00 Ensure that order of instances doesn't matter The insert_overlapping used in lookupInstEnv used to return different results depending on the order in which instances were processed. The problem was that we could end up discarding an overlapping instance in favour of a more specific non-overlapping instance. This is a problem because, even though we won't choose the less-specific instance for matching, it is still useful for pruning away other instances, because it has the overlapping flag set while the new instance doesn't. In insert_overlapping, we now keep a list of "guard" instances, which are instances which are less-specific that one that matches (and hence which we will discard in the end), but want to keep around solely for the purpose of eliminating other instances. Fixes #20946 - - - - - 61f62062 by sheaf at 2022-01-26T12:03:40-05:00 Remove redundant SOURCE import in FitTypes Fixes #20995 - - - - - e8405829 by sheaf at 2022-01-26T12:04:15-05:00 Fix haddock markup in GHC.Tc.Errors.Types - - - - - 590a2918 by Simon Peyton Jones at 2022-01-26T19:45:22-05:00 Make RULE matching insensitive to eta-expansion This patch fixes #19790 by making the rule matcher do on-the-fly eta reduction. See Note [Eta reduction the target] in GHC.Core.Rules I found I also had to careful about casts when matching; see Note [Casts in the target] and Note [Casts in the template] Lots more comments and Notes in the rule matcher - - - - - c61ac4d8 by Matthew Pickering at 2022-01-26T19:45:58-05:00 alwaysRerun generation of ghcconfig This file needs to match exactly what is passed as the testCompiler. Before this change the settings for the first compiler to be tested woudl be stored and not regenerated if --test-compiler changed. - - - - - b5132f86 by Matthew Pickering at 2022-01-26T19:45:58-05:00 Pass config.stage argument to testsuite - - - - - 83d3ad31 by Zubin Duggal at 2022-01-26T19:45:58-05:00 hadrian: Allow testing of the stage1 compiler (#20755) - - - - - a5924b38 by Joachim Breitner at 2022-01-26T19:46:34-05:00 Simplifier: Do the right thing if doFloatFromRhs = False If `doFloatFromRhs` is `False` then the result from `prepareBinding` should not be used. Previously it was in ways that are silly (but not completly wrong, as the simplifier would clean that up again, so no test case). This was spotted by Simon during a phone call. Fixes #20976 - - - - - ce488c2b by Simon Peyton Jones at 2022-01-26T19:47:09-05:00 Better occurrence analysis with casts This patch addresses #20988 by refactoring the way the occurrence analyser deals with lambdas. Previously it used collectBinders to split off a group of binders, and deal with them together. Now I deal with them one at a time in occAnalLam, which allows me to skip casts easily. See Note [Occurrence analysis for lambda binders] about "lambda-groups" This avoidance of splitting out a list of binders has some good consequences. Less code, more efficient, and I think, more clear. The Simplifier needed a similar change, now that lambda-groups can inlude casts. It turned out that I could simplify the code here too, in particular elminating the sm_bndrs field of StrictBind. Simpler, more efficient. Compile-time metrics improve slightly; here are the ones that are +/- 0.5% or greater: Baseline Test Metric value New value Change -------------------------------------------------------------------- T11303b(normal) ghc/alloc 40,736,702 40,543,992 -0.5% T12425(optasm) ghc/alloc 90,443,459 90,034,104 -0.5% T14683(normal) ghc/alloc 2,991,496,696 2,956,277,288 -1.2% T16875(normal) ghc/alloc 34,937,866 34,739,328 -0.6% T17977b(normal) ghc/alloc 37,908,550 37,709,096 -0.5% T20261(normal) ghc/alloc 621,154,237 618,312,480 -0.5% T3064(normal) ghc/alloc 190,832,320 189,952,312 -0.5% T3294(normal) ghc/alloc 1,604,674,178 1,604,608,264 -0.0% T5321FD(normal) ghc/alloc 270,540,489 251,888,480 -6.9% GOOD T5321Fun(normal) ghc/alloc 300,707,814 281,856,200 -6.3% GOOD WWRec(normal) ghc/alloc 588,460,916 585,536,400 -0.5% geo. mean -0.3% Metric Decrease: T5321FD T5321Fun - - - - - 4007905d by Roland Senn at 2022-01-26T19:47:47-05:00 Cleanup tests in directory ghci.debugger. Fixes #21009 * Remove wrong comment about panic in `break003.script`. * Improve test `break008`. * Add test `break028` to `all.T` * Fix wrong comments in `print019.script`, `print026.script` and `result001.script`. * Remove wrong comments from `print024.script` and `print031.script`. * Replace old module name with current name in `print035.script`. - - - - - 3577defb by Matthew Pickering at 2022-01-26T19:48:22-05:00 ci: Move source-tarball and test-bootstrap into full-build - - - - - 6e09b3cf by Matthew Pickering at 2022-01-27T02:39:35-05:00 ci: Add ENABLE_NUMA flag to explicitly turn on libnuma dependency In recent releases a libnuma dependency has snuck into our bindists because the images have started to contain libnuma. We now explicitly pass `--disable-numa` to configure unless explicitly told not to by using the `ENABLE_NUMA` environment variable. So this is tested, there is one random validate job which builds with --enable-numa so that the code in the RTS is still built. Fixes #20957 and #15444 - - - - - f4ce4186 by Simon Peyton Jones at 2022-01-27T02:40:11-05:00 Improve partial signatures As #20921 showed, with partial signatures, it is helpful to use the same algorithm (namely findInferredDiff) for * picking the constraints to retain for the /group/ in Solver.decideQuantification * picking the contraints to retain for the /individual function/ in Bind.chooseInferredQuantifiers This is still regrettably declicate, but it's a step forward. - - - - - 0573aeab by Simon Peyton Jones at 2022-01-27T02:40:11-05:00 Add an Outputable instance for RecTcChecker - - - - - f0adea14 by Ryan Scott at 2022-01-27T02:40:47-05:00 Expand type synonyms in markNominal `markNominal` is repsonsible for setting the roles of type variables that appear underneath an `AppTy` to be nominal. However, `markNominal` previously did not expand type synonyms, so in a data type like this: ```hs data M f a = MkM (f (T a)) type T a = Int ``` The `a` in `M f a` would be marked nominal, even though `T a` would simply expand to `Int`. The fix is simple: call `coreView` as appropriate in `markNominal`. This is much like the fix for #14101, but in a different spot. Fixes #20999. - - - - - 18df4013 by Simon Peyton Jones at 2022-01-27T08:22:30-05:00 Define and use restoreLclEnv This fixes #20981. See Note [restoreLclEnv vs setLclEnv] in GHC.Tc.Utils.Monad. I also use updLclEnv rather than get/set when I can, because it's then much clearer that it's an update rather than an entirely new TcLclEnv coming from who-knows-where. - - - - - 31088dd3 by David Feuer at 2022-01-27T08:23:05-05:00 Add test supplied in T20996 which uses data family result kind polymorphism David (@treeowl) writes: > Following @kcsongor, I've used ridiculous data family result kind > polymorphism in `linear-generics`, and am currently working on getting > it into `staged-gg`. If it should be removed, I'd appreciate a heads up, > and I imagine Csongor would too. > > What do I need by ridiculous polymorphic result kinds? Currently, data > families are allowed to have result kinds that end in `Type` (or maybe > `TYPE r`? I'm not sure), but not in concrete data kinds. However, they > *are* allowed to have polymorphic result kinds. This leads to things I > think most of us find at least quite *weird*. For example, I can write > > ```haskell > data family Silly :: k > data SBool :: Bool -> Type where > SFalse :: SBool False > STrue :: SBool True > SSSilly :: SBool Silly > type KnownBool b where > kb :: SBool b > instance KnownBool False where kb = SFalse > instance KnownBool True where kb = STrue > instance KnownBool Silly where kb = Silly > ``` > > Basically, every kind now has potentially infinitely many "legit" inhabitants. > > As horrible as that is, it's rather useful for GHC's current native > generics system. It's possible to use these absurdly polymorphic result > kinds to probe the structure of generic representations in a relatively > pleasant manner. It's a sort of "formal type application" reminiscent of > the notion of a formal power series (see the test case below). I suspect > a system more like `kind-generics` wouldn't need this extra probing > power, but nothing like that is natively available as yet. > > If the ridiculous result kind polymorphism is banished, we'll still be > able to do what we need as long as we have stuck type families. It's > just rather less ergonomical: a stuck type family has to be used with a > concrete marker type argument. Closes #20996 Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 8fd2ac25 by Andreas Abel at 2022-01-27T18:34:54-05:00 Whitespace only - - - - - 7a854743 by Andreas Abel at 2022-01-27T18:34:54-05:00 Ctd. #18087: complete :since: info for all warnings in users guide Some warnings have been there "forever" and I could not trace back the exact genesis, so I wrote "since at least 5.04". The flag `helpful-errors` could have been added in 7.2 already. I wrote 7.4 since I have no 7.2 available and it is not recognized by 7.0. - - - - - f75411e8 by Andreas Abel at 2022-01-27T18:34:54-05:00 Re #18087 user's guide: add a note that -Wxxx used to be -fwarn-xxx The warning option syntax -W was introduced in GHC 8. The note should clarify what e.g. "since 7.6" means in connection with "-Wxxx": That "-fwarn-xxx" was introduced in 7.6.1. [ci skip] - - - - - 3cae7fde by Peter Trommler at 2022-01-27T18:35:30-05:00 testsuite: Fix AtomicPrimops test on big endian - - - - - 6cc6080c by Ben Gamari at 2022-01-27T18:36:05-05:00 users-guide: Document GHC_CHARENC environment variable As noted in #20963, this was introduced in 1b56c40578374a15b4a2593895710c68b0e2a717 but was no documentation was added at that point. Closes #20963. - - - - - ee21e2de by Ben Gamari at 2022-01-27T18:36:41-05:00 rts: Clean up RTS flags usage message Align flag descriptions and acknowledge that some flags may not be available unless the user linked with `-rtsopts` (as noted in #20961). Fixes #20961. - - - - - 7f8ce19e by Simon Peyton Jones at 2022-01-27T18:37:17-05:00 Fix getHasGivenEqs The second component is supposed to be "insoluble equalities arising from givens". But we were getting wanteds too; and that led to an outright duplication of constraints. It's not harmful, but it's not right either. I came across this when debugging something else. Easily fixed. - - - - - f9ef2d26 by Simon Peyton Jones at 2022-01-27T18:37:17-05:00 Set the TcLclEnv when solving a ForAll constraint Fix a simple omission in GHC.Tc.Solver.Canonical.solveForAll, where we ended up with the wrong TcLclEnv captured in an implication. Result: unhelpful error message (#21006) - - - - - bc6ba8ef by Sylvain Henry at 2022-01-28T12:14:41-05:00 Make most shifts branchless - - - - - 62a6d037 by Simon Peyton Jones at 2022-01-28T12:15:17-05:00 Improve boxity in deferAfterPreciseException As #20746 showed, the demand analyser behaved badly in a key I/O library (`GHC.IO.Handle.Text`), by unnessarily boxing and reboxing. This patch adjusts the subtle function deferAfterPreciseException; it's quite easy, just a bit subtle. See the new Note [deferAfterPreciseException] And this MR deals only with Problem 2 in #20746. Problem 1 is still open. - - - - - 42c47cd6 by Ben Gamari at 2022-01-29T02:40:45-05:00 rts/trace: Shrink tracing flags - - - - - cee66e71 by Ben Gamari at 2022-01-29T02:40:45-05:00 rts/EventLog: Mark various internal globals as static - - - - - 6b0cea29 by Ben Gamari at 2022-01-29T02:40:45-05:00 Propagate PythonCmd to make build system - - - - - 2e29edb7 by Ben Gamari at 2022-01-29T02:40:45-05:00 rts: Refactor event types Previously we would build the eventTypes array at runtime during RTS initialization. However, this is completely unnecessary; it is completely static data. - - - - - bb15c347 by Ben Gamari at 2022-01-29T02:40:45-05:00 rts/eventlog: Ensure that flushCount is initialized - - - - - 268efcc9 by Matthew Pickering at 2022-01-29T02:41:21-05:00 Rework the handling of SkolemInfo The main purpose of this patch is to attach a SkolemInfo directly to each SkolemTv. This fixes the large number of bugs which have accumulated over the years where we failed to report errors due to having "no skolem info" for particular type variables. Now the origin of each type varible is stored on the type variable we can always report accurately where it cames from. Fixes #20969 #20732 #20680 #19482 #20232 #19752 #10946 #19760 #20063 #13499 #14040 The main changes of this patch are: * SkolemTv now contains a SkolemInfo field which tells us how the SkolemTv was created. Used when reporting errors. * Enforce invariants relating the SkolemInfoAnon and level of an implication (ic_info, ic_tclvl) to the SkolemInfo and level of the type variables in ic_skols. * All ic_skols are TcTyVars -- Check is currently disabled * All ic_skols are SkolemTv * The tv_lvl of the ic_skols agrees with the ic_tclvl * The ic_info agrees with the SkolInfo of the implication. These invariants are checked by a debug compiler by checkImplicationInvariants. * Completely refactor kcCheckDeclHeader_sig which kept doing my head in. Plus, it wasn't right because it wasn't skolemising the binders as it decomposed the kind signature. The new story is described in Note [kcCheckDeclHeader_sig]. The code is considerably shorter than before (roughly 240 lines turns into 150 lines). It still has the same awkward complexity around computing arity as before, but that is a language design issue. See Note [Arity inference in kcCheckDeclHeader_sig] * I added new type synonyms MonoTcTyCon and PolyTcTyCon, and used them to be clear which TcTyCons have "finished" kinds etc, and which are monomorphic. See Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon] * I renamed etaExpandAlgTyCon to splitTyConKind, becuase that's a better name, and it is very useful in kcCheckDeclHeader_sig, where eta-expansion isn't an issue. * Kill off the nasty `ClassScopedTvEnv` entirely. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 0a1d0944 by Ben Gamari at 2022-01-29T14:52:55-05:00 Drop SPARC NCG - - - - - 313afb3d by Ben Gamari at 2022-01-29T14:52:56-05:00 A few comment cleanups - - - - - d85a527f by Ben Gamari at 2022-01-29T14:52:56-05:00 Rip out SPARC register support - - - - - c6bede69 by Ben Gamari at 2022-01-29T14:52:56-05:00 rts: Rip out SPARC support - - - - - a67c2471 by Ben Gamari at 2022-01-29T14:52:56-05:00 Rip out remaining SPARC support - - - - - 5771b690 by Ben Gamari at 2022-01-29T14:52:56-05:00 CmmToAsm: Drop RegPair SPARC was its last and only user. - - - - - 512ed3f1 by Ben Gamari at 2022-01-29T14:52:56-05:00 CmmToAsm: Make RealReg a newtype Now that RegPair is gone we no longer need to pay for the additional box. - - - - - 88fea6aa by Ben Gamari at 2022-01-29T14:52:56-05:00 rts: Drop redundant #include <Arena.h> - - - - - ea2a4034 by Ben Gamari at 2022-01-29T14:52:56-05:00 CmmToAsm: Drop ncgExpandTop This was only needed for SPARC's synthetic instructions. - - - - - 88fce740 by Ben Gamari at 2022-01-29T14:54:04-05:00 rel-notes: Note dropping of SPARC support - - - - - eb956cf1 by Ben Gamari at 2022-01-30T06:27:19-05:00 testsuite: Force-enable caret diagnostics in T17786 Otherwise GHC realizes that it's not attached to a proper tty and will disable caret diagnostics. - - - - - d07799ab by Ben Gamari at 2022-01-30T06:27:19-05:00 testsuite: Make T7275 more robust against CCid changes The cost-center numbers are somewhat unstable; normalise them out. - - - - - c76c8050 by Ben Gamari at 2022-01-30T06:27:19-05:00 rts: Don't allocate closurePtrs# pointers on C stack Previously `closurePtrs#` would allocate an aray of the size of the closure being decoded on the C stack. This was ripe for overflowing the C stack overflow. This resulted in `T12492` failing on Windows. - - - - - 3af95f7a by Ben Gamari at 2022-01-30T06:27:19-05:00 testsuite/T4029: Don't depend on echo On Windows the `cmd.exe` shell may be used to execute the command, which will print `ECHO is on.` instead of a newline if you give it no argument. Avoid this by rather using `printf`. - - - - - 3531c478 by Ben Gamari at 2022-01-30T06:27:19-05:00 Use PATH_FMT instead of %s to format `pathchar *` A few %s occurrences have snuck in over the past months. - - - - - ee5c4f9d by Zubin Duggal at 2022-01-31T16:51:55+05:30 Improve migration strategy for the XDG compliance change to the GHC application directory. We want to always use the old path (~/.ghc/..) if it exists. But we never want to create the old path. This ensures that the migration can eventually be completed once older GHC versions are no longer in circulation. Fixes #20684, #20669, #20660 - - - - - 60a54a8f by doyougnu at 2022-01-31T18:46:11-05:00 StgToCmm: decouple DynFlags, add StgToCmmConfig StgToCmm: add Config, remove CgInfoDownwards StgToCmm: runC api change to take StgToCmmConfig StgToCmm: CgInfoDownad -> StgToCmmConfig StgToCmm.Monad: update getters/setters/withers StgToCmm: remove CallOpts in StgToCmm.Closure StgToCmm: remove dynflag references StgToCmm: PtrOpts removed StgToCmm: add TMap to config, Prof - dynflags StgToCmm: add omit yields to config StgToCmm.ExtCode: remove redundant import StgToCmm.Heap: remove references to dynflags StgToCmm: codeGen api change, DynFlags -> Config StgToCmm: remove dynflags in Env and StgToCmm StgToCmm.DataCon: remove dynflags references StgToCmm: remove dynflag references in DataCon StgToCmm: add backend avx flags to config StgToCmm.Prim: remove dynflag references StgToCmm.Expr: remove dynflag references StgToCmm.Bind: remove references to dynflags StgToCmm: move DoAlignSanitisation to Cmm.Type StgToCmm: remove PtrOpts in Cmm.Parser.y DynFlags: update ipInitCode api StgToCmm: Config Module is single source of truth StgToCmm: Lazy config breaks IORef deadlock testsuite: bump countdeps threshold StgToCmm.Config: strictify fields except UpdFrame Strictifying UpdFrameOffset causes the RTS build with stage1 to deadlock. Additionally, before the deadlock performance of the RTS is noticeably slower. StgToCmm.Config: add field descriptions StgToCmm: revert strictify on Module in config testsuite: update CountDeps tests StgToCmm: update comment, fix exports Specifically update comment about loopification passed into dynflags then stored into stgToCmmConfig. And remove getDynFlags from Monad.hs exports Types.Name: add pprFullName function StgToCmm.Ticky: use pprFullname, fixup ExtCode imports Cmm.Info: revert cmmGetClosureType removal StgToCmm.Bind: use pprFullName, Config update comments StgToCmm: update closureDescription api StgToCmm: SAT altHeapCheck StgToCmm: default render for Info table, ticky Use default rendering contexts for info table and ticky ticky, which should be independent of command line input. testsuite: bump count deps pprFullName: flag for ticky vs normal style output convertInfoProvMap: remove unused parameter StgToCmm.Config: add backend flags to config StgToCmm.Config: remove Backend from Config StgToCmm.Prim: refactor Backend call sites StgToCmm.Prim: remove redundant imports StgToCmm.Config: refactor vec compatibility check StgToCmm.Config: add allowQuotRem2 flag StgToCmm.Ticky: print internal names with parens StgToCmm.Bind: dispatch ppr based on externality StgToCmm: Add pprTickyname, Fix ticky naming Accidently removed the ctx for ticky SDoc output. The only relevant flag is sdocPprDebug which was accidental set to False due to using defaultSDocContext without altering the flag. StgToCmm: remove stateful fields in config fixup: config: remove redundant imports StgToCmm: move Sequel type to its own module StgToCmm: proliferate getCallMethod updated api StgToCmm.Monad: add FCodeState to Monad Api StgToCmm: add second reader monad to FCode fixup: Prim.hs: missed a merge conflict fixup: Match countDeps tests to HEAD StgToCmm.Monad: withState -> withCgState To disambiguate it from mtl withState. This withState shouldn't be returning the new state as a value. However, fixing this means tackling the knot tying in CgState and so is very difficult since it changes when the thunk of the knot is forced which either leads to deadlock or to compiler panic. - - - - - 58eccdbc by Ben Gamari at 2022-01-31T18:46:47-05:00 codeGen: Fix two buglets in -fbounds-check logic @Bodigrim noticed that the `compareByteArray#` bounds-checking logic had flipped arguments and an off-by-one. For the sake of clarity I also refactored occurrences of `cmmOffset` to rather use `cmmOffsetB`. I suspect the former should be retired. - - - - - 584f03fa by Simon Peyton Jones at 2022-01-31T18:47:23-05:00 Make typechecker trace less strict Fixes #21011 - - - - - 60ac7300 by Elton at 2022-02-01T12:28:49-05:00 Use braces in TH case pprint (fixes #20893) This patch ensures that the pretty printer formats `case` statements using braces (instead of layout) to remain consistent with the formatting of other statements (like `do`) - - - - - fdda93b0 by Elton at 2022-02-01T12:28:49-05:00 Use braces in TH LambdaCase and where clauses This patch ensures that the pretty printer formats LambdaCase and where clauses using braces (instead of layout) to remain consistent with the formatting of other statements (like `do` and `case`) - - - - - 06185102 by Ben Gamari at 2022-02-01T12:29:26-05:00 Consistently upper-case "Note [" This was achieved with git ls-tree --name-only HEAD -r | xargs sed -i -e 's/note \[/Note \[/g' - - - - - 88fba8a4 by Ben Gamari at 2022-02-01T12:29:26-05:00 Fix a few Note inconsistencies - - - - - 05548a22 by Douglas Wilson at 2022-02-02T19:26:06-05:00 rts: Address failures to inline - - - - - 074945de by Simon Peyton Jones at 2022-02-02T19:26:41-05:00 Two small improvements in the Simplifier As #20941 describes, this patch implements a couple of small fixes to the Simplifier. They make a difference principally with -O0, so few people will notice. But with -O0 they can reduce the number of Simplifer iterations. * In occurrence analysis we avoid making x = (a,b) into a loop breaker because we want to be able to inline x, or (more likely) do case-elimination. But HEAD does not treat x = let y = blah in (a,b) in the same way. We should though, because we are going to float that y=blah out of the x-binding. A one-line fix in OccurAnal. * The crucial function exprIsConApp_maybe uses getUnfoldingInRuleMatch (rightly) but the latter was deeply strange. In HEAD, if rule-rewriting was off (-O0) we only looked inside stable unfoldings. Very stupid. The patch simplifies. * I also noticed that in simplStableUnfolding we were failing to delete the DFun binders from the usage. So I added that. Practically zero perf change across the board, except that we get more compiler allocation in T3064 (which is compiled with -O0). There's a good reason: we get better code. But there are lots of other small compiler allocation decreases: Metrics: compile_time/bytes allocated --------------------- Baseline Test Metric value New value Change ----------------------------------------------------------------- PmSeriesG(normal) ghc/alloc 44,260,817 44,184,920 -0.2% PmSeriesS(normal) ghc/alloc 52,967,392 52,891,632 -0.1% PmSeriesT(normal) ghc/alloc 75,498,220 75,421,968 -0.1% PmSeriesV(normal) ghc/alloc 52,341,849 52,265,768 -0.1% T10421(normal) ghc/alloc 109,702,291 109,626,024 -0.1% T10421a(normal) ghc/alloc 76,888,308 76,809,896 -0.1% T10858(normal) ghc/alloc 125,149,038 125,073,648 -0.1% T11276(normal) ghc/alloc 94,159,364 94,081,640 -0.1% T11303b(normal) ghc/alloc 40,230,059 40,154,368 -0.2% T11822(normal) ghc/alloc 107,424,540 107,346,088 -0.1% T12150(optasm) ghc/alloc 76,486,339 76,426,152 -0.1% T12234(optasm) ghc/alloc 55,585,046 55,507,352 -0.1% T12425(optasm) ghc/alloc 88,343,288 88,265,312 -0.1% T13035(normal) ghc/alloc 98,919,768 98,845,600 -0.1% T13253-spj(normal) ghc/alloc 121,002,153 120,851,040 -0.1% T16190(normal) ghc/alloc 290,313,131 290,074,152 -0.1% T16875(normal) ghc/alloc 34,756,121 34,681,440 -0.2% T17836b(normal) ghc/alloc 45,198,100 45,120,288 -0.2% T17977(normal) ghc/alloc 39,479,952 39,404,112 -0.2% T17977b(normal) ghc/alloc 37,213,035 37,137,728 -0.2% T18140(normal) ghc/alloc 79,430,588 79,350,680 -0.1% T18282(normal) ghc/alloc 128,303,182 128,225,384 -0.1% T18304(normal) ghc/alloc 84,904,713 84,831,952 -0.1% T18923(normal) ghc/alloc 66,817,241 66,731,984 -0.1% T20049(normal) ghc/alloc 86,188,024 86,107,920 -0.1% T5837(normal) ghc/alloc 35,540,598 35,464,568 -0.2% T6048(optasm) ghc/alloc 99,812,171 99,736,032 -0.1% T9198(normal) ghc/alloc 46,380,270 46,304,984 -0.2% geo. mean -0.0% Metric Increase: T3064 - - - - - d2cce453 by Morrow at 2022-02-02T19:27:21-05:00 Fix @since annotation on Nat - - - - - 6438fed9 by Simon Peyton Jones at 2022-02-02T19:27:56-05:00 Refactor the escaping kind check for data constructors As #20929 pointed out, we were in-elegantly checking for escaping kinds in `checkValidType`, even though that check was guaranteed to succeed for type signatures -- it's part of kind-checking a type. But for /data constructors/ we kind-check the pieces separately, so we still need the check. This MR is a pure refactor, moving the test from `checkValidType` to `checkValidDataCon`. No new tests; external behaviour doesn't change. - - - - - fb05e5ac by Andreas Klebinger at 2022-02-02T19:28:31-05:00 Replace sndOfTriple with sndOf3 I also cleaned up the imports slightly while I was at it. - - - - - fbc77d3a by Matthew Pickering at 2022-02-02T19:29:07-05:00 testsuite: Honour PERF_BASELINE_COMMIT when computing allowed metric changes We now get all the commits between the PERF_BASELINE_COMMIT and HEAD and check any of them for metric changes. Fixes #20882 - - - - - 0a82ae0d by Simon Peyton Jones at 2022-02-02T23:49:58-05:00 More accurate unboxing This patch implements a fix for #20817. It ensures that * The final strictness signature for a function accurately reflects the unboxing done by the wrapper See Note [Finalising boxity for demand signatures] and Note [Finalising boxity for let-bound Ids] * A much better "layer-at-a-time" implementation of the budget for how many worker arguments we can have See Note [Worker argument budget] Generally this leads to a bit more worker/wrapper generation, because instead of aborting entirely if the budget is exceeded (and then lying about boxity), we unbox a bit. Binary sizes in increase slightly (around 1.8%) because of the increase in worker/wrapper generation. The big effects are to GHC.Ix, GHC.Show, GHC.IO.Handle.Internals. If we did a better job of dropping dead code, this effect might go away. Some nofib perf improvements: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- VSD +1.8% -0.5% 0.017 0.017 0.0% awards +1.8% -0.1% +2.3% +2.3% 0.0% banner +1.7% -0.2% +0.3% +0.3% 0.0% bspt +1.8% -0.1% +3.1% +3.1% 0.0% eliza +1.8% -0.1% +1.2% +1.2% 0.0% expert +1.7% -0.1% +9.6% +9.6% 0.0% fannkuch-redux +1.8% -0.4% -9.3% -9.3% 0.0% kahan +1.8% -0.1% +22.7% +22.7% 0.0% maillist +1.8% -0.9% +21.2% +21.6% 0.0% nucleic2 +1.7% -5.1% +7.5% +7.6% 0.0% pretty +1.8% -0.2% 0.000 0.000 0.0% reverse-complem +1.8% -2.5% +12.2% +12.2% 0.0% rfib +1.8% -0.2% +2.5% +2.5% 0.0% scc +1.8% -0.4% 0.000 0.000 0.0% simple +1.7% -1.3% +17.0% +17.0% +7.4% spectral-norm +1.8% -0.1% +6.8% +6.7% 0.0% sphere +1.7% -2.0% +13.3% +13.3% 0.0% tak +1.8% -0.2% +3.3% +3.3% 0.0% x2n1 +1.8% -0.4% +8.1% +8.1% 0.0% -------------------------------------------------------------------------------- Min +1.1% -5.1% -23.6% -23.6% 0.0% Max +1.8% +0.0% +36.2% +36.2% +7.4% Geometric Mean +1.7% -0.1% +6.8% +6.8% +0.1% Compiler allocations in CI have a geometric mean of +0.1%; many small decreases but there are three bigger increases (7%), all because we do more worker/wrapper than before, so there is simply more code to compile. That's OK. Perf benchmarks in perf/should_run improve in allocation by a geo mean of -0.2%, which is good. None get worse. T12996 improves by -5.8% Metric Decrease: T12996 Metric Increase: T18282 T18923 T9630 - - - - - d1ef6288 by Peter Trommler at 2022-02-02T23:50:34-05:00 Cmm: fix equality of expressions Compare expressions and types when comparing `CmmLoad`s. Fixes #21016 - - - - - e59446c6 by Peter Trommler at 2022-02-02T23:50:34-05:00 Check type first then expression - - - - - b0e1ef4a by Matthew Pickering at 2022-02-03T14:44:17-05:00 Add failing test for #20791 The test produces different output on static vs dynamic GHC builds. - - - - - cae1fb17 by Matthew Pickering at 2022-02-03T14:44:17-05:00 Frontend01 passes with static GHC - - - - - e343526b by Matthew Pickering at 2022-02-03T14:44:17-05:00 Don't initialise plugins when there are no pipelines to run - - - - - abac45fc by Matthew Pickering at 2022-02-03T14:44:17-05:00 Mark prog003 as expected_broken on static way #20704 - - - - - 13300dfd by Matthew Pickering at 2022-02-03T14:44:17-05:00 Filter out -rtsopts in T16219 to make static/dynamic ways agree - - - - - d89439f2 by Matthew Pickering at 2022-02-03T14:44:17-05:00 T13168: Filter out rtsopts for consistency between dynamic and static ways - - - - - 00180cdf by Matthew Pickering at 2022-02-03T14:44:17-05:00 Accept new output for T14335 test This test was previously not run due to #20960 - - - - - 1accdcff by Matthew Pickering at 2022-02-03T14:44:17-05:00 Add flushes to plugin tests which print to stdout Due to #20791 you need to explicitly flush as otherwise the output from these tests doesn't make it to stdout. - - - - - d820f2e8 by Matthew Pickering at 2022-02-03T14:44:17-05:00 Remove ghc_plugin_way Using ghc_plugin_way had the unintended effect of meaning certain tests weren't run at all when ghc_dynamic=true, if you delete this modifier then the tests work in both the static and dynamic cases. - - - - - aa5ef340 by Matthew Pickering at 2022-02-03T14:44:17-05:00 Unbreak T13168 on windows Fixes #14276 - - - - - 84ab0153 by Matthew Pickering at 2022-02-03T14:44:53-05:00 Rewrite CallerCC parser using ReadP This allows us to remove the dependency on parsec and hence transitively on text. Also added some simple unit tests for the parser and fixed two small issues in the documentation. Fixes #21033 - - - - - 4e6780bb by Matthew Pickering at 2022-02-03T14:45:28-05:00 ci: Add debian 11 jobs (validate/release/nightly) Fixes #21002 - - - - - eddaa591 by Ben Gamari at 2022-02-04T10:01:59-05:00 compiler: Introduce and use RoughMap for instance environments Here we introduce a new data structure, RoughMap, inspired by the previous `RoughTc` matching mechanism for checking instance matches. This allows [Fam]InstEnv to be implemented as a trie indexed by these RoughTc signatures, reducing the complexity of instance lookup and FamInstEnv merging (done during the family instance conflict test) from O(n) to O(log n). The critical performance improvement currently realised by this patch is in instance matching. In particular the RoughMap mechanism allows us to discount many potential instances which will never match for constraints involving type variables (see Note [Matching a RoughMap]). In realistic code bases matchInstEnv was accounting for 50% of typechecker time due to redundant work checking instances when simplifying instance contexts when deriving instances. With this patch the cost is significantly reduced. The larger constants in InstEnv creation do mean that a few small tests regress in allocations slightly. However, the runtime of T19703 is reduced by a factor of 4. Moreover, the compilation time of the Cabal library is slightly improved. A couple of test cases are included which demonstrate significant improvements in compile time with this patch. This unfortunately does not fix the testcase provided in #19703 but does fix #20933 ------------------------- Metric Decrease: T12425 Metric Increase: T13719 T9872a T9872d hard_hole_fits ------------------------- Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 62d670eb by Matthew Pickering at 2022-02-04T10:02:35-05:00 testsuite: Run testsuite dependency calculation before GHC is built The main motivation for this patch is to allow tests to be added to the testsuite which test things about the source tree without needing to build GHC. In particular the notes linter can easily start failing and by integrating it into the testsuite the process of observing these changes is caught by normal validation procedures rather than having to run the linter specially. With this patch I can run ``` ./hadrian/build test --flavour=devel2 --only="uniques" ``` In a clean tree to run the checkUniques linter without having to build GHC. Fixes #21029 - - - - - 4bd52410 by Hécate Moonlight at 2022-02-04T16:14:10-05:00 Add the Ix class to Foreign C integral types Related CLC proposal is here: https://github.com/haskell/core-libraries-committee/issues/30 - - - - - de6d7692 by Ben Gamari at 2022-02-04T16:14:47-05:00 Drop dead code - - - - - b79206f1 by Ben Gamari at 2022-02-04T16:14:47-05:00 Add comments - - - - - 58d7faac by Ben Gamari at 2022-02-04T16:14:47-05:00 cmm: Introduce cmmLoadBWord and cmmLoadGCWord - - - - - 7217156c by Ben Gamari at 2022-02-04T16:14:47-05:00 Introduce alignment in CmmLoad - - - - - 99ea5f2c by Ben Gamari at 2022-02-04T16:14:47-05:00 Introduce alignment to CmmStore - - - - - 606b59a5 by Ben Gamari at 2022-02-04T16:14:47-05:00 Fix array primop alignment - - - - - 1cf9616a by Ben Gamari at 2022-02-04T16:14:47-05:00 llvmGen: Handle unaligned loads/stores This allows us to produce valid code for indexWord8ArrayAs*# on platforms that lack unaligned memory access. - - - - - 8c18feba by Ben Gamari at 2022-02-04T16:14:47-05:00 primops: Fix documentation of setByteArray# Previously the documentation was subtly incorrect regarding the bounds of the operation. Fix this and add a test asserting that a zero-length operation is in fact a no-op. - - - - - 88480e55 by nineonine at 2022-02-04T20:35:45-05:00 Fix unsound behavior of unlifted datatypes in ghci (#20194) Previously, directly calling a function that pattern matches on an unlifted data type which has at least two constructors in GHCi resulted in a segfault. This happened due to unaccounted return frame info table pointer. The fix is to pop the above mentioned frame info table pointer when unlifted things are returned. See Note [Popping return frame for unlifted things] authors: bgamari, nineonine - - - - - a5c7068c by Simon Peyton Jones at 2022-02-04T20:36:20-05:00 Add Outputable instance for Messages c.f. #20980 - - - - - bf495f72 by Simon Peyton Jones at 2022-02-04T20:36:20-05:00 Add a missing restoreLclEnv The commit commit 18df4013f6eaee0e1de8ebd533f7e96c4ee0ff04 Date: Sat Jan 22 01:12:30 2022 +0000 Define and use restoreLclEnv omitted to change one setLclEnv to restoreLclEnv, namely the one in GHC.Tc.Errors.warnRedundantConstraints. This new commit fixes the omission. - - - - - 6af8e71e by Simon Peyton Jones at 2022-02-04T20:36:20-05:00 Improve errors for non-existent labels This patch fixes #17469, by improving matters when you use non-existent field names in a record construction: data T = MkT { x :: Int } f v = MkT { y = 3 } The check is now made in the renamer, in GHC.Rename.Env.lookupRecFieldOcc. That in turn led to a spurious error in T9975a, which is fixed by making GHC.Rename.Names.extendGlobalRdrEnvRn fail fast if it finds duplicate bindings. See Note [Fail fast on duplicate definitions] in that module for more details. This patch was originated and worked on by Alex D (@nineonine) - - - - - 299acff0 by nineonine at 2022-02-05T19:21:49-05:00 Exit with failure when -e fails (fixes #18411 #9916 #17560) - - - - - 549292eb by Matthew Pickering at 2022-02-05T19:22:25-05:00 Make implication tidying agree with Note [Tidying multiple names at once] Note [Tidying multiple names at once] indicates that if multiple variables have the same name then we shouldn't prioritise one of them and instead rename them all to a1, a2, a3... etc This patch implements that change, some error message changes as expected. Closes #20932 - - - - - 2e9248b7 by Ben Gamari at 2022-02-06T01:43:56-05:00 rts/m32: Accept any address within 4GB of program text Previously m32 would assume that the program image was located near the start of the address space and therefore assume that it wanted pages in the bottom 4GB of address space. Instead we now check whether they are within 4GB of whereever the program is loaded. This is necessary on Windows, which now tends to place the image in high memory. The eventual goal is to use m32 to allocate memory for linker sections on Windows. - - - - - 86589b89 by GHC GitLab CI at 2022-02-06T01:43:56-05:00 rts: Generalize mmapForLinkerMarkExecutable Renamed to mprotectForLinker and allowed setting of arbitrary protection modes. - - - - - 88ef270a by GHC GitLab CI at 2022-02-06T01:43:56-05:00 rts/m32: Add consistency-checking infrastructure This adds logic, enabled in the `-debug` RTS for checking the internal consistency of the m32 allocator. This area has always made me a bit nervous so this should help me sleep better at night in exchange for very little overhead. - - - - - 2d6f0b17 by Ben Gamari at 2022-02-06T01:43:56-05:00 rts/m32: Free large objects back to the free page pool Not entirely convinced that this is worth doing. - - - - - e96f50be by GHC GitLab CI at 2022-02-06T01:43:56-05:00 rts/m32: Increase size of free page pool to 256 pages - - - - - fc083b48 by Ben Gamari at 2022-02-06T01:43:56-05:00 rts: Dump memory map on memory mapping failures Fixes #20992. - - - - - 633296bc by Ben Gamari at 2022-02-06T01:43:56-05:00 Fix macro redefinition warnings for PRINTF * Move `PRINTF` macro from `Stats.h` to `Stats.c` as it's only needed in the latter. * Undefine `PRINTF` at the end of `Messages.h` to avoid leaking it. - - - - - 37d435d2 by John Ericson at 2022-02-06T01:44:32-05:00 Purge DynFlags from GHC.Stg Also derive some more instances. GHC doesn't need them, but downstream consumers may need to e.g. put stuff in maps. - - - - - 886baa34 by Peter Trommler at 2022-02-06T10:58:18+01:00 RTS: Fix cabal specification In 35bea01b xxhash.c was removed. Remove the extra-source-files stanza referring to it. - - - - - 27581d77 by Alex D at 2022-02-06T20:50:44-05:00 hadrian: remove redundant import - - - - - 4ff19981 by John Ericson at 2022-02-07T11:04:43-05:00 GHC.HsToCore.Coverage: No more HscEnv, less DynFlags Progress towards #20730 - - - - - b09389a6 by John Ericson at 2022-02-07T11:04:43-05:00 Create `CoverageConfig` As requested by @mpickering to collect the information we project from `HscEnv` - - - - - ff867c46 by Greg Steuck at 2022-02-07T11:05:24-05:00 Avoid using removed utils/checkUniques in validate Asked the question: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7460/diffs#4061f4d17546e239dd10d78c6b48668c2a288e02_1_0 - - - - - a9355e84 by sheaf at 2022-02-08T05:27:25-05:00 Allow HasField in quantified constraints We perform validity checking on user-written HasField instances, for example to disallow: data Foo a = Foo { fld :: Int } instance HasField "fld" (Foo a) Bool However, these checks were also being made on quantified constraints, e.g. data Bar where Bar :: (forall a. HasField s (Foo a) Int) => Proxy s -> Bar This patch simply skips validity checking for quantified constraints, in line with what we already do for equality constraints such as Coercible. Fixes #20989 - - - - - 6d77d3d8 by sheaf at 2022-02-08T05:28:05-05:00 Relax TyEq:N: allow out-of-scope newtype DataCon The 'bad_newtype' assertion in GHC.Tc.Solver.Canonical.canEqCanLHSFinish failed to account for the possibility that the newtype constructor might not be in scope, in which case we don't provide any guarantees about canonicalising away a newtype on the RHS of a representational equality. Fixes #21010 - - - - - a893d2f3 by Matthew Pickering at 2022-02-08T05:28:42-05:00 Remove linter dependency on lint-submods - - - - - 457a5b9c by Ben Gamari at 2022-02-08T05:28:42-05:00 notes-util: initial commit - - - - - 1a943859 by Ben Gamari at 2022-02-08T05:28:42-05:00 gitlab-ci: Add lint-notes job - - - - - bc5cbce6 by Matthew Pickering at 2022-02-08T05:28:42-05:00 Add notes linter to testsuite - - - - - 38c6e301 by Matthew Pickering at 2022-02-08T05:28:42-05:00 Fix some notes - - - - - c3aac0f8 by Matthew Pickering at 2022-02-08T05:28:42-05:00 Add suggestion mode to notes-util - - - - - 5dd29aea by Cale Gibbard at 2022-02-08T05:29:18-05:00 `hscSimpleIface` drop fingerprint param and ret `hscSimpleIface` does not depend on or modify the `Maybe Fingerprint` it is given, only passes it through, so get rid of the extraneous passing. Perhaps the intent was that there would be an iface fingerprint check of some sort? but this was never done. If/when we we want to do that, we can add it back then. - - - - - 4bcbd731 by Cale Gibbard at 2022-02-08T05:29:54-05:00 Document `hscIncrementalFrontend` and flip bool - - - - - b713db1e by John Ericson at 2022-02-08T05:30:29-05:00 StgToCmm: Get rid of GHC.Driver.Session imports `DynFlags` is gone, but let's move a few trivial things around to get rid of its module too. - - - - - f115c382 by Gleb Popov at 2022-02-08T05:31:05-05:00 Fix build on recent FreeBSD. Recent FreeBSD versions gained the sched_getaffinity function, which made two mutually exclusive #ifdef blocks to be enabled. - - - - - 3320ab40 by Ben Gamari at 2022-02-08T10:42:04-05:00 rts/MemoryMap: Use mach_-prefixed type names There appears to be some inconsistency in system-call type naming across Darwin toolchains. Specifically: * the `address` argument to `mach_vm_region` apparently wants to be a `mach_vm_address_t *`, not a `vm_address_t *` * the `vmsize` argument to `mach_vm_region` wants to be a `mach_vm_size_t`, not a `vm_size_t` - - - - - b33f0cfa by Richard Eisenberg at 2022-02-08T10:42:41-05:00 Document that reifyRoles includes kind parameters Close #21056 - - - - - bd493ed6 by PHO at 2022-02-08T10:43:19-05:00 Don't try to build stage1 with -eventlog if stage0 doesn't provide it Like -threaded, stage0 isn't guaranteed to have an event-logging RTS. - - - - - 03c2de0f by Matthew Pickering at 2022-02-09T03:56:22-05:00 testsuite: Use absolute paths for config.libdir Fixes #21052 - - - - - ef294525 by Matthew Pickering at 2022-02-09T03:56:22-05:00 testsuite: Clean up old/redundant predicates - - - - - a39ed908 by Matthew Pickering at 2022-02-09T03:56:22-05:00 testsuite: Add missing dependency on ghcconfig - - - - - a172be07 by PHO at 2022-02-09T03:56:59-05:00 Implement System.Environment.getExecutablePath for NetBSD and also use it from GHC.BaseDir.getBaseDir - - - - - 62fa126d by PHO at 2022-02-09T03:57:37-05:00 Fix a portability issue in m4/find_llvm_prog.m4 `test A == B' is a Bash extension, which doesn't work on platforms where /bin/sh is not Bash. - - - - - fd9981e3 by Ryan Scott at 2022-02-09T03:58:13-05:00 Look through untyped TH splices in tcInferAppHead_maybe Previously, surrounding a head expression with a TH splice would defeat `tcInferAppHead_maybe`, preventing some expressions from typechecking that used to typecheck in previous GHC versions (see #21038 for examples). This is simple enough to fix: just look through `HsSpliceE`s in `tcInferAppHead_maybe`. I've added some additional prose to `Note [Application chains and heads]` in `GHC.Tc.Gen.App` to accompany this change. Fixes #21038. - - - - - 00975981 by sheaf at 2022-02-09T03:58:53-05:00 Add test for #21037 This program was rejected by GHC 9.2, but is accepted on newer versions of GHC. This patch adds a regression test. Closes #21037 - - - - - fad0b2b0 by Ben Gamari at 2022-02-09T08:29:46-05:00 Rename -merge-objs flag to --merge-objs For consistency with --make and friends. - - - - - 1dbe5b2a by Matthew Pickering at 2022-02-09T08:30:22-05:00 driver: Filter out our own boot module in hptSomeThingsBelow hptSomeThingsBelow would return a list of modules which contain the .hs-boot file for a particular module. This caused some problems because we would try and find the module in the HPT (but it's not there when we're compiling the module itself). Fixes #21058 - - - - - 2b1cced1 by Sylvain Henry at 2022-02-09T20:42:23-05:00 NCG: minor code factorization - - - - - e01ffec2 by Sylvain Henry at 2022-02-09T20:42:23-05:00 ByteCode: avoid out-of-bound read Cf https://gitlab.haskell.org/ghc/ghc/-/issues/18431#note_287139 - - - - - 53c26e79 by Ziyang Liu at 2022-02-09T20:43:02-05:00 Include ru_name in toHsRule message See #18147 - - - - - 3df06922 by Ben Gamari at 2022-02-09T20:43:39-05:00 rts: Rename MemoryMap.[ch] -> ReportMemoryMap.[ch] - - - - - e219ac82 by Ben Gamari at 2022-02-09T20:43:39-05:00 rts: Move mmapForLinker and friends to linker/MMap.c They are not particularly related to linking. - - - - - 30e205ca by Ben Gamari at 2022-02-09T20:43:39-05:00 rts/linker: Drop dead IA64 code - - - - - 4d3a306d by Ben Gamari at 2022-02-09T20:43:39-05:00 rts/linker/MMap: Use MemoryAccess in mmapForLinker - - - - - 1db4f1fe by Ben Gamari at 2022-02-09T20:43:39-05:00 linker: Don't use MAP_FIXED As noted in #21057, we really shouldn't be using MAP_FIXED. I would much rather have the process crash with a "failed to map" error than randomly overwrite existing mappings. Closes #21057. - - - - - 1eeae25c by Ben Gamari at 2022-02-09T20:43:39-05:00 rts/mmap: Refactor mmapForLinker Here we try to separate the policy decisions of where to place mappings from the mechanism of creating the mappings. This makes things significantly easier to follow. - - - - - ac2d18a7 by sheaf at 2022-02-09T20:44:18-05:00 Add some perf tests for coercions This patch adds some performance tests for programs that create large coercions. This is useful because the existing test coverage is not very representative of real-world situations. In particular, this adds a test involving an extensible records library, a common pain-point for users. - - - - - 48f25715 by Andreas Klebinger at 2022-02-10T04:35:35-05:00 Add late cost centre support This allows cost centres to be inserted after the core optimization pipeline has run. - - - - - 0ff70427 by Andreas Klebinger at 2022-02-10T04:36:11-05:00 Docs:Mention that safe calls don't keep their arguments alive. - - - - - 1d3ed168 by Ben Gamari at 2022-02-10T04:36:46-05:00 PEi386: Drop Windows Vista fallback in addLibrarySearchPath We no longer support Windows Vista. - - - - - 2a6f2681 by Ben Gamari at 2022-02-10T04:36:46-05:00 linker/PEi386: Make addLibrarySearchPath long-path aware Previously `addLibrarySearchPath` failed to normalise the added path to UNC form before passing it to `AddDllDirectory`. Consequently, the call was subject to the MAX_PATH restriction, leading to the failure of `test-defaulting-plugin-fail`, among others. Happily, this also nicely simplifies the implementation. Closes #21059. - - - - - 2a47ee9c by Daniel Gröber at 2022-02-10T19:18:58-05:00 ghc-boot: Simplify writePackageDb permissions handling Commit ef8a3fbf1 ("ghc-boot: Fix metadata handling of writeFileAtomic") introduced a somewhat over-engineered fix for #14017 by trying to preserve the current permissions if the target file already exists. The problem in the issue is simply that the package db cache file should be world readable but isn't if umask is too restrictive. In fact the previous fix only handles part of this problem. If the file isn't already there in a readable configuration it wont make it so which isn't really ideal either. Rather than all that we now simply always force all the read access bits to allow access while leaving the owner at the system default as it's just not our business to mess with it. - - - - - a1d97968 by Ben Gamari at 2022-02-10T19:19:34-05:00 Bump Cabal submodule Adapts GHC to the factoring-out of `Cabal-syntax`. Fixes #20991. Metric Decrease: haddock.Cabal - - - - - 89cf8caa by Morrow at 2022-02-10T19:20:13-05:00 Add metadata to integer-gmp.cabal - - - - - c995b7e7 by Matthew Pickering at 2022-02-10T19:20:48-05:00 eventlog: Fix event type of EVENT_IPE This leads to corrupted eventlogs because the size of EVENT_IPE is completely wrong. Fixes a bug introduced in 2e29edb7421c21902b47d130d45f60d3f584a0de - - - - - 59ba8fb3 by Matthew Pickering at 2022-02-10T19:20:48-05:00 eventlog: Fix event type of MEM_RETURN This leads to corrupted eventlogs because the size of EVENT_MEM_RETURN is completely wrong. Fixes a bug introduced in 2e29edb7421c21902b47d130d45f60d3f584a0de - - - - - 19413d09 by Matthew Pickering at 2022-02-10T19:20:48-05:00 eventlog: Delete misleading comment in gen_event_types.py Not all events start with CapNo and there's not logic I could see which adds this to the length. - - - - - e06f49c0 by Matthew Pickering at 2022-02-10T19:20:48-05:00 eventlog: Fix size of TICKY_COUNTER_BEGIN_SAMPLE - - - - - 2f99255b by Matthew Pickering at 2022-02-10T19:21:24-05:00 Fix copy-pasto in prof-late-ccs docs - - - - - 19deb002 by Matthew Pickering at 2022-02-10T19:21:59-05:00 Refine tcSemigroupWarnings to work in ghc-prim ghc-prim doesn't depend on base so can't have any Monoid or Semigroup instances. However, attempting to load these definitions ran into issues when the interface for `GHC.Base` did exist as that would try and load the interface for `GHC.Types` (which is the module we are trying to compile and has no interface). The fix is to just not do this check when we are compiling a module in ghc-prim. Fixes #21069 - - - - - 34dec6b7 by sheaf at 2022-02-11T17:55:34-05:00 Decrease the size of the LargeRecord test This test was taking too long to run, so this patch makes it smaller. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 9cab90d9 by Matthew Pickering at 2022-02-11T22:27:19-05:00 Make sure all platforms have a release job The release bindists are currently a mixture of validate and release builds. This is bad because the validate builds don't have profiling libraries. The fix is to make sure there is a release job for each platform we want to produce a release for.t Fixes #21066 - - - - - 4bce3575 by Matthew Pickering at 2022-02-11T22:27:54-05:00 testsuite: Make sure all tests trigger ghc rebuild I made a mistake when implementing #21029 which meant that certain tests didn't trigger a GHC recompilation. By adding the `test:ghc` target to the default settings all tests will now depend on this target unless explicitly opting out via the no_deps modifier. - - - - - 90a26f8b by Sylvain Henry at 2022-02-11T22:28:34-05:00 Fix documentation about Word64Rep/Int64Rep (#16964) - - - - - 0e93023e by Andreas Klebinger at 2022-02-12T13:59:41+00:00 Tag inference work. This does three major things: * Enforce the invariant that all strict fields must contain tagged pointers. * Try to predict the tag on bindings in order to omit tag checks. * Allows functions to pass arguments unlifted (call-by-value). The former is "simply" achieved by wrapping any constructor allocations with a case which will evaluate the respective strict bindings. The prediction is done by a new data flow analysis based on the STG representation of a program. This also helps us to avoid generating redudant cases for the above invariant. StrictWorkers are created by W/W directly and SpecConstr indirectly. See the Note [Strict Worker Ids] Other minor changes: * Add StgUtil module containing a few functions needed by, but not specific to the tag analysis. ------------------------- Metric Decrease: T12545 T18698b T18140 T18923 LargeRecord Metric Increase: LargeRecord ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13253-spj T13379 T15164 T18282 T18304 T18698a T1969 T20049 T3294 T4801 T5321FD T5321Fun T783 T9233 T9675 T9961 T19695 WWRec ------------------------- - - - - - 744f8a11 by Greg Steuck at 2022-02-12T17:13:55-05:00 Only check the exit code in derefnull & divbyzero tests on OpenBSD - - - - - eeead9fc by Ben Gamari at 2022-02-13T03:26:14-05:00 rts/Adjustor: Ensure that allocateExecPage succeeded Previously we failed to handle the case that `allocateExecPage` failed. - - - - - afdfaff0 by Ben Gamari at 2022-02-13T03:26:14-05:00 rts: Drop DEC Alpha adjustor implementation The last Alpha chip was produced in 2004. - - - - - 191dfd2d by Ben Gamari at 2022-02-13T03:26:14-05:00 rts/adjustor: Split Windows path out of NativeAmd64 - - - - - be591e27 by Ben Gamari at 2022-02-13T03:26:14-05:00 rts: Initial commit of AdjustorPool - - - - - d6d48b16 by Ben Gamari at 2022-02-13T03:26:14-05:00 Introduce initAdjustors - - - - - eab37902 by Ben Gamari at 2022-02-13T03:26:14-05:00 adjustors/NativeAmd64: Use AdjustorPool - - - - - 974e73af by Ben Gamari at 2022-02-13T03:26:14-05:00 adjustors/NativeAmd64Mingw: Use AdjustorPool - - - - - 95fab83f by Ben Gamari at 2022-02-13T03:26:14-05:00 configure: Fix result reporting of adjustors method check - - - - - ef5cf55d by nikshalark at 2022-02-13T03:26:16-05:00 (#21044) Documented arithmetic functions in base. Didn't get it right the ninth time. Now everything's formatted correctly. - - - - - acb482cc by Takenobu Tani at 2022-02-16T05:27:17-05:00 Relax load_load_barrier for aarch64 This patch relaxes the instruction for load_load_barrier(). Current load_load_barrier() implements full-barrier with `dmb sy`. It's too strong to order load-load instructions. We can relax it by using `dmb ld`. If current load_load_barrier() is used for full-barriers (load/store - load/store barrier), this patch is not suitable. See also linux-kernel's smp_rmb() implementation: https://github.com/torvalds/linux/blob/v5.14/arch/arm64/include/asm/barrier.h#L90 Hopefully, it's better to use `dmb ishld` rather than `dmb ld` to improve performance. However, I can't validate effects on a real many-core Arm machine. - - - - - 84eaa26f by Oleg Grenrus at 2022-02-16T05:27:56-05:00 Add test for #20562 - - - - - 2c28620d by Adam Sandberg Ericsson at 2022-02-16T05:28:32-05:00 rts: remove struct StgRetry, it is never used - - - - - 74bf9bb5 by Adam Sandberg Ericsson at 2022-02-16T05:28:32-05:00 rts: document some closure types - - - - - 316312ec by nineonine at 2022-02-16T05:29:08-05:00 ghci: fix -ddump-stg-cg (#21052) The pre-codegen Stg AST dump was not available in ghci because it was performed in 'doCodeGen'. This was now moved to 'coreToStg' area. - - - - - a6411d74 by Adam Sandberg Ericsson at 2022-02-16T05:29:43-05:00 docs: mention -fprof-late-ccs in the release notes And note which compiler version it was added in. - - - - - 4127e86d by Adam Sandberg Ericsson at 2022-02-16T05:29:43-05:00 docs: fix release notes formatting - - - - - 4e6c8019 by Matthew Pickering at 2022-02-17T05:25:28-05:00 Always define __GLASGOW_HASKELL_PATCHLEVEL1/2__ macros As #21076 reports if you are using `-Wcpp-undef` then you get warnings when using the `MIN_VERSION_GLASGOW_HASKELL` macro because __GLASGOW_HASKELL_PATCHLEVEL2__ is very rarely explicitliy set (as version numbers are not 4 components long). This macro was introduced in 3549c952b535803270872adaf87262f2df0295a4 and it seems the bug has existed ever since. Fixes #21076 - - - - - 67dd5724 by Ben Gamari at 2022-02-17T05:26:03-05:00 rts/AdjustorPool: Silence unused function warning bitmap_get is only used in the DEBUG RTS configuration. Fixes #21079. - - - - - 4b04f7e1 by Zubin Duggal at 2022-02-20T13:56:15-05:00 Track object file dependencies for TH accurately (#20604) `hscCompileCoreExprHook` is changed to return a list of `Module`s required by a splice. These modules are accumulated in the TcGblEnv (tcg_th_needed_mods). Dependencies on the object files of these modules are recording in the interface. The data structures in `LoaderState` are replaced with more efficient versions to keep track of all the information required. The MultiLayerModulesTH_Make allocations increase slightly but runtime is faster. Fixes #20604 ------------------------- Metric Increase: MultiLayerModulesTH_Make ------------------------- - - - - - 92ab3ff2 by sheaf at 2022-02-20T13:56:55-05:00 Use diagnostics for "missing signature" errors This patch makes the "missing signature" errors from "GHC.Rename.Names" use the diagnostic infrastructure. This encompasses missing type signatures for top-level bindings and pattern synonyms, as well as missing kind signatures for type constructors. This patch also renames TcReportMsg to TcSolverReportMsg, and adds a few convenience functions to compute whether such a TcSolverReportMsg is an expected/actual message. - - - - - 845284a5 by sheaf at 2022-02-20T13:57:34-05:00 Generically: remove redundant Semigroup constraint This patch removes a redundant Semigroup constraint on the Monoid instance for Generically. This constraint can cause trouble when one wants to derive a Monoid instance via Generically through a type that doesn't itself have a Semigroup instance, for example: data Point2D a = Point2D !a !a newtype Vector2D a = Vector2D { tip :: Point2D a } deriving ( Semigroup, Monoid ) via Generically ( Point2D ( Sum a ) ) In this case, we should not require there to be an instance Semigroup ( Point2D ( Sum a ) ) as all we need is an instance for the generic representation of Point2D ( Sum a ), i.e. Semigroup ( Rep ( Point2D ( Sum a) ) () ). - - - - - 6b468f7f by Ben Gamari at 2022-02-20T13:58:10-05:00 Bump time submodule to 1.12.1 - - - - - 2f0ceecc by Zubin Duggal at 2022-02-20T19:06:19+00:00 hadrian: detect if 'main' is not a haskell file and add it to appropriate list of sources - - - - - 7ce1b694 by Zubin Duggal at 2022-02-21T11:18:58+00:00 Reinstallable GHC This patch allows ghc and its dependencies to be built using a normal invocation of cabal-install. Each componenent which relied on generated files or additional configuration now has a Setup.hs file. There are also various fixes to the cabal files to satisfy cabal-install. There is a new hadrian command which will build a stage2 compiler and then a stage3 compiler by using cabal. ``` ./hadrian/build build-cabal ``` There is also a new CI job which tests running this command. For the 9.4 release we will upload all the dependent executables to hackage and then end users will be free to build GHC and GHC executables via cabal. There are still some unresolved questions about how to ensure soundness when loading plugins into a reinstalled GHC (#20742) which will be tighted up in due course. Fixes #19896 - - - - - 78fbc3a3 by Matthew Pickering at 2022-02-21T15:14:28-05:00 hadrian: Enable late-ccs when building profiled_ghc - - - - - 2b890c89 by Matthew Pickering at 2022-02-22T15:59:33-05:00 testsuite: Don't print names of all fragile tests on all runs This information about fragile tests is pretty useless but annoying on CI where you have to scroll up a long way to see the actual issues. - - - - - 0b36801f by sheaf at 2022-02-22T16:00:14-05:00 Forbid standalone instances for built-in classes `check_special_inst_head` includes logic that disallows hand-written instances for built-in classes such as Typeable, KnownNat and KnownSymbol. However, it also allowed standalone deriving declarations. This was because we do want to allow standalone deriving instances with Typeable as they are harmless, but we certainly don't want to allow instances for e.g. KnownNat. This patch ensures that we don't allow derived instances for KnownNat, KnownSymbol (and also KnownChar, which was previously omitted entirely). Fixes #21087 - - - - - ace66dec by Krzysztof Gogolewski at 2022-02-22T16:30:59-05:00 Remove -Wunticked-promoted-constructors from -Wall Update manual; explain ticks as optional disambiguation rather than the preferred default. This is a part of #20531. - - - - - 558c7d55 by Hugo at 2022-02-22T16:31:01-05:00 docs: fix error in annotation guide code snippet - - - - - a599abba by Richard Eisenberg at 2022-02-23T08:16:07-05:00 Kill derived constraints Co-authored by: Sam Derbyshire Previously, GHC had three flavours of constraint: Wanted, Given, and Derived. This removes Derived constraints. Though serving a number of purposes, the most important role of Derived constraints was to enable better error messages. This job has been taken over by the new RewriterSets, as explained in Note [Wanteds rewrite wanteds] in GHC.Tc.Types.Constraint. Other knock-on effects: - Various new Notes as I learned about under-described bits of GHC - A reshuffling around the AST for implicit-parameter bindings, with better integration with TTG. - Various improvements around fundeps. These were caused by the fact that, previously, fundep constraints were all Derived, and Derived constraints would get dropped. Thus, an unsolved Derived didn't stop compilation. Without Derived, this is no longer possible, and so we have to be considerably more careful around fundeps. - A nice little refactoring in GHC.Tc.Errors to center the work on a new datatype called ErrorItem. Constraints are converted into ErrorItems at the start of processing, and this allows for a little preprocessing before the main classification. - This commit also cleans up the behavior in generalisation around functional dependencies. Now, if a variable is determined by functional dependencies, it will not be quantified. This change is user facing, but it should trim down GHC's strange behavior around fundeps. - Previously, reportWanteds did quite a bit of work, even on an empty WantedConstraints. This commit adds a fast path. - Now, GHC will unconditionally re-simplify constraints during quantification. See Note [Unconditionally resimplify constraints when quantifying], in GHC.Tc.Solver. Close #18398. Close #18406. Solve the fundep-related non-confluence in #18851. Close #19131. Close #19137. Close #20922. Close #20668. Close #19665. ------------------------- Metric Decrease: LargeRecord T9872b T9872b_defer T9872d TcPlugin_RewritePerf ------------------------- - - - - - 2ed22ba1 by Matthew Pickering at 2022-02-23T08:16:43-05:00 Introduce predicate for when to enable source notes (needSourceNotes) There were situations where we were using debugLevel == 0 as a proxy for whether to retain source notes but -finfo-table-map also enables and needs source notes so we should act consistently in both cases. Ticket #20847 - - - - - 37deb893 by Matthew Pickering at 2022-02-23T08:16:43-05:00 Use SrcSpan from the binder as initial source estimate There are some situations where we end up with no source notes in useful positions in an expression. In this case we currently fail to provide any source information about where an expression came from. This patch improves the initial estimate by using the position from the top-binder as the guess for the location of the whole inner expression. It provides quite a course estimate but it's better than nothing. Ticket #20847 - - - - - 59b7f764 by Cheng Shao at 2022-02-23T08:17:24-05:00 Don't emit foreign exports initialiser code for empty CAF list - - - - - c7f32f76 by John Ericson at 2022-02-23T13:58:36-05:00 Prepare rechecking logic for new type in a few ways Combine `MustCompile and `NeedsCompile` into a single case. `CompileReason` is put inside to destinguish the two. This makes a number of things easier. `Semigroup RecompileRequired` is no longer used, to make sure we skip doing work where possible. `recompThen` is very similar, but helps remember. `checkList` is rewritten with `recompThen`. - - - - - e60d8df8 by John Ericson at 2022-02-23T13:58:36-05:00 Introduce `MaybeValidated` type to remove invalid states The old return type `(RecompRequired, Maybe _)`, was confusing because it was inhabited by values like `(UpToDate, Nothing)` that made no sense. The new type ensures: - you must provide a value if it is up to date. - you must provide a reason if you don't provide a value. it is used as the return value of: - `checkOldIface` - `checkByteCode` - `checkObjects` - - - - - f07b13e3 by Sylvain Henry at 2022-02-23T13:59:23-05:00 NCG: refactor X86 codegen Preliminary work done to make working on #5444 easier. Mostly make make control-flow easier to follow: * renamed genCCall into genForeignCall * split genForeignCall into the part dispatching on PrimTarget (genPrim) and the one really generating code for a C call (cf ForeignTarget and genCCall) * made genPrim/genSimplePrim only dispatch on MachOp: each MachOp now has its own code generation function. * out-of-line primops are not handled in a partial `outOfLineCmmOp` anymore but in the code generation functions directly. Helper functions have been introduced (e.g. genLibCCall) for code sharing. * the latter two bullets make code generated for primops that are only sometimes out-of-line (e.g. Pdep or Memcpy) and the logic to select between inline/out-of-line much more localized * avoided passing is32bit as an argument as we can easily get it from NatM state when we really need it * changed genCCall type to avoid it being partial (it can't handle PrimTarget) * globally removed 12 calls to `panic` thanks to better control flow and types ("parse, don't validate" ftw!). - - - - - 6fa7591e by Sylvain Henry at 2022-02-23T13:59:23-05:00 NCG: refactor the way registers are handled * add getLocalRegReg to avoid allocating a CmmLocal just to call getRegisterReg * 64-bit registers: in the general case we must always use the virtual higher part of the register, so we might as well always return it with the lower part. The only exception is to implement 64-bit to 32-bit conversions. We now have to explicitly discard the higher part when matching on Reg64/RegCode64 datatypes instead of explicitly fetching the higher part from the lower part: much safer default. - - - - - bc8de322 by Sylvain Henry at 2022-02-23T13:59:23-05:00 NCG: inline some 64-bit primops on x86/32-bit (#5444) Several 64-bit operation were implemented with FFI calls on 32-bit architectures but we can easily implement them with inline assembly code. Also remove unused hs_int64ToWord64 and hs_word64ToInt64 C functions. - - - - - 7b7c6b95 by Matthew Pickering at 2022-02-23T14:00:00-05:00 Simplify/correct implementation of getModuleInfo - - - - - 6215b04c by Matthew Pickering at 2022-02-23T14:00:00-05:00 Remove mg_boot field from ModuleGraph It was unused in the compiler so I have removed it to streamline ModuleGraph. - - - - - 818ff2ef by Matthew Pickering at 2022-02-23T14:00:01-05:00 driver: Remove needsTemplateHaskellOrQQ from ModuleGraph The idea of the needsTemplateHaskellOrQQ query is to check if any of the modules in a module graph need Template Haskell then enable -dynamic-too if necessary. This is quite imprecise though as it will enable -dynamic-too for all modules in the module graph even if only one module uses template haskell, with multiple home units, this is obviously even worse. With -fno-code we already have similar logic to enable code generation just for the modules which are dependeded on my TemplateHaskell modules so we use the same code path to decide whether to enable -dynamic-too rather than using this big hammer. This is part of the larger overall goal of moving as much statically known configuration into the downsweep as possible in order to have fully decided the build plan and all the options before starting to build anything. I also included a fix to #21095, a long standing bug with with the logic which is supposed to enable the external interpreter if we don't have the internal interpreter. Fixes #20696 #21095 - - - - - b6670af6 by Matthew Pickering at 2022-02-23T14:00:40-05:00 testsuite: Normalise output of ghci011 and T7627 The outputs of these tests vary on the order interface files are loaded so we normalise the output to correct for these inconsequential differences. Fixes #21121 - - - - - 9ed3bc6e by Peter Trommler at 2022-02-23T14:01:16-05:00 testsuite: Fix ipeMap test Pointers to closures must be untagged before use. Produce closures of different types so we get different info tables. Fixes #21112 - - - - - 7d426148 by Ziyang Liu at 2022-02-24T04:53:34-05:00 Allow `return` in more cases in ApplicativeDo The doc says that the last statement of an ado-block can be one of `return E`, `return $ E`, `pure E` and `pure $ E`. But `return` is not accepted in a few cases such as: ```haskell -- The ado-block only has one statement x :: F () x = do return () -- The ado-block only has let-statements besides the `return` y :: F () y = do let a = True return () ``` These currently require `Monad` instances. This MR fixes it. Normally `return` is accepted as the last statement because it is stripped in constructing an `ApplicativeStmt`, but this cannot be done in the above cases, so instead we replace `return` by `pure`. A similar but different issue (when the ado-block contains `BindStmt` or `BodyStmt`, the second last statement cannot be `LetStmt`, even if the last statement uses `pure`) is fixed in !6786. - - - - - a5ea7867 by John Ericson at 2022-02-24T20:23:49-05:00 Clarify laws of TestEquality It is unclear what `TestEquality` is for. There are 3 possible choices. Assuming ```haskell data Tag a where TagInt1 :: Tag Int TagInt2 :: Tag Int ``` Weakest -- type param equality semi-decidable --------------------------------------------- `Just Refl` merely means the type params are equal, the values being compared might not be. `Nothing` means the type params may or may not be not equal. ```haskell instance TestEquality Tag where testEquality TagInt1 TagInt1 = Nothing -- oopsie is allowed testEquality TagInt1 TagInt2 = Just Refl testEquality TagInt2 TagInt1 = Just Refl testEquality TagInt2 TagInt2 = Just Refl ``` This option is better demonstrated with a different type: ```haskell data Tag' a where TagInt1 :: Tag Int TagInt2 :: Tag a ``` ```haskell instance TestEquality Tag' where testEquality TagInt1 TagInt1 = Just Refl testEquality TagInt1 TagInt2 = Nothing -- can't be sure testEquality TagInt2 TagInt1 = Nothing -- can't be sure testEquality TagInt2 TagInt2 = Nothing -- can't be sure ``` Weaker -- type param equality decidable --------------------------------------- `Just Refl` merely means the type params are equal, the values being compared might not be. `Nothing` means the type params are not equal. ```haskell instance TestEquality Tag where testEquality TagInt1 TagInt1 = Just Refl testEquality TagInt1 TagInt2 = Just Refl testEquality TagInt2 TagInt1 = Just Refl testEquality TagInt2 TagInt2 = Just Refl ``` Strong -- Like `Eq` ------------------- `Just Refl` means the type params are equal, and the values are equal according to `Eq`. ```haskell instance TestEquality Tag where testEquality TagInt1 TagInt1 = Just Refl testEquality TagInt2 TagInt2 = Just Refl testEquality _ _ = Nothing ``` Strongest -- unique value concrete type --------------------------------------- `Just Refl` means the type params are equal, and the values are equal, and the class assume if the type params are equal the values must also be equal. In other words, the type is a singleton type when the type parameter is a closed term. ```haskell -- instance TestEquality -- invalid instance because two variants for `Int` ``` ------ The discussion in https://github.com/haskell/core-libraries-committee/issues/21 has decided on the "Weaker" option (confusingly formerly called the "Weakest" option). So that is what is implemented. - - - - - 06c18990 by Zubin Duggal at 2022-02-24T20:24:25-05:00 TH: fix pretty printing of GADTs with multiple constuctors (#20842) - - - - - 6555b68c by Matthew Pickering at 2022-02-24T20:25:06-05:00 Move linters into the tree This MR moves the GHC linters into the tree, so that they can be run directly using Hadrian. * Query all files tracked by Git instead of using changed files, so that we can run the exact same linting step locally and in a merge request. * Only check that the changelogs don't contain TBA when RELEASE=YES. * Add hadrian/lint script, which runs all the linting steps. * Ensure the hlint job exits with a failure if hlint is not installed (otherwise we were ignoring the failure). Given that hlint doesn't seem to be available in CI at the moment, I've temporarily allowed failure in the hlint job. * Run all linting tests in CI using hadrian. - - - - - b99646ed by Matthew Pickering at 2022-02-24T20:25:06-05:00 Add rule for generating HsBaseConfig.h If you are running the `lint:{base/compiler}` command locally then this improves the responsiveness because we don't re-run configure everytime if the header file already exists. - - - - - d0deaaf4 by Matthew Pickering at 2022-02-24T20:25:06-05:00 Suggestions due to hlint It turns out this job hasn't been running for quite a while (perhaps ever) so there are quite a few failures when running the linter locally. - - - - - 70bafefb by nineonine at 2022-02-24T20:25:42-05:00 ghci: show helpful error message when loading module with SIMD vector operations (#20214) Previously, when trying to load module with SIMD vector operations, ghci would panic in 'GHC.StgToByteCode.findPushSeq'. Now, a more helpful message is displayed. - - - - - 8ed3d5fd by Matthew Pickering at 2022-02-25T10:24:12+00:00 Remove test-bootstrap and cabal-reinstall jobs from fast-ci [skip ci] - - - - - 8387dfbe by Mario Blažević at 2022-02-25T21:09:41-05:00 template-haskell: Fix two prettyprinter issues Fix two issues regarding printing numeric literals. Fixing #20454. - - - - - 4ad8ce0b by sheaf at 2022-02-25T21:10:22-05:00 GHCi: don't normalise partially instantiated types This patch skips performing type normalisation when we haven't fully instantiated the type. That is, in tcRnExpr (used only for :type in GHCi), skip normalisation if the result type responds True to isSigmaTy. Fixes #20974 - - - - - f35aca4d by Ben Gamari at 2022-02-25T21:10:57-05:00 rts/adjustor: Always place adjustor templates in data section @nrnrnr points out that on his machine ld.lld rejects text relocations. Generalize the Darwin text-relocation avoidance logic to account for this. - - - - - cddb040a by Andreas Klebinger at 2022-02-25T21:11:33-05:00 Ticky: Gate tag-inference dummy ticky-counters behind a flag. Tag inference included a way to collect stats about avoided tag-checks. This was dony by emitting "dummy" ticky entries with counts corresponding to predicted/unpredicated tag checks. This behaviour for ticky is now gated behind -fticky-tag-checks. I also documented ticky-LNE in the process. - - - - - 948bf2d0 by Ben Gamari at 2022-02-25T21:12:09-05:00 Fix comment reference to T4818 - - - - - 9c3edeb8 by Ben Gamari at 2022-02-25T21:12:09-05:00 simplCore: Correctly extend in-scope set in rule matching Note [Matching lets] in GHC.Core.Rules claims the following: > We use GHC.Core.Subst.substBind to freshen the binding, using an > in-scope set that is the original in-scope variables plus the > rs_bndrs (currently floated let-bindings). However, previously the implementation didn't actually do extend the in-scope set with rs_bndrs. This appears to be a regression which was introduced by 4ff4d434e9a90623afce00b43e2a5a1ccbdb4c05. Moreover, the originally reasoning was subtly wrong: we must rather use the in-scope set from rv_lcl, extended with rs_bndrs, not that of `rv_fltR` Fixes #21122. - - - - - 7f9f49c3 by sheaf at 2022-02-25T21:12:47-05:00 Derive some stock instances for OverridingBool This patch adds some derived instances to `GHC.Data.Bool.OverridingBool`. It also changes the order of the constructors, so that the derived `Ord` instance matches the behaviour for `Maybe Bool`. Fixes #20326 - - - - - 140438a8 by nineonine at 2022-02-25T21:13:23-05:00 Add test for #19271 - - - - - ac9f4606 by sheaf at 2022-02-25T21:14:04-05:00 Allow qualified names in COMPLETE pragmas The parser didn't allow qualified constructor names to appear in COMPLETE pragmas. This patch fixes that. Fixes #20551 - - - - - 677c6c91 by Sylvain Henry at 2022-02-25T21:14:44-05:00 Testsuite: remove arch conditional in T8832 Taken from !3658 - - - - - ad04953b by Sylvain Henry at 2022-02-25T21:15:23-05:00 Allow hscGenHardCode to not return CgInfos This is a minor change in preparation for the JS backend: CgInfos aren't mandatory and the JS backend won't return them. - - - - - 929c280f by Sylvain Henry at 2022-02-25T21:15:24-05:00 Derive Enum instances for CCallConv and Safety This is used by the JS backend for serialization. - - - - - 75e4e090 by Sebastian Graf at 2022-02-25T21:15:59-05:00 base: Improve documentation of `throwIO` (#19854) Now it takes a better account of precise vs. imprecise exception semantics. Fixes #19854. - - - - - 61a203ba by Matthew Pickering at 2022-02-26T02:06:51-05:00 Make typechecking unfoldings from interfaces lazier The old logic was unecessarily strict in loading unfoldings because when reading the unfolding we would case on the result of attempting to load the template before commiting to which type of unfolding we were producing. Hence trying to inspect any of the information about an unfolding would force the template to be loaded. This also removes a potentially hard to discover bug where if the template failed to be typechecked for some reason then we would just not return an unfolding. Instead we now panic so these bad situations which should never arise can be identified. - - - - - 2be74460 by Matthew Pickering at 2022-02-26T02:06:51-05:00 Use a more up-to-date snapshot of the current rules in the simplifier As the prescient (now deleted) note warns in simplifyPgmIO we have to be a bit careful about when we gather rules from the EPS so that we get the rules for imported bindings. ``` -- Get any new rules, and extend the rule base -- See Note [Overall plumbing for rules] in GHC.Core.Rules -- We need to do this regularly, because simplification can -- poke on IdInfo thunks, which in turn brings in new rules -- behind the scenes. Otherwise there's a danger we'll simply -- miss the rules for Ids hidden inside imported inlinings ``` Given the previous commit, the loading of unfoldings is now even more delayed so we need to be more careful to read the EPS rule base closer to the point where we decide to try rules. Without this fix GHC performance regressed by a noticeably amount because the `zip` rule was not brought into scope eagerly enough which led to a further series of unfortunate events in the simplifer which tipped `substTyWithCoVars` over the edge of the size threshold, stopped it being inlined and increased allocations by 10% in some cases. Furthermore, this change is noticeably in the testsuite as it changes T19790 so that the `length` rules from GHC.List fires earlier. ------------------------- Metric Increase: T9961 ------------------------- - - - - - b8046195 by Matthew Pickering at 2022-02-26T02:06:52-05:00 Improve efficiency of extending a RuleEnv with a new RuleBase Essentially we apply the identity: > lookupNameEnv n (plusNameEnv_C (++) rb1 rb2) > = lookupNameEnv n rb1 ++ lookupNameEnv n rb2 The latter being more efficient as we don't construct an intermediate map. This is now quite important as each time we try and apply rules we need to combine the current EPS RuleBase with the HPT and ModGuts rule bases. - - - - - 033e9f0f by sheaf at 2022-02-26T02:07:30-05:00 Error on anon wildcards in tcAnonWildCardOcc The code in tcAnonWildCardOcc assumed that it could never encounter anonymous wildcards in illegal positions, because the renamer would have ruled them out. However, it's possible to sneak past the checks in the renamer by using Template Haskell. It isn't possible to simply pass on additional information when renaming Template Haskell brackets, because we don't know in advance in what context the bracket will be spliced in (see test case T15433b). So we accept that we might encounter these bogus wildcards in the typechecker and throw the appropriate error. This patch also migrates the error messages for illegal wildcards in types to use the diagnostic infrastructure. Fixes #15433 - - - - - 32d8fe3a by sheaf at 2022-02-26T14:15:33+01:00 Core Lint: ensure primops can be eta-expanded This patch adds a check to Core Lint, checkCanEtaExpand, which ensures that primops and other wired-in functions with no binding such as unsafeCoerce#, oneShot, rightSection... can always be eta-expanded, by checking that the remaining argument types have a fixed RuntimeRep. Two subtleties came up: - the notion of arity in Core looks through newtypes, so we may need to unwrap newtypes in this check, - we want to avoid calling hasNoBinding on something whose unfolding we are in the process of linting, as this would cause a loop; to avoid this we add some information to the Core Lint environment that holds this information. Fixes #20480 - - - - - 0a80b436 by Peter Trommler at 2022-02-26T17:21:59-05:00 testsuite: Require LLVM for T15155l - - - - - 38cb920e by Oleg Grenrus at 2022-02-28T07:14:04-05:00 Add Monoid a => Monoid (STM a) instance - - - - - d734ef8f by Hécate Moonlight at 2022-02-28T07:14:42-05:00 Make modules in base stable. fix #18963 - - - - - fbf005e9 by Sven Tennie at 2022-02-28T19:16:01-05:00 Fix some hlint issues in ghc-heap This does not fix all hlint issues as the criticised index and length expressions seem to be fine in context. - - - - - adfddf7d by Matthew Pickering at 2022-02-28T19:16:36-05:00 hadrian: Suggest to the user to run ./configure if missing a setting If a setting is missing from the configuration file it's likely the user needs to reconfigure. Fixes #20476 - - - - - 4f0208e5 by Andreas Klebinger at 2022-02-28T19:17:12-05:00 CLabel cleanup: Remove these smart constructors for these reasons: * mkLocalClosureTableLabel : Does the same as the non-local variant. * mkLocalClosureLabel : Does the same as the non-local variant. * mkLocalInfoTableLabel : Decide if we make a local label based on the name and just use mkInfoTableLabel everywhere. - - - - - 065419af by Matthew Pickering at 2022-02-28T19:17:47-05:00 linking: Don't pass --hash-size and --reduce-memory-overhead to ld These flags were added to help with the high linking cost of the old split-objs mode. Now we are using split-sections these flags appear to make no difference to memory usage or time taken to link. I tested various configurations linking together the ghc library with -split-sections enabled. | linker | time (s) | | ------ | ------ | | gold | 0.95 | | ld | 1.6 | | ld (hash-size = 31, reduce-memory-overheads) | 1.6 | | ldd | 0.47 | Fixes #20967 - - - - - 3e65ef05 by Teo Camarasu at 2022-02-28T19:18:27-05:00 template-haskell: fix typo in docstring for Overlap - - - - - 80f9133e by Teo Camarasu at 2022-02-28T19:18:27-05:00 template-haskell: fix docstring for Bytes It seems like a commented out section of code was accidentally included in the docstring for a field. - - - - - 54774268 by Matthew Pickering at 2022-03-01T16:23:10-05:00 Fix longstanding issue with moduleGraphNodes - no hs-boot files case In the case when we tell moduleGraphNodes to drop hs-boot files the idea is to collapse hs-boot files into their hs file nodes. In the old code * nodeDependencies changed edges from IsBoot to NonBoot * moduleGraphNodes just dropped boot file nodes The net result is that any dependencies of the hs-boot files themselves were dropped. The correct thing to do is * nodeDependencies changes edges from IsBoot to NonBoot * moduleGraphNodes merges dependencies of IsBoot and NonBoot nodes. The result is a properly quotiented dependency graph which contains no hs-boot files nor hs-boot file edges. Why this didn't cause endless issues when compiling with boot files, we will never know. - - - - - c84dc506 by Matthew Pickering at 2022-03-01T16:23:10-05:00 driver: Properly add an edge between a .hs and its hs-boot file As noted in #21071 we were missing adding this edge so there were situations where the .hs file would get compiled before the .hs-boot file which leads to issues with -j. I fixed this properly by adding the edge in downsweep so the definition of nodeDependencies can be simplified to avoid adding this dummy edge in. There are plenty of tests which seem to have these redundant boot files anyway so no new test. #21094 tracks the more general issue of identifying redundant hs-boot and SOURCE imports. - - - - - 7aeb6d29 by sheaf at 2022-03-01T16:23:51-05:00 Core Lint: collect args through floatable ticks We were not looking through floatable ticks when collecting arguments in Core Lint, which caused `checkCanEtaExpand` to fail on something like: ```haskell reallyUnsafePtrEquality = \ @a -> (src<loc> reallyUnsafePtrEquality#) @Lifted @a @Lifted @a ``` We fix this by using `collectArgsTicks tickishFloatable` instead of `collectArgs`, to be consistent with the behaviour of eta expansion outlined in Note [Eta expansion and source notes] in GHC.Core.Opt.Arity. Fixes #21152. - - - - - 75caafaa by Matthew Pickering at 2022-03-02T01:14:59-05:00 Ticky profiling improvements. This adds a number of changes to ticky-ticky profiling. When an executable is profiled with IPE profiling it's now possible to associate id-related ticky counters to their source location. This works by emitting the info table address as part of the counter which can be looked up in the IPE table. Add a `-ticky-ap-thunk` flag. This flag prevents the use of some standard thunks which are precompiled into the RTS. This means reduced cache locality and increased code size. But it allows better attribution of execution cost to specific source locations instead of simple attributing it to the standard thunk. ticky-ticky now uses the `arg` field to emit additional information about counters in json format. When ticky-ticky is used in combination with the eventlog eventlog2html can be used to generate a html table from the eventlog similar to the old text output for ticky-ticky. - - - - - aeea6bd5 by doyougnu at 2022-03-02T01:15:39-05:00 StgToCmm.cgTopBinding: no isNCG, use binBlobThresh This is a one line change. It is a fixup from MR!7325, was pointed out in review of MR!7442, specifically: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7442#note_406581 The change removes isNCG check from cgTopBinding. Instead it changes the type of binBlobThresh in DynFlags from Word to Maybe Word, where a Just 0 or a Nothing indicates an infinite threshold and thus the disable CmmFileEmbed case in the original check. This improves the cohesion of the module because more NCG related Backend stuff is moved into, and checked in, StgToCmm.Config. Note, that the meaning of a Just 0 or a Nothing in binBlobThresh is indicated in a comment next to its field in GHC.StgToCmm.Config. DynFlags: binBlobThresh: Word -> Maybe Word StgToCmm.Config: binBlobThesh add not ncg check DynFlags.binBlob: move Just 0 check to dflags init StgToCmm.binBlob: only check isNCG, Just 0 check to dflags StgToCmm.Config: strictify binBlobThresh - - - - - b27b2af3 by sheaf at 2022-03-02T14:08:36-05:00 Introduce ConcreteTv metavariables This patch introduces a new kind of metavariable, by adding the constructor `ConcreteTv` to `MetaInfo`. A metavariable with `ConcreteTv` `MetaInfo`, henceforth a concrete metavariable, can only be unified with a type that is concrete (that is, a type that answers `True` to `GHC.Core.Type.isConcrete`). This solves the problem of dangling metavariables in `Concrete#` constraints: instead of emitting `Concrete# ty`, which contains a secret existential metavariable, we simply emit a primitive equality constraint `ty ~# concrete_tv` where `concrete_tv` is a fresh concrete metavariable. This means we can avoid all the complexity of canonicalising `Concrete#` constraints, as we can just re-use the existing machinery for `~#`. To finish things up, this patch then removes the `Concrete#` special predicate, and instead introduces the special predicate `IsRefl#` which enforces that a coercion is reflexive. Such a constraint is needed because the canonicaliser is quite happy to rewrite an equality constraint such as `ty ~# concrete_tv`, but such a rewriting is not handled by the rest of the compiler currently, as we need to make use of the resulting coercion, as outlined in the FixedRuntimeRep plan. The big upside of this approach (on top of simplifying the code) is that we can now selectively implement PHASE 2 of FixedRuntimeRep, by changing individual calls of `hasFixedRuntimeRep_MustBeRefl` to `hasFixedRuntimeRep` and making use of the obtained coercion. - - - - - 81b7c436 by Matthew Pickering at 2022-03-02T14:09:13-05:00 Make -dannot-lint not panic on let bound type variables After certain simplifier passes we end up with let bound type variables which are immediately inlined in the next pass. The core diff utility implemented by -dannot-lint failed to take these into account and paniced. Progress towards #20965 - - - - - f596c91a by sheaf at 2022-03-02T14:09:51-05:00 Improve out-of-order inferred type variables Don't instantiate type variables for :type in `GHC.Tc.Gen.App.tcInstFun`, to avoid inconsistently instantianting `r1` but not `r2` in the type forall {r1} (a :: TYPE r1) {r2} (b :: TYPE r2). ... This fixes #21088. This patch also changes the primop pretty-printer to ensure that we put all the inferred type variables first. For example, the type of reallyUnsafePtrEquality# is now forall {l :: Levity} {k :: Levity} (a :: TYPE (BoxedRep l)) (b :: TYPE (BoxedRep k)). a -> b -> Int# This means we avoid running into issue #21088 entirely with the types of primops. Users can still write a type signature where the inferred type variables don't come first, however. This change to primops had a knock-on consequence, revealing that we were sometimes performing eta reduction on keepAlive#. This patch updates tryEtaReduce to avoid eta reducing functions with no binding, bringing it in line with tryEtaReducePrep, and thus fixing #21090. - - - - - 1617fed3 by Richard Eisenberg at 2022-03-02T14:10:28-05:00 Make inert_cycle_breakers into a stack. Close #20231. - - - - - c8652a0a by Richard Eisenberg at 2022-03-02T14:11:03-05:00 Make Constraint not *apart* from Type. More details in Note [coreView vs tcView] Close #21092. - - - - - 91a10cb0 by doyougnu at 2022-03-02T14:11:43-05:00 GenStgAlt 3-tuple synonym --> Record type This commit alters GenStgAlt from a type synonym to a Record with field accessors. In pursuit of #21078, this is not a required change but cleans up several areas for nicer code in the upcoming js-backend, and in GHC itself. GenStgAlt: 3-tuple -> record Stg.Utils: GenStgAlt 3-tuple -> record Stg.Stats: StgAlt 3-tuple --> record Stg.InferTags.Rewrite: StgAlt 3-tuple -> record Stg.FVs: GenStgAlt 3-tuple -> record Stg.CSE: GenStgAlt 3-tuple -> record Stg.InferTags: GenStgAlt 3-tuple --> record Stg.Debug: GenStgAlt 3-tuple --> record Stg.Lift.Analysis: GenStgAlt 3-tuple --> record Stg.Lift: GenStgAlt 3-tuple --> record ByteCode.Instr: GenStgAlt 3-tuple --> record Stg.Syntax: add GenStgAlt helper functions Stg.Unarise: GenStgAlt 3-tuple --> record Stg.BcPrep: GenStgAlt 3-tuple --> record CoreToStg: GenStgAlt 3-tuple --> record StgToCmm.Expr: GenStgAlt 3-tuple --> record StgToCmm.Bind: GenStgAlt 3-tuple --> record StgToByteCode: GenStgAlt 3-tuple --> record Stg.Lint: GenStgAlt 3-tuple --> record Stg.Syntax: strictify GenStgAlt GenStgAlt: add haddock, some cleanup fixup: remove calls to pure, single ViewPattern StgToByteCode: use case over viewpatterns - - - - - 73864f00 by Matthew Pickering at 2022-03-02T14:12:19-05:00 base: Remove default method from bitraversable The default instance leads to an infinite loop. bisequenceA is defined in terms of bisquence which is defined in terms of bitraverse. ``` bitraverse f g = (defn of bitraverse) bisequenceA . bimap f g = (defn of bisequenceA) bitraverse id id . bimap f g = (defn of bitraverse) ... ``` Any instances defined without an explicitly implementation are currently broken, therefore removing it will alert users to an issue in their code. CLC issue: https://github.com/haskell/core-libraries-committee/issues/47 Fixes #20329 #18901 - - - - - 9579bf35 by Matthew Pickering at 2022-03-02T14:12:54-05:00 ci: Add check to CI to ensure compiler uses correct BIGNUM_BACKEND - - - - - c48a7c3a by Sylvain Henry at 2022-03-03T07:37:12-05:00 Use Word64# primops in Word64 Num instance Taken froù!3658 - - - - - ce65d0cc by Matthew Pickering at 2022-03-03T07:37:48-05:00 hadrian: Correctly set whether we have a debug compiler when running tests For example, running the `slow-validate` flavour would incorrectly run the T16135 test which would fail with an assertion error, despite the fact that is should be skipped when we have a debug compiler. - - - - - e0c3e757 by Matthew Pickering at 2022-03-03T13:48:41-05:00 docs: Add note to unsafeCoerce function that you might want to use coerce [skip ci] Fixes #15429 - - - - - 559d4cf3 by Matthew Pickering at 2022-03-03T13:49:17-05:00 docs: Add note to RULES documentation about locally bound variables [skip ci] Fixes #20100 - - - - - c534b3dd by Matthew Pickering at 2022-03-03T13:49:53-05:00 Replace ad-hoc CPP with constant from GHC.Utils.Constant Fixes #21154 - - - - - de56cc7e by Krzysztof Gogolewski at 2022-03-04T12:44:26-05:00 Update documentation of LiberalTypeSynonyms We no longer require LiberalTypeSynonyms to use 'forall' or an unboxed tuple in a synonym. I also removed that kind checking before expanding synonyms "could be changed". This was true when type synonyms were thought of macros, but with the extensions such as SAKS or matchability I don't see it changing. - - - - - c0a39259 by Simon Jakobi at 2022-03-04T12:45:01-05:00 base: Mark GHC.Bits not-home for haddock Most (all) of the exports are re-exported from the preferable Data.Bits. - - - - - 3570eda5 by Sylvain Henry at 2022-03-04T12:45:42-05:00 Fix comments about Int64/Word64 primops - - - - - 6f84ee33 by Artem Pelenitsyn at 2022-03-05T01:06:47-05:00 remove MonadFail instances of ST CLC proposal: https://github.com/haskell/core-libraries-committee/issues/33 The instances had `fail` implemented in terms of `error`, whereas the idea of the `MonadFail` class is that the `fail` method should be implemented in terms of the monad itself. - - - - - 584cd5ae by sheaf at 2022-03-05T01:07:25-05:00 Don't allow Float#/Double# literal patterns This patch does the following two things: 1. Fix the check in Core Lint to properly throw an error when it comes across Float#/Double# literal patterns. The check was incorrect before, because it expected the type to be Float/Double instead of Float#/Double#. 2. Add an error in the parser when the user writes a floating-point literal pattern such as `case x of { 2.0## -> ... }`. Fixes #21115 - - - - - 706deee0 by Greg Steuck at 2022-03-05T17:44:10-08:00 Make T20214 terminate promptly be setting input to /dev/null It was hanging and timing out on OpenBSD before. - - - - - 14e90098 by Simon Peyton Jones at 2022-03-07T14:05:41-05:00 Always generalise top-level bindings Fix #21023 by always generalising top-level binding; change the documentation of -XMonoLocalBinds to match. - - - - - c9c31c3c by Matthew Pickering at 2022-03-07T14:06:16-05:00 hadrian: Add little flavour transformer to build stage2 with assertions This can be useful to build a `perf+assertions` build or even better `default+no_profiled_libs+omit_pragmas+assertions`. - - - - - 89c14a6c by Matthew Pickering at 2022-03-07T14:06:16-05:00 ci: Convert all deb10 make jobs into hadrian jobs This is the first step in converting all the CI configs to use hadrian rather than make. (#21129) The metrics increase due to hadrian using --hyperlinked-source for haddock builds. (See #21156) ------------------------- Metric Increase: haddock.Cabal haddock.base haddock.compiler ------------------------- - - - - - 7bfae2ee by Matthew Pickering at 2022-03-07T14:06:16-05:00 Replace use of BIN_DIST_PREP_TAR_COMP with BIN_DIST_NAME And adds a check to make sure we are not accidently settings BIN_DIST_PREP_TAR_COMP when using hadrian. - - - - - 5b35ca58 by Matthew Pickering at 2022-03-07T14:06:16-05:00 Fix gen_contents_index logic for hadrian bindist - - - - - 273bc133 by Krzysztof Gogolewski at 2022-03-07T14:06:52-05:00 Fix reporting constraints in pprTcSolverReportMsg 'no_instance_msg' and 'no_deduce_msg' were omitting the first wanted. - - - - - 5874a30a by Simon Jakobi at 2022-03-07T14:07:28-05:00 Improve setBit for Natural Previously the default definition was used, which involved allocating intermediate Natural values. Fixes #21173. - - - - - 7a02aeb8 by Matthew Pickering at 2022-03-07T14:08:03-05:00 Remove leftover trace in testsuite - - - - - 6ce6c250 by Andreas Klebinger at 2022-03-07T23:48:56-05:00 Expand and improve the Note [Strict Worker Ids]. I've added an explicit mention of the invariants surrounding those. As well as adding more direct cross references to the Strict Field Invariant. - - - - - d0f892fe by Ryan Scott at 2022-03-07T23:49:32-05:00 Delete GenericKind_ in favor of GenericKind_DC When deriving a `Generic1` instance, we need to know what the last type variable of a data type is. Previously, there were two mechanisms to determine this information: * `GenericKind_`, where `Gen1_` stored the last type variable of a data type constructor (i.e., the `tyConTyVars`). * `GenericKind_DC`, where `Gen1_DC` stored the last universally quantified type variable in a data constructor (i.e., the `dataConUnivTyVars`). These had different use cases, as `GenericKind_` was used for generating `Rep(1)` instances, while `GenericKind_DC` was used for generating `from(1)` and `to(1)` implementations. This was already a bit confusing, but things went from confusing to outright wrong after !6976. This is because after !6976, the `deriving` machinery stopped using `tyConTyVars` in favor of `dataConUnivTyVars`. Well, everywhere with the sole exception of `GenericKind_`, which still continued to use `tyConTyVars`. This lead to disaster when deriving a `Generic1` instance for a GADT family instance, as the `tyConTyVars` do not match the `dataConUnivTyVars`. (See #21185.) The fix is to stop using `GenericKind_` and replace it with `GenericKind_DC`. For the most part, this proves relatively straightforward. Some highlights: * The `forgetArgVar` function was deleted entirely, as it no longer proved necessary after `GenericKind_`'s demise. * The substitution that maps from the last type variable to `Any` (see `Note [Generating a correctly typed Rep instance]`) had to be moved from `tc_mkRepTy` to `tc_mkRepFamInsts`, as `tc_mkRepTy` no longer has access to the last type variable. Fixes #21185. - - - - - a60ddffd by Matthew Pickering at 2022-03-08T22:51:37+00:00 Move bootstrap and cabal-reinstall test jobs to nightly CI is creaking under the pressure of too many jobs so attempt to reduce the strain by removing a couple of jobs. - - - - - 7abe3288 by Matthew Pickering at 2022-03-09T10:24:15+00:00 Add 10 minute timeout to linters job - - - - - 3cf75ede by Matthew Pickering at 2022-03-09T10:24:16+00:00 Revert "hadrian: Correctly set whether we have a debug compiler when running tests" Needing the arguments for "GHC/Utils/Constant.hs" implies a dependency on the previous stage compiler. Whilst we work out how to get around this I will just revert this commit (as it only affects running the testsuite in debug way). This reverts commit ce65d0cceda4a028f30deafa3c39d40a250acc6a. - - - - - 18b9ba56 by Matthew Pickering at 2022-03-09T11:07:23+00:00 ci: Fix save_cache function Each interation of saving the cache would copy the whole `cabal` store into a subfolder in the CACHE_DIR rather than copying the contents of the cabal store into the cache dir. This resulted in a cache which looked like: ``` /builds/ghc/ghc/cabal-cache/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/ ``` So it would get one layer deeper every CI run and take longer and longer to compress. - - - - - bc684dfb by Ben Gamari at 2022-03-10T03:20:07-05:00 mr-template: Mention timeframe for review - - - - - 7f5f4ede by Vladislav Zavialov at 2022-03-10T03:20:43-05:00 Bump submodules: containers, exceptions GHC Proposal #371 requires TypeOperators to use type equality a~b. This submodule update pulls in the appropriate forward-compatibility changes in 'libraries/containers' and 'libraries/exceptions' - - - - - 8532b8a9 by Matthew Pickering at 2022-03-10T03:20:43-05:00 Add an inline pragma to lookupVarEnv The containers bump reduced the size of the Data.IntMap.Internal.lookup function so that it no longer experienced W/W. This means that the size of lookupVarEnv increased over the inlining threshold and it wasn't inlined into the hot code path in substTyVar. See containers#821, #21159 and !7638 for some more explanation. ------------------------- Metric Decrease: LargeRecord T12227 T13386 T15703 T18223 T5030 T8095 T9872a T9872b T9872c TcPlugin_RewritePerf ------------------------- - - - - - 844cf1e1 by Matthew Pickering at 2022-03-10T03:20:43-05:00 Normalise output of T10970 test The output of this test changes each time the containers submodule version updates. It's easier to apply the version normaliser so that the test checks that there is a version number, but not which one it is. - - - - - 24b6af26 by Ryan Scott at 2022-03-11T19:56:28-05:00 Refactor tcDeriving to generate tyfam insts before any bindings Previously, there was an awful hack in `genInst` (now called `genInstBinds` after this patch) where we had to return a continutation rather than directly returning the bindings for a derived instance. This was done for staging purposes, as we had to first infer the instance contexts for derived instances and then feed these contexts into the continuations to ensure the generated instance bindings had accurate instance contexts. `Note [Staging of tcDeriving]` in `GHC.Tc.Deriving` described this confusing state of affairs. The root cause of this confusing design was the fact that `genInst` was trying to generate instance bindings and associated type family instances for derived instances simultaneously. This really isn't possible, however: as `Note [Staging of tcDeriving]` explains, one needs to have access to the associated type family instances before one can properly infer the instance contexts for derived instances. The use of continuation-returning style was an attempt to circumvent this dependency, but it did so in an awkward way. This patch detangles this awkwardness by splitting up `genInst` into two functions: `genFamInsts` (for associated type family instances) and `genInstBinds` (for instance bindings). Now, the `tcDeriving` function calls `genFamInsts` and brings all the family instances into scope before calling `genInstBinds`. This removes the need for the awkward continuation-returning style seen in the previous version of `genInst`, making the code easier to understand. There are some knock-on changes as well: 1. `hasStockDeriving` now needs to return two separate functions: one that describes how to generate family instances for a stock-derived instance, and another that describes how to generate the instance bindings. I factored out this pattern into a new `StockGenFns` data type. 2. While documenting `StockGenFns`, I realized that there was some inconsistency regarding which `StockGenFns` functions needed which arguments. In particular, the function in `GHC.Tc.Deriv.Generics` which generates `Rep(1)` instances did not take a `SrcSpan` like other `gen_*` functions did, and it included an extra `[Type]` argument that was entirely redundant. As a consequence, I refactored the code in `GHC.Tc.Deriv.Generics` to more closely resemble other `gen_*` functions. A happy result of all this is that all `StockGenFns` functions now take exactly the same arguments, which makes everything more uniform. This is purely a refactoring that should not have any effect on user-observable behavior. The new design paves the way for an eventual fix for #20719. - - - - - 62caaa9b by Ben Gamari at 2022-03-11T19:57:03-05:00 gitlab-ci: Use the linters image in hlint job As the `hlint` executable is only available in the linters image. Fixes #21146. - - - - - 4abd7eb0 by Matthew Pickering at 2022-03-11T19:57:38-05:00 Remove partOfGhci check in the loader This special logic has been part of GHC ever since template haskell was introduced in 9af77fa423926fbda946b31e174173d0ec5ebac8. It's hard to believe in any case that this special logic pays its way at all. Given * The list is out-of-date, which has potential to lead to miscompilation when using "editline", which was removed in 2010 (46aed8a4). * The performance benefit seems negligable as each load only happens once anyway and packages specified by package flags are preloaded into the linker state at the start of compilation. Therefore we just remove this logic. Fixes #19791 - - - - - c40cbaa2 by Andreas Klebinger at 2022-03-11T19:58:14-05:00 Improve -dtag-inference-checks checks. FUN closures don't get tagged when evaluated. So no point in checking their tags. - - - - - ab00d23b by Simon Jakobi at 2022-03-11T19:58:49-05:00 Improve clearBit and complementBit for Natural Also optimize bigNatComplementBit#. Fixes #21175, #21181, #21194. - - - - - a6d8facb by Sebastian Graf at 2022-03-11T19:59:24-05:00 gitignore all (build) directories headed by _ - - - - - 524795fe by Sebastian Graf at 2022-03-11T19:59:24-05:00 Demand: Document why we need three additional equations of multSubDmd - - - - - 6bdcd557 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: make 64-bit word splitting for 32-bit targets respect target endianness This used to been broken for little-endian targets. - - - - - 9e67c69e by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: fix Double# literal payload for 32-bit targets Contrary to the legacy comment, the splitting didn't happen and we ended up with a single StgWord64 literal in the output code! Let's just do the splitting here. - - - - - 1eee2e28 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: use __builtin versions of memcpyish functions to fix type mismatch Our memcpyish primop's type signatures doesn't match the C type signatures. It's not a problem for typical archs, since their C ABI permits dropping the result, but it doesn't work for wasm. The previous logic would cast the memcpyish function pointer to an incorrect type and perform an indirect call, which results in a runtime trap on wasm. The most straightforward fix is: don't emit EFF_ for memcpyish functions. Since we don't want to include extra headers in .hc to bring in their prototypes, we can just use the __builtin versions. - - - - - 9d8d4837 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: emit __builtin_unreachable() when CmmSwitch doesn't contain fallback case Otherwise the C compiler may complain "warning: non-void function does not return a value in all control paths [-Wreturn-type]". - - - - - 27da5540 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: make floatToWord32/doubleToWord64 faster Use castFloatToWord32/castDoubleToWord64 in base to perform the reinterpret cast. - - - - - c98e8332 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: fix -Wunused-value warning in ASSIGN_BaseReg When ASSIGN_BaseReg is a no-op, we shouldn't generate any C code, otherwise C compiler complains a bunch of -Wunused-value warnings when doing unregisterised codegen. - - - - - 5932247c by Ben Gamari at 2022-03-11T20:00:36-05:00 users guide: Eliminate spurious \spxentry mentions We were failing to pass the style file to `makeindex`, as is done by the mklatex configuration generated by Sphinx. Fixes #20913. - - - - - e40cf4ef by Simon Jakobi at 2022-03-11T20:01:11-05:00 ghc-bignum: Tweak integerOr The result of ORing two BigNats is always greater or equal to the larger of the two. Therefore it is safe to skip the magnitude checks of integerFromBigNat#. - - - - - cf081476 by Vladislav Zavialov at 2022-03-12T07:02:40-05:00 checkUnboxedLitPat: use non-fatal addError This enables GHC to report more parse errors in a single pass. - - - - - 7fe07143 by Andreas Klebinger at 2022-03-12T07:03:16-05:00 Rename -fprof-late-ccs to -fprof-late - - - - - 88a94541 by Sylvain Henry at 2022-03-12T07:03:56-05:00 Hadrian: avoid useless allocations in trackArgument Cf ticky report before the change: Entries Alloc Alloc'd Non-void Arguments STG Name -------------------------------------------------------------------------------- 696987 29044128 0 1 L main:Target.trackArgument_go5{v r24kY} (fun) - - - - - 2509d676 by Sylvain Henry at 2022-03-12T07:04:36-05:00 Hadrian: avoid allocating in stageString (#19209) - - - - - c062fac0 by Sylvain Henry at 2022-03-12T07:04:36-05:00 Hadrian: remove useless imports Added for no reason in 7ce1b694f7be7fbf6e2d7b7eb0639e61fbe358c6 - - - - - c82fb934 by Sylvain Henry at 2022-03-12T07:05:16-05:00 Hadrian: avoid allocations in WayUnit's Read instance (#19209) - - - - - ed04aed2 by Sylvain Henry at 2022-03-12T07:05:16-05:00 Hadrian: use IntSet Binary instance for Way (#19209) - - - - - ad835531 by Simon Peyton Jones at 2022-03-13T18:12:12-04:00 Fix bug in weak loop-breakers in OccurAnal Note [Weak loop breakers] explains why we need to track variables free in RHS of rules. But we need to do this for /inactive/ rules as well as active ones, unlike the rhs_fv_env stuff. So we now have two fields in node Details, one for free vars of active rules, and one for free vars of all rules. This was shown up by #20820, which is now fixed. - - - - - 76b94b72 by Sebastian Graf at 2022-03-13T18:12:48-04:00 Worker/wrapper: Preserve float barriers (#21150) Issue #21150 shows that worker/wrapper allocated a worker function for a function with multiple calls that said "called at most once" when the first argument was absent. That's bad! This patch makes it so that WW preserves at least one non-one-shot value lambda (see `Note [Preserving float barriers]`) by passing around `void#` in place of absent arguments. Fixes #21150. Since the fix is pretty similar to `Note [Protecting the last value argument]`, I put the logic in `mkWorkerArgs`. There I realised (#21204) that `-ffun-to-thunk` is basically useless with `-ffull-laziness`, so I deprecated the flag, simplified and split into `needsVoidWorkerArg`/`addVoidWorkerArg`. SpecConstr is another client of that API. Fixes #21204. Metric Decrease: T14683 - - - - - 97db789e by romes at 2022-03-14T11:36:39-04:00 Fix up Note [Bind free vars] Move GHC-specific comments from Language.Haskell.Syntax.Binds to GHC.Hs.Binds It looks like the Note was deleted but there were actually two copies of it. L.H.S.B no longer references it, and GHC.Hs.Binds keeps an updated copy. (See #19252) There are other duplicated notes -- they will be fixed in the next commit - - - - - 135888dd by romes at 2022-03-14T11:36:39-04:00 TTG Pull AbsBinds and ABExport out of the main AST AbsBinds and ABExport both depended on the typechecker, and were thus removed from the main AST Expr. CollectPass now has a new function `collectXXHsBindsLR` used for the new HsBinds extension point Bumped haddock submodule to work with AST changes. The removed Notes from Language.Haskell.Syntax.Binds were duplicated (and not referenced) and the copies in GHC.Hs.Binds are kept (and referenced there). (See #19252) - - - - - 106413f0 by sheaf at 2022-03-14T11:37:21-04:00 Add two coercion optimisation perf tests - - - - - 8eadea67 by sheaf at 2022-03-14T15:08:24-04:00 Fix isLiftedType_maybe and handle fallout As #20837 pointed out, `isLiftedType_maybe` returned `Just False` in many situations where it should return `Nothing`, because it didn't take into account type families or type variables. In this patch, we fix this issue. We rename `isLiftedType_maybe` to `typeLevity_maybe`, which now returns a `Levity` instead of a boolean. We now return `Nothing` for types with kinds of the form `TYPE (F a1 ... an)` for a type family `F`, as well as `TYPE (BoxedRep l)` where `l` is a type variable. This fix caused several other problems, as other parts of the compiler were relying on `isLiftedType_maybe` returning a `Just` value, and were now panicking after the above fix. There were two main situations in which panics occurred: 1. Issues involving the let/app invariant. To uphold that invariant, we need to know whether something is lifted or not. If we get an answer of `Nothing` from `isLiftedType_maybe`, then we don't know what to do. As this invariant isn't particularly invariant, we can change the affected functions to not panic, e.g. by behaving the same in the `Just False` case and in the `Nothing` case (meaning: no observable change in behaviour compared to before). 2. Typechecking of data (/newtype) constructor patterns. Some programs involving patterns with unknown representations were accepted, such as T20363. Now that we are stricter, this caused further issues, culminating in Core Lint errors. However, the behaviour was incorrect the whole time; the incorrectness only being revealed by this change, not triggered by it. This patch fixes this by overhauling where the representation polymorphism involving pattern matching are done. Instead of doing it in `tcMatches`, we instead ensure that the `matchExpected` functions such as `matchExpectedFunTys`, `matchActualFunTySigma`, `matchActualFunTysRho` allow return argument pattern types which have a fixed RuntimeRep (as defined in Note [Fixed RuntimeRep]). This ensures that the pattern matching code only ever handles types with a known runtime representation. One exception was that patterns with an unknown representation type could sneak in via `tcConPat`, which points to a missing representation-polymorphism check, which this patch now adds. This means that we now reject the program in #20363, at least until we implement PHASE 2 of FixedRuntimeRep (allowing type families in RuntimeRep positions). The aforementioned refactoring, in which checks have been moved to `matchExpected` functions, is a first step in implementing PHASE 2 for patterns. Fixes #20837 - - - - - 8ff32124 by Sebastian Graf at 2022-03-14T15:09:01-04:00 DmdAnal: Don't unbox recursive data types (#11545) As `Note [Demand analysis for recursive data constructors]` describes, we now refrain from unboxing recursive data type arguments, for two reasons: 1. Relating to run/alloc perf: Similar to `Note [CPR for recursive data constructors]`, it seldomly improves run/alloc performance if we just unbox a finite number of layers of a potentially huge data structure. 2. Relating to ghc/alloc perf: Inductive definitions on single-product recursive data types like the one in T11545 will (diverge, and) have very deep demand signatures before any other abortion mechanism in Demand analysis is triggered. That leads to great and unnecessary churn on Demand analysis when ultimately we will never make use of any nested strictness information anyway. Conclusion: Discard nested demand and boxity information on such recursive types with the help of `Note [Detecting recursive data constructors]`. I also implemented `GHC.Types.Unique.MemoFun.memoiseUniqueFun` in order to avoid the overhead of repeated calls to `GHC.Core.Opt.WorkWrap.Utils.isRecDataCon`. It's nice and simple and guards against some smaller regressions in T9233 and T16577. ghc/alloc performance-wise, this patch is a very clear win: Test Metric value New value Change --------------------------------------------------------------------------------------- LargeRecord(normal) ghc/alloc 6,141,071,720 6,099,871,216 -0.7% MultiLayerModulesTH_OneShot(normal) ghc/alloc 2,740,973,040 2,705,146,640 -1.3% T11545(normal) ghc/alloc 945,475,492 85,768,928 -90.9% GOOD T13056(optasm) ghc/alloc 370,245,880 326,980,632 -11.7% GOOD T18304(normal) ghc/alloc 90,933,944 76,998,064 -15.3% GOOD T9872a(normal) ghc/alloc 1,800,576,840 1,792,348,760 -0.5% T9872b(normal) ghc/alloc 2,086,492,432 2,073,991,848 -0.6% T9872c(normal) ghc/alloc 1,750,491,240 1,737,797,832 -0.7% TcPlugin_RewritePerf(normal) ghc/alloc 2,286,813,400 2,270,957,896 -0.7% geo. mean -2.9% No noteworthy change in run/alloc either. NoFib results show slight wins, too: -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- constraints -1.9% -1.4% fasta -3.6% -2.7% reverse-complem -0.3% -0.9% treejoin -0.0% -0.3% -------------------------------------------------------------------------------- Min -3.6% -2.7% Max +0.1% +0.1% Geometric Mean -0.1% -0.1% Metric Decrease: T11545 T13056 T18304 - - - - - ab618309 by Vladislav Zavialov at 2022-03-15T18:34:38+03:00 Export (~) from Data.Type.Equality (#18862) * Users can define their own (~) type operator * Haddock can display documentation for the built-in (~) * New transitional warnings implemented: -Wtype-equality-out-of-scope -Wtype-equality-requires-operators Updates the haddock submodule. - - - - - 577135bf by Aaron Allen at 2022-03-16T02:27:48-04:00 Convert Diagnostics in GHC.Tc.Gen.Foreign Converts all uses of 'TcRnUnknownMessage' to proper diagnostics. - - - - - c1fed9da by Aaron Allen at 2022-03-16T02:27:48-04:00 Suggest FFI extensions as hints (#20116) - Use extension suggestion hints instead of suggesting extensions in the error message body for several FFI errors. - Adds a test case for `TcRnForeignImportPrimExtNotSet` - - - - - a33d1045 by Zubin Duggal at 2022-03-16T02:28:24-04:00 TH: allow negative patterns in quotes (#20711) We still don't allow negative overloaded patterns. Earler all negative patterns were treated as negative overloaded patterns. Now, we expliclty check the extension field to see if the pattern is actually a negative overloaded pattern - - - - - 1575c4a5 by Sebastian Graf at 2022-03-16T02:29:03-04:00 Demand: Let `Boxed` win in `lubBoxity` (#21119) Previously, we let `Unboxed` win in `lubBoxity`, which is unsoundly optimistic in terms ob Boxity analysis. "Unsoundly" in the sense that we sometimes unbox parameters that we better shouldn't unbox. Examples are #18907 and T19871.absent. Until now, we thought that this hack pulled its weight becuase it worked around some shortcomings of the phase separation between Boxity analysis and CPR analysis. But it is a gross hack which caused regressions itself that needed all kinds of fixes and workarounds. See for example #20767. It became impossible to work with in !7599, so I want to remove it. For example, at the moment, `lubDmd B dmd` will not unbox `dmd`, but `lubDmd A dmd` will. Given that `B` is supposed to be the bottom element of the lattice, it's hardly justifiable to get a better demand when `lub`bing with `A`. The consequence of letting `Boxed` win in `lubBoxity` is that we *would* regress #2387, #16040 and parts of #5075 and T19871.sumIO, until Boxity and CPR are able to communicate better. Fortunately, that is not the case since I could tweak the other source of optimism in Boxity analysis that is described in `Note [Unboxed demand on function bodies returning small products]` so that we *recursively* assume unboxed demands on function bodies returning small products. See the updated Note. `Note [Boxity for bottoming functions]` describes why we need bottoming functions to have signatures that say that they deeply unbox their arguments. In so doing, I had to tweak `finaliseArgBoxities` so that it will never unbox recursive data constructors. This is in line with our handling of them in CPR. I updated `Note [Which types are unboxed?]` to reflect that. In turn we fix #21119, #20767, #18907, T19871.absent and get a much simpler implementation (at least to think about). We can also drop the very ad-hoc definition of `deferAfterPreciseException` and its Note in favor of the simple, intuitive definition we used to have. Metric Decrease: T16875 T18223 T18698a T18698b hard_hole_fits Metric Increase: LargeRecord MultiComponentModulesRecomp T15703 T8095 T9872d Out of all the regresions, only the one in T9872d doesn't vanish in a perf build, where the compiler is bootstrapped with -O2 and thus SpecConstr. Reason for regressions: * T9872d is due to `ty_co_subst` taking its `LiftingContext` boxed. That is because the context is passed to a function argument, for example in `liftCoSubstTyVarBndrUsing`. * In T15703, LargeRecord and T8095, we get a bit more allocations in `expand_syn` and `piResultTys`, because a `TCvSubst` isn't unboxed. In both cases that guards against reboxing in some code paths. * The same is true for MultiComponentModulesRecomp, where we get less unboxing in `GHC.Unit.Finder.$wfindInstalledHomeModule`. In a perf build, allocations actually *improve* by over 4%! Results on NoFib: -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- awards -0.4% +0.3% cacheprof -0.3% +2.4% fft -1.5% -5.1% fibheaps +1.2% +0.8% fluid -0.3% -0.1% ida +0.4% +0.9% k-nucleotide +0.4% -0.1% last-piece +10.5% +13.9% lift -4.4% +3.5% mandel2 -99.7% -99.8% mate -0.4% +3.6% parser -1.0% +0.1% puzzle -11.6% +6.5% reverse-complem -3.0% +2.0% scs -0.5% +0.1% sphere -0.4% -0.2% wave4main -8.2% -0.3% -------------------------------------------------------------------------------- Summary excludes mandel2 because of excessive bias Min -11.6% -5.1% Max +10.5% +13.9% Geometric Mean -0.2% +0.3% -------------------------------------------------------------------------------- Not bad for a bug fix. The regression in `last-piece` could become a win if SpecConstr would work on non-recursive functions. The regression in `fibheaps` is due to `Note [Reboxed crud for bottoming calls]`, e.g., #21128. - - - - - bb779b90 by sheaf at 2022-03-16T02:29:42-04:00 Add a regression test for #21130 This problem was due to a bug in cloneWanted, which was incorrectly creating a coercion hole to hold an evidence variable. This bug was introduced by 8bb52d91 and fixed in 81740ce8. Fixes #21130 - - - - - 0f0e2394 by Tamar Christina at 2022-03-17T10:16:37-04:00 linker: Initial Windows C++ exception unwinding support - - - - - 36d20d4d by Tamar Christina at 2022-03-17T10:16:37-04:00 linker: Fix ADDR32NB relocations on Windows - - - - - 8a516527 by Tamar Christina at 2022-03-17T10:16:37-04:00 testsuite: properly escape string paths - - - - - 1a0dd008 by sheaf at 2022-03-17T10:17:13-04:00 Hadrian: account for change in late-ccs flag The late cost centre flag was renamed from -fprof-late-ccs to -fprof-late in 7fe07143, but this change hadn't been propagated to Hadrian. - - - - - 8561c1af by romes at 2022-03-18T05:10:58-04:00 TTG: Refactor HsBracket - - - - - 19163397 by romes at 2022-03-18T05:10:58-04:00 Type-checking untyped brackets When HsExpr GhcTc, the HsBracket constructor should hold a HsBracket GhcRn, rather than an HsBracket GhcTc. We make use of the HsBracket p extension constructor (XBracket (XXBracket p)) to hold an HsBracket GhcRn when the pass is GhcTc See !4782 https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782 - - - - - 310890a5 by romes at 2022-03-18T05:10:58-04:00 Separate constructors for typed and untyped brackets Split HsBracket into HsTypedBracket and HsUntypedBracket. Unfortunately, we still cannot get rid of instance XXTypedBracket GhcTc = HsTypedBracket GhcRn despite no longer requiring it for typechecking, but rather because the TH desugarer works on GhcRn rather than GhcTc (See GHC.HsToCore.Quote) - - - - - 4a2567f5 by romes at 2022-03-18T05:10:58-04:00 TTG: Refactor bracket for desugaring during tc When desugaring a bracket we want to desugar /renamed/ rather than /typechecked/ code; So in (HsExpr GhcTc) tree, we must have a (HsExpr GhcRn) for the quotation itself. This commit reworks the TTG refactor on typed and untyped brackets by storing the /renamed/ code in the bracket field extension rather than in the constructor extension in `HsQuote` (previously called `HsUntypedBracket`) See Note [The life cycle of a TH quotation] and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782 - - - - - b056adc8 by romes at 2022-03-18T05:10:58-04:00 TTG: Make HsQuote GhcTc isomorphic to NoExtField An untyped bracket `HsQuote p` can never be constructed with `p ~ GhcTc`. This is because we don't typecheck `HsQuote` at all. That's OK, because we also never use `HsQuote GhcTc`. To enforce this at the type level we make `HsQuote GhcTc` isomorphic to `NoExtField` and impossible to construct otherwise, by using TTG field extensions to make all constructors, except for `XQuote` (which takes `NoExtField`), unconstructable, with `DataConCantHappen` This is explained more in detail in Note [The life cycle of a TH quotation] Related discussion: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782 - - - - - ac3b2e7d by romes at 2022-03-18T05:10:58-04:00 TTG: TH brackets finishing touches Rewrite the critical notes and fix outdated ones, use `HsQuote GhcRn` (in `HsBracketTc`) for desugaring regardless of the bracket being typed or untyped, remove unused `EpAnn` from `Hs*Bracket GhcRn`, zonkExpr factor out common brackets code, ppr_expr factor out common brackets code, and fix tests, to finish MR https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782. ------------------------- Metric Decrease: hard_hole_fits ------------------------- - - - - - d147428a by Ben Gamari at 2022-03-18T05:11:35-04:00 codeGen: Fix signedness of jump table indexing Previously while constructing the jump table index we would zero-extend the discriminant before subtracting the start of the jump-table. This goes subtly wrong in the case of a sub-word, signed discriminant, as described in the included Note. Fix this in both the PPC and X86 NCGs. Fixes #21186. - - - - - 435a3d5d by Ben Gamari at 2022-03-18T05:11:35-04:00 testsuite: Add test for #21186 - - - - - e9d8de93 by Zubin Duggal at 2022-03-19T07:35:49-04:00 TH: Fix pretty printing of newtypes with operators and GADT syntax (#20868) The pretty printer for regular data types already accounted for these, and had some duplication with the newtype pretty printer. Factoring the logic out into a common function and using it for both newtypes and data declarations is enough to fix the bug. - - - - - 244da9eb by sheaf at 2022-03-19T07:36:24-04:00 List GHC.Event.Internal in base.cabal on Windows GHC.Event.Internal was not listed in base.cabal on Windows. This caused undefined reference errors. This patch adds it back, by moving it out of the OS-specific logic in base.cabal. Fixes #21245. - - - - - d1c03719 by Andreas Klebinger at 2022-03-19T07:37:00-04:00 Compact regions: Maintain tags properly Fixes #21251 - - - - - d45bb701 by romes at 2022-03-19T07:37:36-04:00 Remove dead code HsDoRn - - - - - c842611f by nineonine at 2022-03-20T21:16:06-04:00 Revamp derived Eq instance code generation (#17240) This patch improves code generation for derived Eq instances. The idea is to use 'dataToTag' to evaluate both arguments. This allows to 'short-circuit' when tags do not match. Unfortunately, inner evals are still present when we branch on tags. This is due to the way 'dataToTag#' primop evaluates its argument in the code generator. #21207 was created to explore further optimizations. Metric Decrease: LargeRecord - - - - - 52ffd38c by Sylvain Henry at 2022-03-20T21:16:46-04:00 Avoid some SOURCE imports - - - - - b91798be by Zubin Duggal at 2022-03-23T13:39:39-04:00 hi haddock: Lex and store haddock docs in interface files Names appearing in Haddock docstrings are lexed and renamed like any other names appearing in the AST. We currently rename names irrespective of the namespace, so both type and constructor names corresponding to an identifier will appear in the docstring. Haddock will select a given name as the link destination based on its own heuristics. This patch also restricts the limitation of `-haddock` being incompatible with `Opt_KeepRawTokenStream`. The export and documenation structure is now computed in GHC and serialised in .hi files. This can be used by haddock to directly generate doc pages without reparsing or renaming the source. At the moment the operation of haddock is not modified, that's left to a future patch. Updates the haddock submodule with the minimum changes needed. - - - - - 78db231f by Cheng Shao at 2022-03-23T13:40:17-04:00 configure: bump LlvmMaxVersion to 14 LLVM 13.0.0 is released in Oct 2021, and latest head validates against LLVM 13 just fine if LlvmMaxVersion is bumped. - - - - - b06e5dd8 by Adam Sandberg Ericsson at 2022-03-23T13:40:54-04:00 docs: clarify the eventlog format documentation a little bit - - - - - 4dc62498 by Matthew Pickering at 2022-03-23T13:41:31-04:00 Fix behaviour of -Wunused-packages in ghci Ticket #21110 points out that -Wunused-packages behaves a bit unusually in GHCi. Now we define the semantics for -Wunused-packages in interactive mode as follows: * If you use -Wunused-packages on an initial load then the warning is reported. * If you explicitly set -Wunused-packages on the command line then the warning is displayed (until it is disabled) * If you then subsequently modify the set of available targets by using :load or :cd (:cd unloads everything) then the warning is (silently) turned off. This means that every :r the warning is printed if it's turned on (but you did ask for it). Fixes #21110 - - - - - fed05347 by Ben Gamari at 2022-03-23T13:42:07-04:00 rts/adjustor: Place adjustor templates in data section on all OSs In !7604 we started placing adjustor templates in the data section on Linux as some toolchains there reject relocations in the text section. However, it turns out that OpenBSD also exhibits this restriction. Fix this by *always* placing adjustor templates in the data section. Fixes #21155. - - - - - db32bb8c by Zubin Duggal at 2022-03-23T13:42:44-04:00 Improve error message when warning about unsupported LLVM version (#20958) Change the wording to make it clear that the upper bound is non-inclusive. - - - - - f214349a by Ben Gamari at 2022-03-23T13:43:20-04:00 rts: Untag function field in scavenge_PAP_payload Previously we failed to untag the function closure when scavenging the payload of a PAP, resulting in an invalid closure pointer being passed to scavenge_large_bitmap and consequently #21254. Fix this. Fixes #21254 - - - - - e6d0e287 by Ben Gamari at 2022-03-23T13:43:20-04:00 rts: Don't mark object code in markCAFs unless necessary Previously `markCAFs` would call `markObjectCode` even in non-major GCs. This is problematic since `prepareUnloadCheck` is not called in such GCs, meaning that the section index has not been updated. Fixes #21254 - - - - - 1a7cf096 by Sylvain Henry at 2022-03-23T13:44:05-04:00 Avoid redundant imports of GHC.Driver.Session Remove GHC.Driver.Session imports that weren't considered as redundant because of the reexport of PlatformConstants. Also remove this reexport as modules using this datatype should import GHC.Platform instead. - - - - - e3f60577 by Sylvain Henry at 2022-03-23T13:44:05-04:00 Reverse dependency between StgToCmm and Runtime.Heap.Layout - - - - - e6585ca1 by Sylvain Henry at 2022-03-23T13:44:46-04:00 Define filterOut with filter filter has fusion rules that filterOut lacks - - - - - c58d008c by Ryan Scott at 2022-03-24T06:10:43-04:00 Fix and simplify DeriveAnyClass's context inference using SubTypePredSpec As explained in `Note [Gathering and simplifying constraints for DeriveAnyClass]` in `GHC.Tc.Deriv.Infer`, `DeriveAnyClass` infers instance contexts by emitting implication constraints. Previously, these implication constraints were constructed by hand. This is a terribly trick thing to get right, as it involves a delicate interplay of skolemisation, metavariable instantiation, and `TcLevel` bumping. Despite much effort, we discovered in #20719 that the implementation was subtly incorrect, leading to valid programs being rejected. While we could scrutinize the code that manually constructs implication constraints and repair it, there is a better, less error-prone way to do things. After all, the heart of `DeriveAnyClass` is generating code which fills in each class method with defaults, e.g., `foo = $gdm_foo`. Typechecking this sort of code is tantamount to calling `tcSubTypeSigma`, as we much ensure that the type of `$gdm_foo` is a subtype of (i.e., more polymorphic than) the type of `foo`. As an added bonus, `tcSubTypeSigma` is a battle-tested function that handles skolemisation, metvariable instantiation, `TcLevel` bumping, and all other means of tricky bookkeeping correctly. With this insight, the solution to the problems uncovered in #20719 is simple: use `tcSubTypeSigma` to check if `$gdm_foo`'s type is a subtype of `foo`'s type. As a side effect, `tcSubTypeSigma` will emit exactly the implication constraint that we were attempting to construct by hand previously. Moreover, it does so correctly, fixing #20719 as a consequence. This patch implements the solution thusly: * The `PredSpec` data type (previously named `PredOrigin`) is now split into `SimplePredSpec`, which directly stores a `PredType`, and `SubTypePredSpec`, which stores the actual and expected types in a subtype check. `SubTypePredSpec` is only used for `DeriveAnyClass`; all other deriving strategies use `SimplePredSpec`. * Because `tcSubTypeSigma` manages the finer details of type variable instantiation and constraint solving under the hood, there is no longer any need to delicately split apart the method type signatures in `inferConstraintsAnyclass`. This greatly simplifies the implementation of `inferConstraintsAnyclass` and obviates the need to store skolems, metavariables, or given constraints in a `ThetaSpec` (previously named `ThetaOrigin`). As a bonus, this means that `ThetaSpec` now simply becomes a synonym for a list of `PredSpec`s, which is conceptually much simpler than it was before. * In `simplifyDeriv`, each `SubTypePredSpec` results in a call to `tcSubTypeSigma`. This is only performed for its side effect of emitting an implication constraint, which is fed to the rest of the constraint solving machinery in `simplifyDeriv`. I have updated `Note [Gathering and simplifying constraints for DeriveAnyClass]` to explain this in more detail. To make the changes in `simplifyDeriv` more manageable, I also performed some auxiliary refactoring: * Previously, every iteration of `simplifyDeriv` was skolemising the type variables at the start, simplifying, and then performing a reverse substitution at the end to un-skolemise the type variables. This is not necessary, however, since we can just as well skolemise once at the beginning of the `deriving` pipeline and zonk the `TcTyVar`s after `simplifyDeriv` is finished. This patch does just that, having been made possible by prior work in !7613. I have updated `Note [Overlap and deriving]` in `GHC.Tc.Deriv.Infer` to explain this, and I have also left comments on the relevant data structures (e.g., `DerivEnv` and `DerivSpec`) to explain when things might be `TcTyVar`s or `TyVar`s. * All of the aforementioned cleanup allowed me to remove an ad hoc deriving-related in `checkImplicationInvariants`, as all of the skolems in a `tcSubTypeSigma`–produced implication constraint should now be `TcTyVar` at the time the implication is created. * Since `simplifyDeriv` now needs a `SkolemInfo` and `UserTypeCtxt`, I have added `ds_skol_info` and `ds_user_ctxt` fields to `DerivSpec` to store these. Similarly, I have also added a `denv_skol_info` field to `DerivEnv`, which ultimately gets used to initialize the `ds_skol_info` in a `DerivSpec`. Fixes #20719. - - - - - 21680fb0 by Sebastian Graf at 2022-03-24T06:11:19-04:00 WorkWrap: Handle partial FUN apps in `isRecDataCon` (#21265) Partial FUN apps like `(->) Bool` aren't detected by `splitFunTy_maybe`. A silly oversight that is easily fixed by replacing `splitFunTy_maybe` with a guard in the `splitTyConApp_maybe` case. But fortunately, Simon nudged me into rewriting the whole `isRecDataCon` function in a way that makes it much shorter and hence clearer which DataCons are actually considered as recursive. Fixes #21265. - - - - - a2937e2b by Matthew Pickering at 2022-03-24T17:13:22-04:00 Add test for T21035 This test checks that you are allowed to explicitly supply object files for dependencies even if you haven't got the shared object for that library yet. Fixes #21035 - - - - - 1756d547 by Matthew Pickering at 2022-03-24T17:13:58-04:00 Add check to ensure we are not building validate jobs for releases - - - - - 99623358 by Matthew Pickering at 2022-03-24T17:13:58-04:00 hadrian: Correct generation of hsc2hs wrapper If you inspect the inside of a wrapper script for hsc2hs you will see that the cflag and lflag values are concatenated incorrectly. ``` HSC2HS_EXTRA="--cflag=-U__i686--lflag=-fuse-ld=gold" ``` It should instead be ``` HSC2HS_EXTRA="--cflag=-U__i686 --lflag=-fuse-ld=gold" ``` Fixes #21221 - - - - - fefd4e31 by Matthew Pickering at 2022-03-24T17:13:59-04:00 testsuite: Remove library dependenices from T21119 These dependencies would affect the demand signature depending on various rules and so on. Fixes #21271 - - - - - 5ff690b8 by Matthew Pickering at 2022-03-24T17:13:59-04:00 ci: Generate jobs for all normal builds and use hadrian for all builds This commit introduces a new script (.gitlab/gen_ci.hs) which generates a yaml file (.gitlab/jobs.yaml) which contains explicit descriptions for all the jobs we want to run. The jobs are separated into three categories: * validate - jobs run on every MR * nightly - jobs run once per day on the master branch * release - jobs for producing release artifacts The generation script is a Haskell program which includes a DSL for specifying the different jobs. The hope is that it's easier to reason about the different jobs and how the variables are merged together rather than the unclear and opaque yaml syntax. The goal is to fix issues like #21190 once and for all.. The `.gitlab/jobs.yaml` can be generated by running the `.gitlab/generate_jobs` script. You have to do this manually. Another consequence of this patch is that we use hadrian for all the validate, nightly and release builds on all platforms. - - - - - 1d673aa2 by Christiaan Baaij at 2022-03-25T11:35:49-04:00 Add the OPAQUE pragma A new pragma, `OPAQUE`, that ensures that every call of a named function annotated with an `OPAQUE` pragma remains a call of that named function, not some name-mangled variant. Implements GHC proposal 0415: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0415-opaque-pragma.rst This commit also updates the haddock submodule to handle the newly introduced lexer tokens corresponding to the OPAQUE pragma. - - - - - 83f5841b by Bodigrim at 2022-03-25T11:36:31-04:00 Add instance Lift ByteArray - - - - - 7cc1184a by Matthew Pickering at 2022-03-25T11:37:07-04:00 Make -ddump-rn-ast and -ddump-tc-ast work in GHCi Fixes #17830 - - - - - 940feaf3 by Sylvain Henry at 2022-03-25T11:37:47-04:00 Modularize Tidy (#17957) - Factorize Tidy options into TidyOpts datatype. Initialize it in GHC.Driver.Config.Tidy - Same thing for StaticPtrOpts - Perform lookups of unpackCString[Utf8]# once in initStaticPtrOpts instead of for every use of mkStringExprWithFS - - - - - 25101813 by Takenobu Tani at 2022-03-28T01:16:02-04:00 users-guide: Correct markdown for profiling This patch corrects some markdown. [skip ci] - - - - - c832ae93 by Matthew Pickering at 2022-03-28T01:16:38-04:00 hadrian: Flag cabal flag handling This patch basically deletes some ad-hoc handling of Cabal Flags and replaces it with a correct query of the LocalBuildInfo. The flags in the local build info can be modified by users by passing hadrian options For example (!4331) ``` *.genapply.cabal.configure.opts += --flags=unregisterised ``` And all the flags specified by the `Cabal Flags` builder were already passed to configure properly using `--flags`. - - - - - a9f3a5c6 by Ben Gamari at 2022-03-28T01:16:38-04:00 Disable text's dependency on simdutf by default Unfortunately we are simply not currently in a good position to robustly ship binary distributions which link against C++ code like simdutf. Fixes #20724. - - - - - eff86e8a by Richard Eisenberg at 2022-03-28T01:17:14-04:00 Add Red Herring to Note [What might equal later?] Close #21208. - - - - - 12653be9 by jberryman at 2022-03-28T01:17:55-04:00 Document typed splices inhibiting unused bind detection (#16524) - - - - - 4aeade15 by Adam Sandberg Ericsson at 2022-03-28T01:18:31-04:00 users-guide: group ticky-ticky profiling under one heading - - - - - cc59648a by Sylvain Henry at 2022-03-28T01:19:12-04:00 Hadrian: allow testsuite to run with cross-compilers (#21292) - - - - - 89cb1315 by Matthew Pickering at 2022-03-28T01:19:48-04:00 hadrian: Add show target to bindist makefile Some build systems use "make show" to query facts about the bindist, for example: ``` make show VALUE=ProjectVersion > version ``` to determine the ProjectVersion - - - - - 8229885c by Alan Zimmerman at 2022-03-28T19:23:28-04:00 EPA: let stmt with semicolon has wrong anchor The code let ;x =1 Captures the semicolon annotation, but did not widen the anchor in the ValBinds. Fix that. Closes #20247 - - - - - 2c12627c by Ryan Scott at 2022-03-28T19:24:04-04:00 Consistently attach SrcSpans to sub-expressions in TH splices Before, `GHC.ThToHs` was very inconsistent about where various sub-expressions would get the same `SrcSpan` from the original TH splice location or just a generic `noLoc` `SrcSpan`. I have ripped out all uses of `noLoc` in favor of the former instead, and I have added a `Note [Source locations within TH splices]` to officially enshrine this design choice. Fixes #21299. - - - - - 789add55 by Zubin Duggal at 2022-03-29T13:07:22-04:00 Fix all invalid haddock comments in the compiler Fixes #20935 and #20924 - - - - - 967dad03 by Zubin Duggal at 2022-03-29T13:07:22-04:00 hadrian: Build lib:GHC with -haddock and -Winvalid-haddock (#21273) - - - - - ad09a5f7 by sheaf at 2022-03-29T13:08:05-04:00 Hadrian: make DDEBUG separate from debugged RTS This patchs separates whether -DDEBUG is enabled (i.e. whether debug assertions are enabled) from whether we are using the debugged RTS (i.e. GhcDebugged = YES). This means that we properly skip tests which have been marked with `when(compiler_debugged(), skip)`. Fixes #21113, #21153 and #21234 - - - - - 840a6811 by Matthew Pickering at 2022-03-29T13:08:42-04:00 RTS: Zero gc_cpu_start and gc_cpu_end after accounting When passed a combination of `-N` and `-qn` options the cpu time for garbage collection was being vastly overcounted because the counters were not being zeroed appropiately. When -qn1 is passed, only 1 of the N avaiable GC threads is chosen to perform work, the rest are idle. At the end of the GC period, stat_endGC traverses all the GC threads and adds up the elapsed time from each of them. For threads which didn't participate in this GC, the value of the cpu time should be zero, but before this patch, the counters were not zeroed and hence we would count the same elapsed time on many subsequent iterations (until the thread participated in a GC again). The most direct way to zero these fields is to do so immediately after the value is added into the global counter, after which point they are never used again. We also tried another approach where we would zero the counter in yieldCapability but there are some (undiagnosed) siations where a capbility would not pass through yieldCapability before the GC ended and the same double counting problem would occur. Fixes #21082 - - - - - dda46e2d by Matthew Pickering at 2022-03-29T13:09:18-04:00 Add test for T21306 Fixes #21306 - - - - - f07c7766 by Jakob Brünker at 2022-03-30T03:10:33-04:00 Give parsing plugins access to errors Previously, when the parser produced non-fatal errors (i.e. it produced errors but the 'PState' is 'POk'), compilation would be aborted before the 'parsedResultAction' of any plugin was invoked. This commit changes that, so that such that 'parsedResultAction' gets collections of warnings and errors as argument, and must return them after potentially modifying them. Closes #20803 - - - - - e5dfde75 by Ben Gamari at 2022-03-30T03:11:10-04:00 Fix reference to Note [FunBind vs PatBind] This Note was renamed in 2535a6716202253df74d8190b028f85cc6d21b72 yet this occurrence was not updated. - - - - - 21894a63 by Krzysztof Gogolewski at 2022-03-30T03:11:45-04:00 Refactor: make primtypes independent of PrimReps Previously, 'pcPrimTyCon', the function used to define a primitive type, was taking a PrimRep, only to convert it to a RuntimeRep. Now it takes a RuntimeRep directly. Moved primRepToRuntimeRep to GHC.Types.RepType. It is now located next to its inverse function runtimeRepPrimRep. Now GHC.Builtin.Types.Prim no longer mentions PrimRep, and GHC.Types.RepType no longer imports GHC.Builtin.Types.Prim. Removed unused functions `primRepsToRuntimeRep` and `mkTupleRep`. Removed Note [PrimRep and kindPrimRep] - it was never referenced, didn't belong to Types.Prim, and Note [Getting from RuntimeRep to PrimRep] is more comprehensive. - - - - - 43da2963 by Matthew Pickering at 2022-03-30T09:55:49+01:00 Fix mention of non-existent "rehydrateIface" function [skip ci] Fixes #21303 - - - - - 6793a20f by gershomb at 2022-04-01T10:33:46+01:00 Remove wrong claim about naturality law. This docs change removes a longstanding confusion in the Traversable docs. The docs say "(The naturality law is implied by parametricity and thus so is the purity law [1, p15].)". However if one reads the reference a different "natural" law is implied by parametricity. The naturality law given as a law here is imposed. Further, the reference gives examples which violate both laws -- so they cannot be implied by parametricity. This PR just removes the wrong claim. - - - - - 5beeff46 by Ben Gamari at 2022-04-01T10:34:39+01:00 Refactor handling of global initializers GHC uses global initializers for a number of things including cost-center registration, info-table provenance registration, and setup of foreign exports. Previously, the global initializer arrays which referenced these initializers would live in the object file of the C stub, which would then be merged into the main object file of the module. Unfortunately, this approach is no longer tenable with the move to Clang/LLVM on Windows (see #21019). Specifically, lld's PE backend does not support object merging (that is, the -r flag). Instead we are now rather packaging a module's object files into a static library. However, this is problematic in the case of initializers as there are no references to the C stub object in the archive, meaning that the linker may drop the object from the final link. This patch refactors our handling of global initializers to instead place initializer arrays within the object file of the module to which they belong. We do this by introducing a Cmm data declaration containing the initializer array in the module's Cmm stream. While the initializer functions themselves remain in separate C stub objects, the reference from the module's object ensures that they are not dropped from the final link. In service of #21068. - - - - - 3e6fe71b by Matthew Pickering at 2022-04-01T10:35:41+01:00 Fix remaining issues in eventlog types (gen_event_types.py) * The size of End concurrent mark phase looks wrong and, it used to be 4 and now it's 0. * The size of Task create is wrong, used to be 18 and now 14. * The event ticky-ticky entry counter begin sample has the wrong name * The event ticky-ticky entry counter being sample has the wrong size, was 0 now 32. Closes #21070 - - - - - 7847f47a by Ben Gamari at 2022-04-01T10:35:41+01:00 users-guide: Fix a few small issues in eventlog format descriptions The CONC_MARK_END event description didn't mention its payload. Clarify the meaning of the CREATE_TASK's payload. - - - - - acfd5a4c by Matthew Pickering at 2022-04-01T10:35:53+01:00 ci: Regenerate jobs.yaml It seems I forgot to update this to reflect the current state of gen_ci.hs - - - - - a952dd80 by Matthew Pickering at 2022-04-01T10:35:59+01:00 ci: Attempt to fix windows cache issues It appears that running the script directly does nothing (no info is printed about saving the cache). - - - - - fb65e6e3 by Adrian Ratiu at 2022-04-01T10:49:52+01:00 fp_prog_ar.m4: take AR var into consideration In ChromeOS and Gentoo we want the ability to use LLVM ar instead of GNU ar even though both are installed, thus we pass (for eg) AR=llvm-ar to configure. Unfortunately GNU ar always gets picked regardless of the AR setting because the check does not consider the AR var when setting fp_prog_ar, hence this fix. - - - - - 1daaefdf by Greg Steuck at 2022-04-01T10:50:16+01:00 T13366 requires c++ & c++abi libraries on OpenBSD Fixes this failure: =====> 1 of 1 [0, 0, 0] T13366(normal) 1 of 1 [0, 0, 0] Compile failed (exit code 1) errors were: <no location info>: error: user specified .o/.so/.DLL could not be loaded (File not found) Whilst trying to load: (dynamic) stdc++ Additional directories searched: (none) *** unexpected failure for T13366(normal) - - - - - 18e6c85b by Jakob Bruenker at 2022-04-01T10:54:28+01:00 new datatypes for parsedResultAction Previously, the warnings and errors were given and returned as a tuple (Messages PsWarnings, Messages PsErrors). Now, it's just PsMessages. This, together with the HsParsedModule the parser plugin gets and returns, has been wrapped up as ParsedResult. - - - - - 9727e592 by Morrow at 2022-04-01T10:55:12+01:00 Clarify that runghc interprets the input program - - - - - f589dea3 by sheaf at 2022-04-01T10:59:58+01:00 Unify RuntimeRep arguments in ty_co_match The `ty_co_match` function ignored the implicit RuntimeRep coercions that occur in a `FunCo`. Even though a comment explained that this should be fine, #21205 showed that it could result in discarding a RuntimeRep coercion, and thus discarding an important cast entirely. With this patch, we first match the kinds in `ty_co_match`. Fixes #21205 ------------------------- Metric Increase: T12227 T18223 ------------------------- - - - - - 6f4dc372 by Andreas Klebinger at 2022-04-01T11:01:35+01:00 Export MutableByteArray from Data.Array.Byte This implements CLC proposal #49 - - - - - 5df9f5e7 by ARATA Mizuki at 2022-04-01T11:02:35+01:00 Add test cases for #20640 Closes #20640 - - - - - 8334ff9e by Krzysztof Gogolewski at 2022-04-01T11:03:16+01:00 Minor cleanup - Remove unused functions exprToCoercion_maybe, applyTypeToArg, typeMonoPrimRep_maybe, runtimeRepMonoPrimRep_maybe. - Replace orValid with a simpler check - Use splitAtList in applyTysX - Remove calls to extra_clean in the testsuite; it does not do anything. Metric Decrease: T18223 - - - - - b2785cfc by Eric Lindblad at 2022-04-01T11:04:07+01:00 hadrian typos - - - - - 418e6fab by Eric Lindblad at 2022-04-01T11:04:12+01:00 two typos - - - - - dd7c7c99 by Phil de Joux at 2022-04-01T11:04:56+01:00 Add tests and docs on plugin args and order. - - - - - 3e209a62 by MaxHearnden at 2022-04-01T11:05:19+01:00 Change may not to might not - - - - - b84380d3 by Matthew Pickering at 2022-04-01T11:07:27+01:00 hadrian: Remove linters-common from bindist Zubin observed that the bindists contains the utility library linters-common. There are two options: 1. Make sure only the right files are added into the bindist.. a bit tricky due to the non-trivial structure of the lib directory. 2. Remove the bad files once they get copied in.. a bit easier So I went for option 2 but we perhaps should go for option 1 in the future. Fixes #21203 - - - - - ba9904c1 by Zubin Duggal at 2022-04-01T11:07:31+01:00 hadrian: allow testing linters with out of tree compilers - - - - - 26547759 by Matthew Pickering at 2022-04-01T11:07:35+01:00 hadrian: Introduce CheckProgram datatype to replace a 7-tuple - - - - - df65d732 by Jakob Bruenker at 2022-04-01T11:08:28+01:00 Fix panic when pretty printing HsCmdLam When pretty printing a HsCmdLam with more than one argument, GHC panicked because of a missing case. This fixes that. Closes #21300 - - - - - ad6cd165 by John Ericson at 2022-04-01T11:10:06+01:00 hadrian: Remove vestigial -this-unit-id support check This has been dead code since 400ead81e80f66ad7b1260b11b2a92f25ccc3e5a. - - - - - 8ca7ab81 by Matthew Pickering at 2022-04-01T11:10:23+01:00 hadrian: Fix race involving empty package databases There was a small chance of a race occuring between the small window of 1. The first package (.conf) file get written into the database 2. hadrian calling "ghc-pkg recache" to refresh the package.conf file In this window the package database would contain rts.conf but not a package.cache file, and therefore if ghc was invoked it would error because it was missing. To solve this we call "ghc-pkg recache" at when the database is created by shake by writing the stamp file into the database folder. This also creates the package.cache file and so avoids the possibility of this race. - - - - - cc4ec64b by Matthew Pickering at 2022-04-01T11:11:05+01:00 hadrian: Add assertion that in/out tree args are the same There have been a few instances where this calculation was incorrect, so we add a non-terminal assertion when now checks they the two computations indeed compute the same thing. Fixes #21285 - - - - - 691508d8 by Matthew Pickering at 2022-04-01T11:13:10+01:00 hlint: Ignore suggestions in generated HaddockLex file With the make build system this file ends up in the compiler/ subdirectory so is linted. With hadrian, the file ends up in _build so it's not linted. Fixes #21313 - - - - - f8f152e7 by Krzysztof Gogolewski at 2022-04-01T11:14:08+01:00 Change GHC.Prim to GHC.Exts in docs and tests Users are supposed to import GHC.Exts rather than GHC.Prim. Part of #18749. - - - - - f8fc6d2e by Matthew Pickering at 2022-04-01T11:15:24+01:00 driver: Improve -Wunused-packages error message (and simplify implementation) In the past I improved the part of -Wunused-packages which found which packages were used. Now I improve the part which detects which ones were specified. The key innovation is to use the explicitUnits field from UnitState which has the result of resolving the package flags, so we don't need to mess about with the flag arguments from DynFlags anymore. The output now always includes the package name and version (and the flag which exposed it). ``` The following packages were specified via -package or -package-id flags, but were not needed for compilation: - bytestring-0.11.2.0 (exposed by flag -package bytestring) - ghc-9.3 (exposed by flag -package ghc) - process-1.6.13.2 (exposed by flag -package process) ``` Fixes #21307 - - - - - 5e5a12d9 by Matthew Pickering at 2022-04-01T11:15:32+01:00 driver: In oneshot mode, look for interface files in hidir How things should work: * -i is the search path for source files * -hidir explicitly sets the search path for interface files and the output location for interface files. * -odir sets the search path and output location for object files. Before in one shot mode we would look for the interface file in the search locations given by `-i`, but then set the path to be in the `hidir`, so in unusual situations the finder could find an interface file in the `-i` dir but later fail because it tried to read the interface file from the `-hidir`. A bug identified by #20569 - - - - - 950f58e7 by Matthew Pickering at 2022-04-01T11:15:36+01:00 docs: Update documentation interaction of search path, -hidir and -c mode. As noted in #20569 the documentation for search path was wrong because it seemed to indicate that `-i` dirs were important when looking for interface files in `-c` mode, but they are not important if `-hidir` is set. Fixes #20569 - - - - - d85c7dcb by sheaf at 2022-04-01T11:17:56+01:00 Keep track of promotion ticks in HsOpTy This patch adds a PromotionFlag field to HsOpTy, which is used in pretty-printing and when determining whether to emit warnings with -fwarn-unticked-promoted-constructors. This allows us to correctly report tick-related warnings for things like: type A = Int : '[] type B = [Int, Bool] Updates haddock submodule Fixes #19984 - - - - - 32070e6c by Jakob Bruenker at 2022-04-01T20:31:08+02:00 Implement \cases (Proposal 302) This commit implements proposal 302: \cases - Multi-way lambda expressions. This adds a new expression heralded by \cases, which works exactly like \case, but can match multiple apats instead of a single pat. Updates submodule haddock to support the ITlcases token. Closes #20768 - - - - - c6f77f39 by sheaf at 2022-04-01T20:33:05+02:00 Add a regression test for #21323 This bug was fixed at some point between GHC 9.0 and GHC 9.2; this patch simply adds a regression test. - - - - - 3596684e by Jakob Bruenker at 2022-04-01T20:33:05+02:00 Fix error when using empty case in arrow notation It was previously not possible to use -XEmptyCase in Arrow notation, since GHC would print "Exception: foldb of empty list". This is now fixed. Closes #21301 - - - - - 9a325b59 by Ben Gamari at 2022-04-01T20:33:05+02:00 users-guide: Fix various markup issues - - - - - aefb1e6d by sheaf at 2022-04-01T20:36:01+02:00 Ensure implicit parameters are lifted `tcExpr` typechecked implicit parameters by introducing a metavariable of kind `TYPE kappa`, without enforcing that `kappa ~ LiftedRep`. This patch instead creates a metavariable of kind `Type`. Fixes #21327 - - - - - ed62dc66 by Ben Gamari at 2022-04-05T11:44:51-04:00 gitlab-ci: Disable cabal-install store caching on Windows For reasons that remain a mystery, cabal-install seems to consistently corrupt its cache on Windows. Disable caching for now. Works around #21347. - - - - - 5ece5c5a by Ryan Scott at 2022-04-06T13:00:51-04:00 Add /linters/*/dist-install/ to .gitignore Fixes #21335. [ci skip] - - - - - 410c76ee by Ben Gamari at 2022-04-06T13:01:28-04:00 Use static archives as an alternative to object merging Unfortunately, `lld`'s COFF backend does not currently support object merging. With ld.bfd having broken support for high image-load base addresses, it's necessary to find an alternative. Here I introduce support in the driver for generating static archives, which we use on Windows instead of object merging. Closes #21068. - - - - - 400666c8 by Ben Gamari at 2022-04-06T13:01:28-04:00 rts/linker: Catch archives masquerading as object files Check the file's header to catch static archive bearing the `.o` extension, as may happen on Windows after the Clang refactoring. See #21068 - - - - - 694d39f0 by Ben Gamari at 2022-04-06T13:01:28-04:00 driver: Make object merging optional On Windows we don't have a linker which supports object joining (i.e. the `-r` flag). Consequently, `-pgmlm` is now a `Maybe`. See #21068. - - - - - 41fcb5cd by Ben Gamari at 2022-04-06T13:01:28-04:00 hadrian: Refactor handling of ar flags Previously the setup was quite fragile as it had to assume which arguments were file arguments and which were flags. - - - - - 3ac80a86 by Ben Gamari at 2022-04-06T13:01:28-04:00 hadrian: Produce ar archives with L modifier on Windows Since object files may in fact be archive files, we must ensure that their contents are merged rather than constructing an archive-of-an-archive. See #21068. - - - - - 295c35c5 by Ben Gamari at 2022-04-06T13:01:28-04:00 Add a Note describing lack of object merging on Windows See #21068. - - - - - d2ae0a3a by Ben Gamari at 2022-04-06T13:01:28-04:00 Build ar archives with -L when "joining" objects Since there may be .o files which are in fact archives. - - - - - babb47d2 by Zubin Duggal at 2022-04-06T13:02:04-04:00 Add warnings for file header pragmas that appear in the body of a module (#20385) Once we are done parsing the header of a module to obtain the options, we look through the rest of the tokens in order to determine if they contain any misplaced file header pragmas that would usually be ignored, potentially resulting in bad error messages. The warnings are reported immediately so that later errors don't shadow over potentially helpful warnings. Metric Increase: T13719 - - - - - 3f31825b by Ben Gamari at 2022-04-06T13:02:40-04:00 rts/AdjustorPool: Generalize to allow arbitrary contexts Unfortunately the i386 adjustor logic needs this. - - - - - 9b645ee1 by Ben Gamari at 2022-04-06T13:02:40-04:00 adjustors/i386: Use AdjustorPool In !7511 (closed) I introduced a new allocator for adjustors, AdjustorPool, which eliminates the address space fragmentation issues which adjustors can introduce. In that work I focused on amd64 since that was the platform where I observed issues. However, in #21132 we noted that the size of adjustors is also a cause of CI fragility on i386. In this MR I port i386 to use AdjustorPool. Sadly the complexity of the i386 adjustor code does cause require a bit of generalization which makes the code a bit more opaque but such is the world. Closes #21132. - - - - - c657a616 by Ben Gamari at 2022-04-06T13:03:16-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. - - - - - 9ce273b9 by Ben Gamari at 2022-04-06T13:03:16-04:00 gitlab-ci: Drop dead HACKAGE_INDEX_STATE variable - - - - - 01845375 by Ben Gamari at 2022-04-06T13:03:16-04:00 gitlab/darwin: Factor out bindists This makes it a bit easier to bump them. - - - - - c41c478e by Ben Gamari at 2022-04-06T13:03:16-04:00 Fix a few new warnings when booting with GHC 9.2.2 -Wuni-incomplete-patterns and apparent improvements in the pattern match checker surfaced these. - - - - - 6563cd24 by Ben Gamari at 2022-04-06T13:03:16-04:00 gitlab-ci: Bump bootstrap compiler to 9.2.2 This is necessary to build recent `text` commits. Bumps Hackage index state for a hashable which builds with GHC 9.2. - - - - - a62e983e by Ben Gamari at 2022-04-06T13:03:16-04:00 Bump text submodule to current `master` Addresses #21295. - - - - - 88d61031 by Vladislav Zavialov at 2022-04-06T13:03:53-04:00 Refactor OutputableBndrFlag instances The matching on GhcPass introduced by 95275a5f25a is not necessary. This patch reverts it to make the code simpler. - - - - - f601f002 by GHC GitLab CI at 2022-04-06T15:18:26-04:00 rts: Eliminate use of nested functions This is a gcc-specific extension. - - - - - d4c5f29c by Ben Gamari at 2022-04-06T15:18:26-04:00 driver: Drop hacks surrounding windres invocation Drop hack for #1828, among others as they appear to be unnecessary when using `llvm-windres`. - - - - - 6be2c5a7 by Ben Gamari at 2022-04-06T15:18:26-04:00 Windows/Clang: Build system adaptation * Bump win32-tarballs to 0.7 * Move Windows toolchain autoconf logic into separate file * Use clang and LLVM utilities as described in #21019 * Disable object merging as lld doesn't support -r * Drop --oformat=pe-bigobj-x86-64 arguments from ld flags as LLD detects that the output is large on its own. * Drop gcc wrapper since Clang finds its root fine on its own. - - - - - c6fb7aff by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Test that we can build bigobj PE objects - - - - - 79851c07 by Ben Gamari at 2022-04-06T15:18:26-04:00 Drop -static-libgcc This flag is not applicable when Clang is used. - - - - - 1f8a8264 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Port T16514 to C Previously this test was C++ which made it a bit of a portability problem. - - - - - d7e650d1 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Mark Windows as a libc++ platform - - - - - d7886c46 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Mark T9405 as fixed on Windows I have not seen it fail since moving to clang. Closes #12714. - - - - - 4c3fbb4e by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Mark FloatFnInverses as fixed The new toolchain has fixed it. Closes #15670. - - - - - 402c36ba by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Rework T13606 to avoid gcc dependence Previously we used libgcc_s's import library in T13606. However, now that we ship with clang we no longer have this library. Instead we now use gdi32. - - - - - 9934ad54 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Clean up tests depending on C++ std lib - - - - - 12fcdef2 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Split T13366 into two tests Split up the C and C++ uses since the latter is significantly more platform-dependent. - - - - - 3c08a198 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Fix mk-big-obj I'm a bit unclear on how this previously worked as it attempted to build an executable without defining `main`. - - - - - 7e97cc23 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Provide module definitions in T10955dyn Otherwise the linker will export all symbols, including those provided by the RTS, from the produced shared object. Consequently, attempting to link against multiple objects simultaneously will cause the linker to complain that RTS symbols are multiply defined. Avoid this by limiting the DLL exports with a module definition file. - - - - - 9a248afa by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Mark test-defaulting-plugin as fragile on Windows Currently llvm-ar does not handle long file paths, resulting in occassional failures of these tests and #21293. - - - - - 39371aa4 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite/driver: Treat framework failures of fragile tests as non-fatal Previously we would report framework failures of tests marked as fragile as failures. Now we rather treat them as fragile test failures, which are not fatal to the testsuite run. Noticed while investigating #21293. - - - - - a1e6661d by Ben Gamari at 2022-04-06T15:18:32-04:00 Bump Cabal submodule - Disable support for library-for-ghci on Windows as described in #21068. - Teach Cabal to use `ar -L` when available - - - - - f7b0f63c by Ben Gamari at 2022-04-06T15:18:37-04:00 Bump process submodule Fixes missing TEST_CC_OPTS in testsuite tests. - - - - - 109cee19 by Ben Gamari at 2022-04-06T15:18:37-04:00 hadrian: Disable ghci libraries when object merging is not available - - - - - c22fba5c by Ben Gamari at 2022-04-06T15:18:37-04:00 Bump bytestring submodule - - - - - 6e2744cc by Ben Gamari at 2022-04-06T15:18:37-04:00 Bump text submodule - - - - - 32333747 by Ben Gamari at 2022-04-06T15:18:37-04:00 hadrian: Build wrappers using ghc rather than cc - - - - - 59787ba5 by Ben Gamari at 2022-04-06T15:18:37-04:00 linker/PEi386: More descriptive error message - - - - - 5e3c3c4f by Ben Gamari at 2022-04-06T15:18:37-04:00 testsuite: Mark TH_spliceE5_prof as unbroken on Windows It was previously failing due to #18721 and now passes with the new toolchain. Closes #18721. - - - - - 9eb0a9d9 by GHC GitLab CI at 2022-04-06T15:23:48-04:00 rts/PEi386: Move some debugging output to -DL - - - - - ce874595 by Ben Gamari at 2022-04-06T15:24:01-04:00 nativeGen/x86: Use %rip-relative addressing On Windows with high-entropy ASLR we must use %rip-relative addressing to avoid overflowing the signed 32-bit immediate size of x86-64. Since %rip-relative addressing comes essentially for free and can make linking significantly easier, we use it on all platforms. - - - - - 52deee64 by Ben Gamari at 2022-04-06T15:24:01-04:00 Generate LEA for label expressions - - - - - 105a0056 by Ben Gamari at 2022-04-06T15:24:01-04:00 Refactor is32BitLit to take Platform rather than Bool - - - - - ec4526b5 by Ben Gamari at 2022-04-06T15:24:01-04:00 Don't assume that labels are 32-bit on Windows - - - - - ffdbe457 by Ben Gamari at 2022-04-06T15:24:01-04:00 nativeGen: Note signed-extended nature of MOV - - - - - bfb79697 by Ben Gamari at 2022-04-06T15:30:56-04:00 rts: Move __USE_MINGW_ANSI_STDIO definition to PosixSource.h It's easier to ensure that this is included first than Rts.h - - - - - 5ad143fd by Ben Gamari at 2022-04-06T15:30:56-04:00 rts: Fix various #include issues This fixes various violations of the newly-added RTS includes linter. - - - - - a59a66a8 by Ben Gamari at 2022-04-06T15:30:56-04:00 testsuite: Lint RTS #includes Verifies two important properties of #includes in the RTS: * That system headers don't appear inside of a `<BeginPrivate.h>` block as this can hide system library symbols, resulting in very hard-to-diagnose linker errors * That no headers precede `Rts.h`, ensuring that __USE_MINGW_ANSI_STDIO is set correctly before system headers are included. - - - - - 42bf7528 by GHC GitLab CI at 2022-04-06T16:25:04-04:00 rts/PEi386: Fix memory leak Previously we would leak the section information of the `.bss` section. - - - - - d286a55c by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker: Preserve information about symbol types As noted in #20978, the linker would previously handle overflowed relocations by creating a jump island. While this is fine in the case of code symbols, it's very much not okay in the case of data symbols. To fix this we must keep track of whether each symbol is code or data and relocate them appropriately. This patch takes the first step in this direction, adding a symbol type field to the linker's symbol table. It doesn't yet change relocation behavior to take advantage of this knowledge. Fixes #20978. - - - - - e689e9d5 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PEi386: Fix relocation overflow behavior This fixes handling of overflowed relocations on PEi386 targets: * Refuse to create jump islands for relocations of data symbols * Correctly handle the `__imp___acrt_iob_func` symbol, which is an new type of symbol: `SYM_TYPE_INDIRECT_DATA` - - - - - 655e7d8f by GHC GitLab CI at 2022-04-06T16:25:25-04:00 rts: Mark anything that might have an info table as data Tables-next-to-code mandates that we treat symbols with info tables like data since we cannot relocate them using a jump island. See #20983. - - - - - 7e8cc293 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PEi386: Rework linker This is a significant rework of the PEi386 linker, making the linker compatible with high image base addresses. Specifically, we now use the m32 allocator instead of `HeapAllocate`. In addition I found a number of latent bugs in our handling of import libraries and relocations. I've added quite a few comments describing what I've learned about Windows import libraries while fixing these. Thanks to Tamar Christina (@Phyx) for providing the address space search logic, countless hours of help while debugging, and his boundless Windows knowledge. Co-Authored-By: Tamar Christina <tamar at zhox.com> - - - - - ff625218 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PEi386: Move allocateBytes to MMap.c - - - - - f562b5ca by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PEi386: Avoid accidentally-quadratic allocation cost We now preserve the address that we last mapped, allowing us to resume our search and avoiding quadratic allocation costs. This fixes the runtime of T10296a, which allocates many adjustors. - - - - - 3247b7db by Ben Gamari at 2022-04-06T16:25:25-04:00 Move msvcrt dep out of base - - - - - fa404335 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker: More descriptive debug output - - - - - 140f338f by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PathUtils: Define pathprintf in terms of snwprintf on Windows swprintf deviates from usual `snprintf` semantics in that it does not guarantee reasonable behavior when the buffer is NULL (that is, returning the number of bytes that would have been emitted). - - - - - eb60565b by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker: Report archive member index - - - - - 209fd61b by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker: Split up object resolution and initialization Previously the RTS linker would call initializers during the "resolve" phase of linking. However, this is problematic in the case of cyclic dependencies between objects. In particular, consider the case where we have a situation where a static library contains a set of recursive objects: * object A has depends upon symbols in object B * object B has an initializer that depends upon object A * we try to load object A The linker would previously: 1. start resolving object A 2. encounter the reference to object B, loading it resolve object B 3. run object B's initializer 4. the initializer will attempt to call into object A, which hasn't been fully resolved (and therefore protected) Fix this by moving constructor execution to a new linking phase, which follows resolution. Fix #21253. - - - - - 8e8a1021 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker/LoadArchive: Fix leaking file handle Previously `isArchive` could leak a `FILE` handle if the `fread` returned a short read. - - - - - 429ea5d9 by sheaf at 2022-04-07T07:55:52-04:00 Remove Fun pattern from Typeable COMPLETE set GHC merge request !963 improved warnings in the presence of COMPLETE annotations. This allows the removal of the Fun pattern from the complete set. Doing so expectedly causes some redundant pattern match warnings, in particular in GHC.Utils.Binary.Typeable and Data.Binary.Class from the binary library; this commit addresses that. Updates binary submodule Fixes #20230 - - - - - 54b18824 by Alan Zimmerman at 2022-04-07T07:56:28-04:00 EPA: handling of con_bndrs in mkGadtDecl Get rid of unnnecessary case clause that always matched. Closes #20558 - - - - - 9c838429 by Ben Gamari at 2022-04-07T09:38:53-04:00 testsuite: Mark T10420 as broken on Windows Due to #21322. - - - - - 50739d2b by Ben Gamari at 2022-04-07T09:42:42-04:00 rts: Refactor and fix printf attributes on clang Clang on Windows does not understand the `gnu_printf` attribute; use `printf` instead. - - - - - 9eeaeca4 by Ben Gamari at 2022-04-07T09:42:42-04:00 rts: Add missing newline in error message - - - - - fcef9a17 by Ben Gamari at 2022-04-07T09:42:42-04:00 configure: Make environ decl check more robust Some platforms (e.g. Windows/clang64) declare `environ` in `<stdlib.h>`, not `<unistd.h>` - - - - - 8162b4f3 by Ben Gamari at 2022-04-07T09:42:42-04:00 rts: Adjust RTS symbol table on Windows for ucrt - - - - - 633280d7 by Ben Gamari at 2022-04-07T09:43:21-04:00 testsuite: Fix exit code of bounds checking tests on Windows `abort` exits with 255, not 134, on Windows. - - - - - cab4dc01 by Ben Gamari at 2022-04-07T09:43:31-04:00 testsuite: Update expected output from T5435 tests on Windows I'll admit, I don't currently see *why* this output is reordered but it is a fairly benign difference and I'm out of time to investigate. - - - - - edf5134e by Ben Gamari at 2022-04-07T09:43:35-04:00 testsuite: Mark T20918 as broken on Windows Our toolchain on Windows doesn't currently have Windows support. - - - - - d0ddeff3 by Ben Gamari at 2022-04-07T09:43:39-04:00 testsuite: Mark linker unloading tests as broken on Windows Due to #20354. We will need to investigate this prior the release. - - - - - 5a86da2b by Ben Gamari at 2022-04-07T09:43:43-04:00 testsuite: Mark T9405 as broken on Windows Due to #21361. - - - - - 4aa86dcf by Ben Gamari at 2022-04-07T09:44:18-04:00 Merge branches 'wip/windows-high-codegen', 'wip/windows-high-linker', 'wip/windows-clang-2' and 'wip/lint-rts-includes' into wip/windows-clang-join - - - - - 7206f055 by Ben Gamari at 2022-04-07T09:45:07-04:00 rts/CloneStack: Ensure that Rts.h is #included first As is necessary on Windows. - - - - - 9cfcb27b by Ben Gamari at 2022-04-07T09:45:07-04:00 rts: Fallback to ucrtbase not msvcrt Since we have switched to Clang the toolchain now links against ucrt rather than msvcrt. - - - - - d6665d85 by Ben Gamari at 2022-04-07T09:46:25-04:00 Accept spurious perf test shifts on Windows Metric Decrease: T16875 Metric Increase: T12707 T13379 T3294 T4801 T5321FD T5321Fun T783 - - - - - 83363c8b by Simon Peyton Jones at 2022-04-07T12:57:21-04:00 Use prepareBinding in tryCastWorkerWrapper As #21144 showed, tryCastWorkerWrapper was calling prepareRhs, and then unconditionally floating the bindings, without the checks of doFloatFromRhs. That led to floating an unlifted binding into a Rec group. This patch refactors prepareBinding to make these checks, and do them uniformly across all calls. A nice improvement. Other changes * Instead of passing around a RecFlag and a TopLevelFlag; and sometimes a (Maybe SimplCont) for join points, define a new Simplifier-specific data type BindContext: data BindContext = BC_Let TopLevelFlag RecFlag | BC_Join SimplCont and use it consistently. * Kill off completeNonRecX by inlining it. It was only called in one place. * Add a wrapper simplImpRules for simplRules. Compile time on T9630 drops by 4.7%; little else changes. Metric Decrease: T9630 - - - - - 02279a9c by Vladislav Zavialov at 2022-04-07T12:57:59-04:00 Rename [] to List (#21294) This patch implements a small part of GHC Proposal #475. The key change is in GHC.Types: - data [] a = [] | a : [a] + data List a = [] | a : List a And the rest of the patch makes sure that List is pretty-printed as [] in various contexts. Updates the haddock submodule. - - - - - 08480d2a by Simon Peyton Jones at 2022-04-07T12:58:36-04:00 Fix the free-var test in validDerivPred The free-var test (now documented as (VD3)) was too narrow, affecting only class predicates. #21302 demonstrated that this wasn't enough! Fixes #21302. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - b3d6d23d by Andreas Klebinger at 2022-04-07T12:59:12-04:00 Properly explain where INLINE pragmas can appear. Fixes #20676 - - - - - 23ef62b3 by Ben Gamari at 2022-04-07T14:28:28-04:00 rts: Fix off-by-one in snwprintf usage - - - - - b2dbcc7d by Simon Jakobi at 2022-04-08T03:00:38-04:00 Improve seq[D]VarSet Previously, the use of size[D]VarSet would involve a traversal of the entire underlying IntMap. Since IntMaps are already spine-strict, this is unnecessary. - - - - - 64ac20a7 by sheaf at 2022-04-08T03:01:16-04:00 Add test for #21338 This no-skolem-info bug was fixed by the no-skolem-info patch that will be part of GHC 9.4. This patch adds a regression test for the issue reported in issue #21338. Fixes #21338. - - - - - c32c4db6 by Ben Gamari at 2022-04-08T03:01:53-04:00 rts: Move __USE_MINGW_ANSI_STDIO definition to PosixSource.h It's easier to ensure that this is included first than Rts.h - - - - - 56f85d62 by Ben Gamari at 2022-04-08T03:01:53-04:00 rts: Fix various #include issues This fixes various violations of the newly-added RTS includes linter. - - - - - cb1f31f5 by Ben Gamari at 2022-04-08T03:01:53-04:00 testsuite: Lint RTS #includes Verifies two important properties of #includes in the RTS: * That system headers don't appear inside of a `<BeginPrivate.h>` block as this can hide system library symbols, resulting in very hard-to-diagnose linker errors * That no headers precede `Rts.h`, ensuring that __USE_MINGW_ANSI_STDIO is set correctly before system headers are included. - - - - - c44432db by Krzysztof Gogolewski at 2022-04-08T03:02:29-04:00 Fixes to 9.4 release notes - Mention -Wforall-identifier - Improve description of withDict - Fix formatting - - - - - 777365f1 by sheaf at 2022-04-08T09:43:35-04:00 Correctly report SrcLoc of redundant constraints We were accidentally dropping the source location information in certain circumstances when reporting redundant constraints. This patch makes sure that we set the TcLclEnv correctly before reporting the warning. Fixes #21315 - - - - - af300a43 by Vladislav Zavialov at 2022-04-08T09:44:11-04:00 Reject illegal quote mark in data con declarations (#17865) * Non-fatal (i.e. recoverable) parse error * Checking infix constructors * Extended the regression test - - - - - 56254e6b by Ben Gamari at 2022-04-08T09:59:46-04:00 Merge remote-tracking branch 'origin/master' - - - - - 6e2c3b7c by Matthew Pickering at 2022-04-08T13:55:15-04:00 driver: Introduce HomeModInfoCache abstraction The HomeModInfoCache is a mutable cache which is updated incrementally as the driver completes, this makes it robust to exceptions including (SIGINT) The interface for the cache is described by the `HomeMOdInfoCache` data type: ``` data HomeModInfoCache = HomeModInfoCache { hmi_clearCache :: IO [HomeModInfo] , hmi_addToCache :: HomeModInfo -> IO () } ``` The first operation clears the cache and returns its contents. This is designed so it's harder to end up in situations where the cache is retained throughout the execution of upsweep. The second operation allows a module to be added to the cache. The one slightly nasty part is in `interpretBuildPlan` where we have to be careful to ensure that the cache writes happen: 1. In parralel 2. Before the executation continues after upsweep. This requires some simple, localised MVar wrangling. Fixes #20780 - - - - - 85f4a3c9 by Andreas Klebinger at 2022-04-08T13:55:50-04:00 Add flag -fprof-manual which controls if GHC should honour manual cost centres. This allows disabling of manual control centres in code a user doesn't control like libraries. Fixes #18867 - - - - - 3415981c by Vladislav Zavialov at 2022-04-08T13:56:27-04:00 HsUniToken for :: in GADT constructors (#19623) One more step towards the new design of EPA. Updates the haddock submodule. - - - - - 23f95735 by sheaf at 2022-04-08T13:57:07-04:00 Docs: datacon eta-expansion, rep-poly checks The existing notes weren't very clear on how the eta-expansion of data constructors that occurs in tcInferDataCon/dsConLike interacts with the representation polymorphism invariants. So we explain with a few more details how we ensure that the representation-polymorphic lambdas introduced by tcInferDataCon/dsConLike don't end up causing problems, by checking they are properly instantiated and then relying on the simple optimiser to perform beta reduction. A few additional changes: - ConLikeTc just take type variables instead of binders, as we never actually used the binders. - Removed the FRRApp constructor of FRROrigin; it was no longer used now that we use ExpectedFunTyOrigin. - Adds a bit of documentation to the constructors of ExpectedFunTyOrigin. - - - - - d4480490 by Matthew Pickering at 2022-04-08T13:57:43-04:00 ci: Replace "always" with "on_success" to stop build jobs running before hadrian-ghci has finished See https://docs.gitlab.com/ee/ci/yaml/#when * always means, always run not matter what * on_success means, run if the dependencies have built successfully - - - - - 0736e949 by Vladislav Zavialov at 2022-04-08T13:58:19-04:00 Disallow (->) as a data constructor name (#16999) The code was misusing isLexCon, which was never meant for validation. In fact, its documentation states the following: Use these functions to figure what kind of name a 'FastString' represents; these functions do /not/ check that the identifier is valid. Ha! This sign can't stop me because I can't read. The fix is to use okConOcc instead. The other checks (isTcOcc or isDataOcc) seem superfluous, so I also removed those. - - - - - e58d5eeb by Simon Peyton Jones at 2022-04-08T13:58:55-04:00 Tiny documentation wibble This commit commit 83363c8b04837ee871a304cf85207cf79b299fb0 Author: Simon Peyton Jones <simon.peytonjones at gmail.com> Date: Fri Mar 11 16:55:38 2022 +0000 Use prepareBinding in tryCastWorkerWrapper refactored completeNonRecX away, but left a Note referring to it. This MR fixes that Note. - - - - - 4bb00839 by Matthew Pickering at 2022-04-09T07:40:28-04:00 ci: Fix nightly head.hackage pipelines This also needs a corresponding commit to head.hackage, I also made the job explicitly depend on the fedora33 job so that it isn't blocked by a failing windows job, which causes docs-tarball to fail. - - - - - 3c48e12a by Matthew Pickering at 2022-04-09T07:40:28-04:00 ci: Remove doc-tarball dependency from perf and perf-nofib jobs These don't depend on the contents of the tarball so we can run them straight after the fedora33 job finishes. - - - - - 27362265 by Matthew Pickering at 2022-04-09T07:41:04-04:00 Bump deepseq to 1.4.7.0 Updates deepseq submodule Fixes #20653 - - - - - 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
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